Compare commits

...
384 Commits
Author SHA1 Message Date
Github Actions aa7e30070f [CI Skip] release/stable 3.9.1
skip-checks: true
2021-02-14 17:46:51 +00:00
Jaco Greeff 64b5855f65 3.8 (#3174) 2021-02-14 18:39:44 +01:00
Github Actions d7ff9e706e [CI Skip] release/beta 3.8.2-5
skip-checks: true
2021-02-14 08:53:37 +00:00
Jaco Greeff 15ba6f6261 Adjust Result for Rust-compatible Err (w/ deprecation of is/asError) (#3172)
* Adjust Result for Rust-compatible Err (w/ deprecation of is/asError)

* Jsdoc comments

* test updates
2021-02-14 09:43:37 +01:00
Github Actions 8c88a880c6 [CI Skip] release/beta 3.8.2-4
skip-checks: true
2021-02-11 17:27:04 +00:00
Jaco Greeff 74566cce7b Update Rococo types (drop v0) (#3167) 2021-02-11 18:17:05 +01:00
Github Actions 16f6deed5e [CI Skip] release/beta 3.8.2-3
skip-checks: true
2021-02-10 12:14:16 +00:00
Jaco Greeff 40edc131fe Allow geneic args for keys/entries (#3165) 2021-02-10 13:04:23 +01:00
Github Actions 3e014b38e6 [CI Skip] release/beta 3.8.2-2
skip-checks: true
2021-02-10 08:49:29 +00:00
Jaco Greeff b4cfdbffab Fix council derives for seatholders (#3163)
* Fix council derives for setholders

* Fix vote retreival
2021-02-10 09:41:47 +01:00
Github Actions cbfb6f8f59 [CI Skip] release/beta 3.8.2-1
skip-checks: true
2021-02-09 19:00:05 +00:00
Jaco Greeff b5bc15ab8b Last Kusama upgrade block (#3160) 2021-02-09 19:50:24 +01:00
Github Actions 0b343fc0f8 [CI Skip] release/beta 3.8.2-0
skip-checks: true
2021-02-08 15:55:08 +00:00
Jaco Greeff e7f9693873 Add ParaLifecycle type (#3159) 2021-02-08 16:47:02 +01:00
Github Actions a0a5c3185d [CI Skip] release/stable 3.8.1
skip-checks: true
2021-02-07 13:05:43 +00:00
Jaco Greeff 151d4693a9 3.8 (#3158) 2021-02-07 13:56:10 +01:00
Github Actions cdb27d8ec2 [CI Skip] release/beta 3.7.4-8
skip-checks: true
2021-02-07 12:14:25 +00:00
Jaco Greeff 055e4d1261 Bump to common stable (#3157) 2021-02-07 13:06:46 +01:00
Github Actions bf753255ab [CI Skip] release/beta 3.7.4-7
skip-checks: true
2021-02-07 08:59:19 +00:00
Jaco Greeff e2230ef454 Bump common (#3155)
* Bump common

* Adjust (some) tests

* Adjust tests
2021-02-07 09:49:48 +01:00
Github Actions 0f5b01b856 [CI Skip] release/beta 3.7.4-6
skip-checks: true
2021-02-06 13:45:59 +00:00
Jaco Greeff 82787c96c6 Single put_code/deploy (new & backwards compat.) (#3143)
* Single put_code/deploy (new & backwards compat.)

* new-style

* old-style deploy?

* notice

* Cleanups

* linting

* grrr... Mac case-sensistivity

* Add createContract on BluePrint

* Adjust contracts check

* Adjust

* Adjust tests
2021-02-06 14:36:42 +01:00
Github Actions f89028d5fe [CI Skip] release/beta 3.7.4-5
skip-checks: true
2021-02-06 12:09:28 +00:00
Jaco Greeff ba24a2e917 Bump latest Substrate meta (#3154) 2021-02-06 13:00:26 +01:00
Github Actions b549bbf46b [CI Skip] release/beta 3.7.4-4
skip-checks: true
2021-02-06 07:58:57 +00:00
Jaco Greeff 1e87f58f36 Allow extensions on typesBundle (#3142)
* Allow extensions on typesBundle

* User extension take precedence
2021-02-06 08:49:11 +01:00
Github Actions f643426067 [CI Skip] release/beta 3.7.4-3
skip-checks: true
2021-02-05 21:12:04 +00:00
Jaco Greeff 94d26c76ec Check for autoConnectMs on reconnect (#3151)
* Check for autoConnectMs on reconnect

* Update packages/rpc-provider/src/ws/index.ts
2021-02-05 22:03:31 +01:00
Github Actions 8fe262a712 [CI Skip] release/beta 3.7.4-2
skip-checks: true
2021-02-05 15:55:13 +00:00
Jake Naviasky 122ee968cb Add eth filter RPC endpoints and FilterChanges type. (#3150) 2021-02-05 16:45:31 +01:00
Github Actions d2ff350db9 [CI Skip] release/beta 3.7.4-1
skip-checks: true
2021-02-05 07:34:46 +00:00
Nantian 9100aabbac fix signedExtensions type (#3148) 2021-02-05 08:25:17 +01:00
Github Actions 1e73f69253 [CI Skip] release/beta 3.7.4-0
skip-checks: true
2021-02-04 16:16:08 +00:00
Jaco Greeff 7153cb4158 Extend ProxyType with CancelProxy (#3147) 2021-02-04 17:05:56 +01:00
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
Github Actions 970039775d [CI Skip] release/stable 3.3.1
skip-checks: true
2021-01-04 10:08:22 +00:00
Jaco Greeff 2ddcd59ed0 3.3 (#3017) 2021-01-04 11:01:09 +01:00
Github Actions a4519495ad [CI Skip] release/beta 3.2.4-13
skip-checks: true
2021-01-03 10:35:48 +00:00
Jaco Greeff a9c9fb5769 2021 (#3015) 2021-01-03 11:26:46 +01:00
Github Actions 0e928a2a11 [CI Skip] release/beta 3.2.4-12
skip-checks: true
2021-01-02 09:46:10 +00:00
Jaco Greeff 756b24f10a Bum dev (#3014) 2021-01-02 10:37:47 +01:00
Github Actions 85a37b2604 [CI Skip] release/beta 3.2.4-11
skip-checks: true
2021-01-02 09:22:17 +00:00
Jaco Greeff e0e8d37a64 Extract ss58 from system constants (as available) (#3006)
* Extract ss58 from system constants (as available)

* merge

* optional
2021-01-02 10:12:53 +01:00
Github Actions 4c4fd2afd1 [CI Skip] release/beta 3.2.4-10
skip-checks: true
2021-01-02 08:53:19 +00:00
Jaco Greeff 926d1e55d1 Parallel RPC calls (metadata/methods alongside chain details) (#3011)
* Parallel metadata retrieval

* Update

* Parallel genesisHash

* Checks

* rpc_methods in mock provider (now required)
2021-01-02 09:44:08 +01:00
Github Actions 491e7cd155 [CI Skip] release/beta 3.2.4-9
skip-checks: true
2021-01-01 11:18:39 +00:00
Jaco Greeff ed2d6e8d0e Build metadata with rpc aliasses (#3013)
* Build metadata with rpc aliasses

* links
2021-01-01 12:11:30 +01:00
Github Actions 714f72d6c3 [CI Skip] release/beta 3.2.4-8
skip-checks: true
2021-01-01 09:42:31 +00:00
Jaco Greeff 8671171061 Bump metadata (#3012) 2021-01-01 10:34:07 +01:00
Github Actions 45b176de7d [CI Skip] release/beta 3.2.4-7
skip-checks: true
2020-12-31 12:50:25 +00:00
Jaco Greeff 1901b8899d Bump dev/util (#3010) 2020-12-31 13:41:57 +01:00
Github Actions 9ead0103a9 [CI Skip] release/beta 3.2.4-6
skip-checks: true
2020-12-30 17:28:11 +00:00
Miguel Hervas af0bcc80e8 Adding RT4 Types (#3007)
* update to rc6 types

* Adding RT4 Types
2020-12-30 18:20:54 +01:00
Github Actions e0b7dd13e0 [CI Skip] release/beta 3.2.4-5
skip-checks: true
2020-12-29 21:38:22 +00:00
Jaco Greeff 9e13b6f54e blockWeights.maxBlock for estimation (#3004) 2020-12-29 22:29:13 +01:00
Github Actions 6aa5a2dd0c [CI Skip] release/beta 3.2.4-4
skip-checks: true
2020-12-29 21:26:50 +00:00
Jaco Greeff 361f9e4419 Apply aliases for constants (#3003)
* Apply aliasses for constants

* Remove todo

* shortcut

* Re-add metaVersion
2020-12-29 22:17:31 +01:00
Github Actions 1ca00c7633 [CI Skip] release/beta 3.2.4-3
skip-checks: true
2020-12-29 20:50:46 +00:00
Jaco Greeff 83f36e466f Check metadata.version instead of isIndexed (#3002)
* Check metadata.version instead of isIndexed

* Bump
2020-12-29 21:42:06 +01:00
Jaco Greeff e685923102 Add ExitReason types (evm) (#3001)
* Add ExitReason types (evm)

* Log, Account, Vicinity
2020-12-29 21:28:04 +01:00
Github Actions 3aaa6db190 [CI Skip] release/beta 3.2.4-2
skip-checks: true
2020-12-29 14:54:38 +00:00
Ewa Kowalska a98b6b9bf8 Add bounty index to DeriveBounty (#3000)
* Add bounty index to DeriveBounty

* Apply review suggestions
2020-12-29 15:46:03 +01:00
Github Actions fc0148fd41 [CI Skip] release/beta 3.2.4-1
skip-checks: true
2020-12-29 14:38:29 +00:00
Jaco Greeff 1dc04ec8bd pre (#2999) 2020-12-29 15:31:12 +01:00
Github Actions 3c2617fe5c [CI Skip] release/stable 3.2.3
skip-checks: true
2020-12-29 10:13:45 +00:00
Jaco Greeff 9e20006d24 3.2.3 2020-12-29 11:03:57 +01:00
Github Actions dcd5a0b620 [CI Skip] release/beta 3.2.3-5
skip-checks: true
2020-12-29 10:01:17 +00:00
Jaco Greeff 6f5b852bf7 Work around incorrect contracts.call RPC handler (#2998) 2020-12-29 10:53:11 +01:00
Github Actions 22e4abc903 [CI Skip] release/beta 3.2.3-4
skip-checks: true
2020-12-28 14:11:29 +00:00
Jaco Greeff b5e37c020d Call return is CallBase (w/ method, section) (#2996)
* Call return is CallBase (w/ method, section)

* Remove {section, method}Name

* mthod/section

* compare via .is
2020-12-28 15:02:27 +01:00
Github Actions a806e4a2ee [CI Skip] release/beta 3.2.3-3
skip-checks: true
2020-12-28 12:30:05 +00:00
Jaco Greeff 9164637c44 Fix augmented generation for RPC w/ alias (#2994)
* Fix augmented generation for RPC w/ alias

* Fix

* Rebuild
2020-12-28 13:21:43 +01:00
Antoine EstienneandJaco Greeff 1ba8f71da1 add client version and sh3 decorators for web3 (#2993)
* add client version and sh3 decorators for web3

* add web3 to rpcCore

* refactored with correct file

* Apply suggestions from code review

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

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-12-28 13:12:12 +01:00
Github Actions 91693bf587 [CI Skip] release/beta 3.2.3-2
skip-checks: true
2020-12-28 11:01:04 +00:00
Jaco Greeff e6a99b9f07 metadataMd section aliasses (#2992) 2020-12-28 11:54:18 +01:00
Github Actions f6d9ba2471 [CI Skip] release/beta 3.2.3-1
skip-checks: true
2020-12-28 10:46:54 +00:00
Jaco Greeff af24955bc7 3.2.3-0 (#2990) 2020-12-28 11:39:58 +01:00
Github Actions 3e66807716 [CI Skip] release/stable 3.2.2
skip-checks: true
2020-12-28 09:16:19 +00:00
Jaco Greeff f34d48ad09 3.2.2 (#2988)
* 3.2.2

* Patch correctly
2020-12-28 10:07:58 +01:00
Github Actions 0d7be67499 [CI Skip] release/stable 3.2.1
skip-checks: true
2020-12-27 19:24:36 +00:00
Jaco Greeff 7804794233 3.2 (#2987) 2020-12-27 20:15:08 +01:00
Github Actions c7a68a4e05 [CI Skip] release/beta 3.1.2-11
skip-checks: true
2020-12-27 12:06:46 +00:00
Jaco Greeff 811f9f7868 Support for eth_getProof RPC (#2986) 2020-12-27 12:59:29 +01:00
Github Actions d9acf1cfea [CI Skip] release/beta 3.1.2-10
skip-checks: true
2020-12-27 10:23:11 +00:00
Jaco Greeff 0967dbba6b Add api.{errors, events, query, tx}.<method>.<section>.is(...) (#2984)
* api.{event, error}.<section>.is<Type>

* Full generation, with checkTypes

* .is

* Extrinsic with arg type definition

* decorate is

* Call is

* Remove hasOrigin

* Renames

* Query is

* Fix extrinsic is

* Backwards compatibility for generated types

* event with optional AnyTuple

* Cleanups

* Cleanups

* Adjust

* Cleanup
2020-12-27 11:15:02 +01:00
Github Actions 025a745258 [CI Skip] release/beta 3.1.2-9
skip-checks: true
2020-12-27 08:19:59 +00:00
Jaco Greeff 88eb4fd6e5 Bump util (#2985) 2020-12-27 09:11:36 +01:00
Github Actions 0dcdffd59c [CI Skip] release/beta 3.1.2-8
skip-checks: true
2020-12-25 08:07:54 +00:00
yjh 1f39ad264a fix MetadataVersioned.asV12 (#2983) 2020-12-25 09:00:51 +01:00
Github Actions e357a08118 [CI Skip] release/beta 3.1.2-7
skip-checks: true
2020-12-24 07:38:46 +00:00
Jaco Greeff d6b2b4a1a3 Remove support for pre-v2 staking (#2980)
* Remove support for pre-v2 staking

* Adjust with util array functions

* Remove old enumset support

* Empty controller

* withController flag
2020-12-24 08:32:03 +01:00
Github Actions 47f2ee725f [CI Skip] release/beta 3.1.2-6
skip-checks: true
2020-12-22 16:28:53 +00:00
Jaco Greeff 1028e14761 Format <= 32 as number, > as hex (not used size) (#2978) 2020-12-22 17:21:42 +01:00
Github Actions 5fdefa9e58 [CI Skip] release/beta 3.1.2-5
skip-checks: true
2020-12-22 14:39:16 +00:00
Jaco Greeff 80209da5c5 Add frontier RPCs (& types for them) (#2976)
* Add frontier RPCs (& types for them)

* Add filters

* Cleanup optional params

* Add ethereum module aliasses

* Split rpc

* Split net RPC

* full block details

* onlyHex

* Revert onlyHex change
2020-12-22 15:30:48 +01:00
Github Actions bbdf0e3192 [CI Skip] release/beta 3.1.2-4
skip-checks: true
2020-12-22 10:51:07 +00:00
Jaco Greeff 9ee1c0bf13 AccountInfo with provider/consumers (#2975) 2020-12-22 11:42:47 +01:00
Github Actions 5490947384 [CI Skip] release/beta 3.1.2-3
skip-checks: true
2020-12-22 09:34:59 +00:00
Jaco Greeff b1788be796 Bump deps (#2974) 2020-12-22 10:26:17 +01:00
Github Actions f4ec312656 [CI Skip] release/beta 3.1.2-2
skip-checks: true
2020-12-21 18:46:36 +00:00
Jaco Greeff e1057603fc MessageIngestionType (parachains) (#2973)
* MessageIngestionType (parachains)

* _'s
2020-12-21 19:39:46 +01:00
Github Actions 0268e398c1 [CI Skip] release/beta 3.1.2-1
skip-checks: true
2020-12-21 18:37:49 +00:00
Jaco Greeff 757d45b39e Few missing type imports (#2972) 2020-12-21 19:29:22 +01:00
Github Actions 4f57a5a611 [CI Skip] release/beta 3.1.2-0
skip-checks: true
2020-12-21 16:26:14 +00:00
Jaco Greeff 987896e323 Adjust for last remaining circular deps (#2971)
* Adjust for last remaining circular deps

* Remove RegistryMetadata duplication

* Update packages/typegen/scripts/polkadot-types-internal-interfaces.js

* typo

* Direct decorateExtrinsics import
2020-12-21 17:17:20 +01:00
Github Actions 1b9d3bf38e [CI Skip] release/stable 3.1.1
skip-checks: true
2020-12-20 15:51:02 +00:00
Jaco Greeff b8a0f39da4 3.1 (#2969) 2020-12-20 16:44:07 +01:00
Github Actions e4e20f8a88 [CI Skip] release/beta 3.0.2-14
skip-checks: true
2020-12-20 11:18:17 +00:00
Jaco Greeff 131729e438 Adjust bountyBase for keys (#2968) 2020-12-20 12:08:56 +01:00
Github Actions 4672439bce [CI Skip] release/beta 3.0.2-13
skip-checks: true
2020-12-20 09:45:36 +00:00
Jaco Greeff 0b11fc98b9 Update to latest Substrate metadata (#2967)
* Update to latest Substrate metadata

* Update bounties derive

* Cleanups

* Update bounty location
2020-12-20 10:36:38 +01:00
Github Actions ece0a4b19a [CI Skip] release/beta 3.0.2-12
skip-checks: true
2020-12-19 15:33:16 +00:00
Jaco Greeff 1dac7e3f1b Bump util (#2966)
* Bump util

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md
2020-12-19 16:24:17 +01:00
Github Actions 3e1c93d4a8 [CI Skip] release/beta 3.0.2-11
skip-checks: true
2020-12-19 10:57:24 +00:00
Jaco Greeff 19e9af02d8 Bump deps 2020-12-19 11:47:32 +01:00
Github Actions 2200cc2fab [CI Skip] release/beta 3.0.2-10
skip-checks: true
2020-12-18 15:34:09 +00:00
Jaco Greeff 33990b6d02 Update types for parachains (#2964)
* Update types for parachains

* alias VecDeque
2020-12-18 16:25:53 +01:00
Github Actions 333313fd6a [CI Skip] release/beta 3.0.2-9
skip-checks: true
2020-12-18 10:42:33 +00:00
Jaco Greeff 33fd09c053 Bump dev 2020-12-18 11:33:28 +01:00
Github Actions 7dadac7344 [CI Skip] release/beta 3.0.2-8
skip-checks: true
2020-12-17 13:05:48 +00:00
Jaco Greeff 340554a659 Mark detectPackage as sideEffect 2020-12-17 13:57:48 +01:00
Github Actions 236ad16406 [CI Skip] release/beta 3.0.2-7
skip-checks: true
2020-12-17 11:57:14 +00:00
Jaco Greeff aae4671db5 Bump common, detectPackage with callback 2020-12-17 12:49:05 +01:00
Github Actions d0f9eb7d03 [CI Skip] release/beta 3.0.2-6
skip-checks: true
2020-12-16 14:53:01 +00:00
Jaco Greeff d6106b3253 Allow detectPackage with import.meta.url (#2962)
* Allow detectPackage with import.meta.url

* Fix detectPackage import

* header naming
2020-12-16 15:46:02 +01:00
Github Actions 9740c282d8 [CI Skip] release/beta 3.0.2-5
skip-checks: true
2020-12-16 14:01:09 +00:00
Jaco Greeff f65b5c77ec RxJs esm for non-node (#2961) 2020-12-16 14:54:16 +01:00
Github Actions 0f920ee77d [CI Skip] release/beta 3.0.2-4
skip-checks: true
2020-12-16 12:19:27 +00:00
DavidandJaco Greeff 62d1415d1b Don't log full error (#2952)
* Don't log full error

In `txwrapper` we can't always know if a payload is a signing payload or a signed tx so we first try one and then the other. When the former fails users get a scary-looking error. If upstream logs the error there's little we can do about it lest we [monkey patch `console.error`](https://github.com/paritytech/txwrapper-core/pull/22/files#diff-ea2d1c5845dd0e2fb9814e98a3464c2c63a43922983391e98fe9c20c328e979cR55) which is nasty af.

Hence this PR that removes the log here so that downstream can choose what to do with the error message.

* Add UnsafeOptions to let callers decide if they want errors logged or not

* Update packages/api-contract/src/util.ts

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

* Update packages/rpc-core/src/index.ts

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

* Update packages/rpc-core/src/index.ts

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

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

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

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-12-16 13:12:50 +01:00
Github Actions f8792e09c9 [CI Skip] release/beta 3.0.2-3
skip-checks: true
2020-12-16 11:42:45 +00:00
Jaco Greeff 8d4b03d066 Thin rxjs wrapper for esm (#2960)
* Thin rxjs wrapper for esm

* Comprehensive exports
2020-12-16 12:35:44 +01:00
Github Actions 5d3c728cf0 [CI Skip] release/beta 3.0.2-2
skip-checks: true
2020-12-15 22:40:49 +00:00
Ian HeandIan He 04340de6ae Http provider support multi (#2950)
* use queryStorageAt for multi storage queries

* fix lint

* e2e tests

* skip lints for api.spec.ts

* remove e2e test from PR

* do not decorate multi() if can not supported

* empty line

* update

Co-authored-by: Ian He <ian.he@centrality.ai>
2020-12-15 23:32:45 +01:00
Github Actions d709a5b3be [CI Skip] release/beta 3.0.2-1
skip-checks: true
2020-12-15 14:00:58 +00:00
Jaco Greeff 1d3dfc77a3 Use package-info (name/version only) for detectPackage (#2955)
* Use package-info (name/version only) for detectPackage

* Fixed @polkadot/dev?
2020-12-15 14:52:27 +01:00
Antoine EstienneandJaco Greeff a72d33ad24 Add missing parachain types (#2954)
* adde dmissing types

* replaced id with u32

* Apply suggestions from code review

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

* camelCase

* lint

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-12-15 14:51:55 +01:00
Github Actions e4948ef579 [CI Skip] release/beta 3.0.2-0
skip-checks: true
2020-12-14 15:53:52 +00:00
Jaco Greeff f9812585b8 Remove core single-type create duplication (#2888)
* Remove coe single-type create duplication

* Re-add entry index
2020-12-14 16:45:30 +01:00
Github Actions e2654dd2f8 [CI Skip] release/stable 3.0.1
skip-checks: true
2020-12-14 09:21:39 +00:00
Jaco Greeff 5f0ea88a42 3.0 (#2948)
* 3.0

* CHANGELOG typos
2020-12-14 10:13:17 +01:00
Github Actions 69be690be6 [CI Skip] release/beta 2.10.2-18
skip-checks: true
2020-12-13 16:02:40 +00:00
Jaco Greeff 67d4637786 Bump common (#2947) 2020-12-13 16:55:38 +01:00
Github Actions d2557a3cac [CI Skip] release/beta 2.10.2-17
skip-checks: true
2020-12-13 13:22:02 +00:00
Jaco Greeff e2911a33c4 Replace memoizee with memoize from @polkadot/util (#2946) 2020-12-13 14:15:13 +01:00
Github Actions 9b45901760 [CI Skip] release/beta 2.10.2-16
skip-checks: true
2020-12-13 10:22:49 +00:00
Jaco Greeff 450f53d563 Bump common (#2945)
* Bump common

* Expand CHANGELOG
2020-12-13 11:15:47 +01:00
Github Actions 5374c863ad [CI Skip] release/beta 2.10.2-15
skip-checks: true
2020-12-12 13:12:08 +00:00
Jaco Greeff ce29ae6e0e Bump common (#2944) 2020-12-12 14:05:13 +01:00
Github Actions d420c65c2b [CI Skip] release/beta 2.10.2-14
skip-checks: true
2020-12-11 23:14:23 +00:00
Jaco Greeff 427ae64fab Bump dev (#2943) 2020-12-12 00:06:32 +01:00
Github Actions 173c40b0e5 [CI Skip] release/beta 2.10.2-13
skip-checks: true
2020-12-11 17:51:07 +00:00
Jaco Greeff 208fbb24d5 Build esm (& add x-rxjs package) (#2942) 2020-12-11 18:44:23 +01:00
Github Actions 9ee563e3f6 [CI Skip] release/beta 2.10.2-12
skip-checks: true
2020-12-11 09:28:01 +00:00
Jaco Greeff 70acb27218 Bump dev 2020-12-11 10:19:39 +01:00
Github Actions dd29ebbeae [CI Skip] release/beta 2.10.2-11
skip-checks: true
2020-12-10 16:51:46 +00:00
Jaco Greeff b01935122f Build esm alongside (don't use) (#2940) 2020-12-10 17:43:33 +01:00
Github Actions 71d54821e0 [CI Skip] release/beta 2.10.2-10
skip-checks: true
2020-12-10 14:50:44 +00:00
Jaco Greeff 5df3e1605a Bump deps (#2938) 2020-12-10 15:43:29 +01:00
Github Actions 50737b7ef7 [CI Skip] release/beta 2.10.2-9
skip-checks: true
2020-12-09 19:08:39 +00:00
Jaco Greeff ecc86f797c Bump dev (prefer esm in esm mode) (#2937) 2020-12-09 20:01:36 +01:00
Github Actions ff020d14e4 [CI Skip] release/beta 2.10.2-8
skip-checks: true
2020-12-09 17:08:37 +00:00
Jaco Greeff ff36cb97c2 Bump common, allow esm alongside cjs (#2936)
* Bump common, allow esm alongside cjs

* Bumps
2020-12-09 18:00:01 +01:00
Github Actions 01f2fe7c86 [CI Skip] release/beta 2.10.2-7
skip-checks: true
2020-12-09 11:17:31 +00:00
Jaco Greeff 948d8cccc1 Swap to Metadata <-> registry path imports (#2934)
* Swap to Metadata <-> registry path imports

* Call circulars
2020-12-09 12:09:20 +01:00
Github Actions da2e2f89c9 [CI Skip] release/beta 2.10.2-6
skip-checks: true
2020-12-09 10:10:27 +00:00
Alex D 6b4fd110a1 Types bundle derive (#2932)
* added derives typesBundle overrides

* fix lint
2020-12-09 11:01:33 +01:00
Jaco Greeff a48eba101c Adjust Type dependency on Text (#2933) 2020-12-09 11:01:11 +01:00
Github Actions 78b9d29fa0 [CI Skip] release/beta 2.10.2-5
skip-checks: true
2020-12-08 16:52:37 +00:00
Jaco Greeff 92c9ce15d6 Expand SessionKeys[n] definitions (#2929)
* Expand SessionKeys[n] definitions

* Update packages/types/src/interfaces/session/definitions.ts
2020-12-08 17:44:35 +01:00
Github Actions 11c4239614 [CI Skip] release/beta 2.10.2-4
skip-checks: true
2020-12-08 16:33:06 +00:00
Jaco Greeff 0cb7b34ff0 Update with new consumed Weight structures (#2928)
* Update with new consumed Weight structures

* dispatch(Info, Error} optional in result

* Update for maximumBlockWeight
2020-12-08 17:26:13 +01:00
Github Actions a74382c539 [CI Skip] release/beta 2.10.2-3
skip-checks: true
2020-12-08 12:33:19 +00:00
Krzysztof Jelski beccc2ed9b Derive for bounties and descriptions (#2925)
* WIP on bounties derive.

* wip

* Some basic tests for derive bounties

* Simplify bounties derive and mocks

* Get bounties and descriptions

* Allow for empty bounties. Refactor tests.

* Move tests to test directory

* Attempt to remove duplication

* Sort imports

* Reorganize tests

* Change returned type
2020-12-08 13:25:30 +01:00
Jaco Greeff c29f66c7c5 Inject RPC definitions from typesBundle (#2927)
* Inject RPC definitions from typesBundle

* Augment RPC only, don't clobber
2020-12-08 13:23:41 +01:00
Github Actions dba23e3923 [CI Skip] release/beta 2.10.2-2
skip-checks: true
2020-12-08 10:34:37 +00:00
Jaco Greeff f633b3d6c1 Remove --fix on CI (#2926) 2020-12-08 11:27:07 +01:00
Github Actions b1c7409c59 [CI Skip] release/beta 2.10.2-1
skip-checks: true
2020-12-07 16:34:27 +00:00
Jaco Greeff a2423b1004 Add query sizeAt (#2922)
* Add query sizeAt

* @deprecated for .range
2020-12-07 17:27:33 +01:00
Github Actions c0f1bf7f1e [CI Skip] release/beta 2.10.2-0
skip-checks: true
2020-12-07 15:34:13 +00:00
Jaco Greeff 8e6a1c8fb1 Bump dev (sort imports) (#2923)
* Bump dev (sort imports)

* Resort

* Adjust ApiInterfaceRx
2020-12-07 16:26:19 +01:00
Github Actions 92ee9ab339 [CI Skip] release/stable 2.10.1
skip-checks: true
2020-12-07 10:18:58 +00:00
Jaco Greeff 70f1fa5514 2.10 (#2920)
* 2.10

* Use system.blockHashCount
2020-12-07 11:11:39 +01:00
Github Actions 37f49b30de [CI Skip] release/beta 2.9.2-13
skip-checks: true
2020-12-06 10:39:11 +00:00
Jaco Greeff 8b4d3872d7 Bump metadata (w/ AssetBalance, AssetDetails) (#2917)
* Bump metadata (w/ AssetBalance, AssetDetails)

* Bluperint for new-style with salt as default

* Use TBalance

* Easier overrides

* Balance

* Build types
2020-12-06 11:31:54 +01:00
Github Actions 4e2ab3d11c [CI Skip] release/beta 2.9.2-12
skip-checks: true
2020-12-06 09:58:41 +00:00
Jaco Greeff b1291bfbe3 system_{addLogFilter, resetLogFilter} RPCs (#2916) 2020-12-06 10:51:05 +01:00
Github Actions 026ef3c4ed [CI Skip] release/beta 2.9.2-11
skip-checks: true
2020-12-05 10:06:04 +00:00
Jaco Greeff 158fe79c43 Bump deps (minor) (#2914) 2020-12-05 10:58:25 +01:00
Github Actions c467efdb3b [CI Skip] release/beta 2.9.2-10
skip-checks: true
2020-12-04 12:01:42 +00:00
Jaco Greeff b1d0eb9597 Revert "Add signExtrinsic on the Signer interface (#2912)"
This reverts commit a9e8388cc8.
2020-12-04 12:54:14 +01:00
Github Actions 3b9149d3ac [CI Skip] release/beta 2.9.2-9
skip-checks: true
2020-12-04 11:31:06 +00:00
Jaco Greeff a9e8388cc8 Add signExtrinsic on the Signer interface (#2912)
* Add signExtrinsic on the Signer interface

* Unused registry
2020-12-04 12:22:40 +01:00
Github Actions a33265e5ed [CI Skip] release/beta 2.9.2-8
skip-checks: true
2020-12-03 08:53:55 +00:00
Jaco Greeff 1d6bfb69ff Limit to maximum hashes (250) in era length calcs (#2910) 2020-12-03 09:45:23 +01:00
Github Actions 96f32c63fd [CI Skip] release/beta 2.9.2-7
skip-checks: true
2020-12-03 07:23:50 +00:00
Jaco Greeff 07b69fe635 .multi with no params (#2908)
* .multi with no params

* Adjust batch size
2020-12-03 08:16:24 +01:00
Github Actions a579f3e09c [CI Skip] release/beta 2.9.2-6
skip-checks: true
2020-12-02 19:38:40 +00:00
Jaco Greeff 6559b1ad11 Retrieve ledger for payouts (#2901) 2020-12-02 20:30:40 +01:00
Github Actions f7da1d0fb2 [CI Skip] release/beta 2.9.2-5
skip-checks: true
2020-12-02 18:31:04 +00:00
Jaco Greeff 94e57f6dcf hasIndentities extract base (#2900) 2020-12-02 19:23:30 +01:00
Github Actions 1364c45d16 [CI Skip] release/beta 2.9.2-4
skip-checks: true
2020-12-02 15:54:07 +00:00
Jaco Greeff 54b5b38ba6 Additional query opts (flags) (#2899) 2020-12-02 16:47:47 +01:00
Github Actions 944f4ddf1d [CI Skip] release/beta 2.9.2-3
skip-checks: true
2020-12-02 13:56:41 +00:00
Jaco Greeff 895d44fe9f Optimize use of derive staking.query (with full results) (#2897) 2020-12-02 14:49:14 +01:00
Github Actions eccc6cc2c9 [CI Skip] release/beta 2.9.2-2
skip-checks: true
2020-12-02 11:17:38 +00:00
Jaco Greeff a7c2d11a56 Update parachain types (#2895) 2020-12-02 12:09:47 +01:00
Github Actions a71744bd16 [CI Skip] release/beta 2.9.2-1
skip-checks: true
2020-12-02 09:18:47 +00:00
Jaco Greeff 0e52e8fe23 Some type imports (interfaces) (#2887)
* Some type imports (interfaces)

* Additional

* Additional

* Small movements/fixes

* Additional

* Additional

* Unsaved...
2020-12-02 10:12:19 +01:00
Github Actions 2769336344 [CI Skip] release/beta 2.9.2-0
skip-checks: true
2020-12-01 20:41:29 +00:00
Jaco Greeff 522906695f Bump berry (#2893)
* Bump berry

* rewrite
2020-12-01 21:33:46 +01:00
Github Actions f7c968b7a6 [CI Skip] release/stable 2.9.1
skip-checks: true
2020-11-30 11:25:01 +00:00
Jaco Greeff c1b7660122 2.9 (#2891) 2020-11-30 12:16:29 +01:00
Github Actions 811a2291ed [CI Skip] release/beta 2.8.3-5
skip-checks: true
2020-11-29 15:16:18 +00:00
Jaco Greeff 90cc148383 Correct hasIdentity parentId extraction (#2884) 2020-11-29 16:08:39 +01:00
Github Actions b652bdc2de [CI Skip] release/beta 2.8.3-4
skip-checks: true
2020-11-29 14:24:26 +00:00
Jaco Greeff f6942cc0f0 Extract identity-only derive from accounts.info (#2882)
* Extract identity-only derive from accounts.info

* Add hasIdentity

* hasIdentityMulti
2020-11-29 15:16:54 +01:00
Github Actions 8e852db87c [CI Skip] release/beta 2.8.3-3
skip-checks: true
2020-11-29 11:49:15 +00:00
Jordan 75f97bb1ff Allow typegen for custom RPCs (#2876)
* Allow typegen for custom RPCs

* It runs

* fix lint

* Remove unused metadata arg
2020-11-29 12:42:42 +01:00
Github Actions c8d7e971bc [CI Skip] release/beta 2.8.3-2
skip-checks: true
2020-11-28 12:05:18 +00:00
Jaco Greeff 09aa046ab4 Remove send queue, always require connection (#2881)
* Remove send queue, always require connection

* Adjust tests for non-queued
2020-11-28 12:57:24 +01:00
Github Actions 25e29d9565 [CI Skip] release/beta 2.8.3-1
skip-checks: true
2020-11-28 11:32:57 +00:00
Jaco Greeff c396b963ee Version bump (pre) (#2880) 2020-11-28 12:25:56 +01:00
Github Actions 46be42705b [CI Skip] release/stable 2.8.2
skip-checks: true
2020-11-28 11:09:03 +00:00
Jaco Greeff d65eb7a27f Raw slice with from (like subarray) (#2879)
* Raw slice with from (like subarray)

* Dep bumps

* 2.8.2

* re-use toU8a()

* Uint8Array.from

* slice on derived comment
2020-11-28 12:00:29 +01:00
Github Actions a1a73cbf01 [CI Skip] release/beta 2.8.2-3
skip-checks: true
2020-11-26 10:41:05 +00:00
Jaco Greeff 72e03138e8 Fix 0-259 for node 2020-11-26 11:33:32 +01:00
Github Actions b0e7440ca6 [CI Skip] release/beta 2.8.2-2
skip-checks: true
2020-11-26 10:09:35 +00:00
Jaco Greeff 4847988a94 Types for Substrate node (MultiAddress) (#2875) 2020-11-26 11:02:31 +01:00
Github Actions a58be22764 [CI Skip] release/beta 2.8.2-1
skip-checks: true
2020-11-25 12:15:04 +00:00
Jaco Greeff f6af257051 derive.staking.electedInfo also contains current (#2874) 2020-11-25 13:08:17 +01:00
Github Actions 790e0ebdcf [CI Skip] release/beta 2.8.2-0
skip-checks: true
2020-11-24 12:22:26 +00:00
Jaco Greeff 1db2cfbedf Bump deps (#2872) 2020-11-24 13:13:12 +01:00
641 changed files with 18601 additions and 9262 deletions
+11 -1
View File
@@ -4,4 +4,14 @@
1.11.2
1.12.2
1.17.2
1.31.2
1.31.2
2.8.2
3.2.2
3.2.3
3.3.2
3.6.2
3.6.3
3.6.4
3.7.2
3.7.3
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
const base = require('@polkadot/dev/config/eslint.cjs');
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-55
View File
File diff suppressed because one or more lines are too long
+55
View File
File diff suppressed because one or more lines are too long
+1 -3
View File
@@ -9,7 +9,5 @@ plugins:
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
yarnPath: .yarn/releases/yarn-2.3.3.cjs
yarnPath: .yarn/releases/yarn-2.4.0.cjs
+267
View File
@@ -1,5 +1,272 @@
# CHANGELOG
## 3.9.1 Feb 14, 2021
Upgrade priority: Low.
- **Important** The `Result<T, E>` has been updated in the generation and the base types to follow the Rust version 100%. This means `{as, is}Error` is now available as `{as, is}Err` on the `Result` type. The older versions can still be used, but the `*Error` interfaces are now marked as deprecated.
Changes:
- Adjust `Result<T, E>` interface to be 100% compatible with the Rust version
- Add the `2028` upgrade to the known upgrades (optimizing certain `.at` queries)
- Adjust council derives to cater for latest Substrate & Polkadot
- Adjust Rococo know type definitions to cater for the latest update
- Update types for latest Polkadot/Substrate
- Add generic arguments for TypeScript users to `.entries/.keys` to deal with the key typings
## 3.8.1 Feb 7, 2021
Upgrade priority: Low. Recommended for users of the latest Substrate master, especially using contracts.
- **Important** The `api-contract` `Code` now supports deploying the code and a contract in on operation. This aligns with the latest Substrate where code cannot be uploaded with a contract. The `createBlueprint` is therefore deprecated, use `code.tx.<constructor>(...)` to deploy code. (Compatible with both old and new versions of Substrate)
Contributed:
- Add support for latest Frontier RPCs (Thanks to https://github.com/jnaviask)
- Fix user-supplied signed extensions type signature (Thanks to https://github.com/ntduan)
Changes:
- Expand `api-contract` to allow for `Code` to deploy contract alongside code. `createBlueprint` is now deprecated, replaced by `createContract` or the preferred `code.tx.<constructor>`, which uploads and deploys the code in one operation. This aligns with the current Substrate master contracts implementation.
- Allow for signed extensions to be supplied inside type bundles
- Ensure that the auto-connect state is checked on auto-connections (respecting disconnect)
- Added `CancelProxy` to `ProxyTypes on Polkadot, Kusama & Westend
- Updated to latest Substrate metadata
## 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
Upgrade priority: Low. Recommended for users of frontier evm module with additional types.
Contributed:
- Expand bounty derives (Thanks to https://github.com/ekowalsk)
- Adjust known-types (Thanks to https://github.com/mikiquantum)
Changes:
- Parallelize the API-init RPC calls for faster overall startup
- Add `ExitReason` types for the frontier evm module
- Adjust checks for indexed/non-indexed module checks (metadata decoration)
- Apply module aliases on constants (aligning with events, extrinsics)
- Allow for use of `system.ss58Prefix` as exposed (current Substrate master)
- Correct use of api-contract `blockWeights.maxBlock` in estimation
- Build metadata docs & interfaces with section aliases
- Update to latest Substrate master metadata in tests
## 3.2.1 Dec 27, 2020
Upgrade priority: Low. Recommended for users of parachains.
Contributed:
- Adjust metadata `.asV12` type signature (Thanks to https://github.com/yjhmelody)
Changes:
- Add `api.{errors, events, query, tx}.<section>.<name>.is(...)`
- Remove support for staking pre Substrate 2.0
- Add all frontier types & RPCs
- Support `AccountInfo` with new provider/consumer refCount structure
- Additional Cumulus parachain types
- Consistently format number JSON based on bitLength
- Cleanup metadata -> api dependencies
- Update `@polkadot/util` to 5.2.1
## 3.1.1 Dec 20, 2020
Upgrade priority: Low. Recommended for users of parachains.
Contributed:
- Additional parachain types (Thanks to https://github.com/joelamouche)
- Support for multi queries with `HttpProvider` (Thanks to https://github.com/ianhe8x)
- Configurable error logging with `createTypeUnsafe` (Thanks to https://github.com/dvdplm)
Changes:
- Adjust core type creation, removing storage duplication
- Update parachain types to support Rococo v1
- Adjust bounties derive to cater for new Substrate namespaces (& move to bounties)
- Mark `detectPackage` as known side-effect
- Add `detectPackage` to `@polkadot/metadata` (a number of requests on this)
- Adjust x-rxjs wrapper to expose all methods, incl. Node.js esm fixes
- Update to latest Substrate static metadata
- Update `@polkadot/util` to 5.1.1
## 3.0.1 Dec 14, 2020
Upgrade priority: Low. Recommended for the next Kusama/Polkadot upgrades due to additional types and those following chains following Substrate master closely.
**Important** While this package contains no external interface changes, it now compiles and ships both cjs and esm modules. This means that modern bundlers will have more information for tree-shaking available. Additionally when using Node with `.mjs` extensions, the esm version imports will be used on recent Node versions. Adding an export map, as here, may have some impacts so a major semver bump is advised. There may be (small) dragons hiding in the dark corners...
Contributed:
- Injection of derives via typesBundle (Thanks to https://github.com/pr0fedt)
- Added derives for bounties (Thanks to https://github.com/krzysztof-jelski)
Changes:
- Build and expose both cjs and esm via exports map
- Inject RPC definitions for typesBundle, allowing per-spec configuration
- Added `query.<section>.<method>.sizeAt(hash, [...params])` for all storage
- Add new Substrate consumed Weight types
- Expand `SessionKeys<n>` definitions (up to 9)
- Cleanup circular `Type` <-> `Text` definitions
- Cleanup circular `Metadata` <-> `TypeRegistry` imports
- Update `@polkadot/util` to 5.0.1
## 2.10.1 Dec 7, 2020
Upgrade priority: Low. Recommended when following Substrate master and/or parachains development, contains the latest types for both.
- **Breaking change** If using the `staking.query` derive, you now need to pass flags as to which values to retrieve
Changes:
- Ensure that maximum era is limited to `consts.system.blockHashCount` (don't overflow on very low blocktimes)
- Apply current Polkadot master parachain types
- Apply current Substrate master asset types
- Add `system_{addLogFilter, resetLogFilter}` RPCs
- Adjust tests for latest Substrate metadata
- Adjust staking derives to be more performant (flags indicate which query values to retrieve)
- Add account derive to cater for the availability of identities
- Use `import type` in all cases
## 2.9.1 Nov 30, 2020
Upgrade priority: Low. No major changes when on at least 2.8.2. Users encouraged to upgrade to at least that patch.
- **Breaking change** The API will now not attempt to queue calls made while not connected and send on connection. Rather when making a call and the RPC node is not connected, an error will be thrown.
Contributed:
- Add typegen capability for custom RPCs (Thanks to https://github.com/holygits)
Changes:
- Remove rpc-core send queue, only allow sends while connected
- Adjust staking derive for `electedInfo` to contain details of current validators
- Extract identity-only derive from `accounts.info` for simpler reusability
- Add types for Substrate master node (to allow for consistent swapping to `MultiAddress`)
- Adjust `Bytes` with `.slice` to be consistent for `Uint8array` extensions (already released in 2.8.2 as a bugfix)
## 2.8.1 Nov 23, 2020
Upgrade priority: Low. Recommended if using Substrate master with new `MultiAddress`.
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
module.exports = require('@polkadot/dev/config/babel-config-cjs.cjs');
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
const config = require('@polkadot/dev/config/jest.cjs');
+12 -10
View File
@@ -3,14 +3,16 @@
"author": "Jaco Greeff <jacogr@gmail.com>",
"license": "Apache-2",
"private": true,
"type": "commonjs",
"workspaces": [
"packages/*"
],
"resolutions": {
"typescript": "^4.0.5"
"typescript": "^4.1.3"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
"build": "yarn build:interfaces && polkadot-dev-build-ts",
"build:extra": "(cd packages/typegen && copyfiles scripts/* build)",
"build:interfaces": "polkadot-types-internal-interfaces",
"build:release": "polkadot-ci-ghact-build",
"docs:metadata": "polkadot-types-internal-metadata",
@@ -23,14 +25,14 @@
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/register": "^7.12.1",
"@babel/runtime": "^7.12.5",
"@polkadot/dev": "^0.60.3",
"@polkadot/ts": "^0.3.55",
"@babel/core": "^7.12.13",
"@babel/register": "^7.12.13",
"@babel/runtime": "^7.12.13",
"@polkadot/dev": "^0.61.25",
"@polkadot/ts": "^0.3.59",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.15",
"copyfiles": "^2.4.0"
"@types/jest": "^26.0.20",
"copyfiles": "^2.4.1"
},
"version": "2.8.1"
"version": "3.9.1"
}
+7 -11
View File
@@ -1,13 +1,9 @@
{
"name": "@polkadot/api-contract",
"version": "2.8.1",
"version": "3.9.1",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"sideEffects": false,
"keywords": [
"Polkadot",
"ABI"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
@@ -16,11 +12,11 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/api": "2.8.1",
"@polkadot/types": "2.8.1",
"@polkadot/util": "^4.2.1",
"bn.js": "^4.11.9",
"rxjs": "^6.6.3"
"@babel/runtime": "^7.12.13",
"@polkadot/api": "3.9.1",
"@polkadot/types": "3.9.1",
"@polkadot/util": "^5.6.2",
"@polkadot/x-rxjs": "^5.6.2",
"bn.js": "^4.11.9"
}
}
+2 -3
View File
@@ -1,9 +1,8 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { Abi } from '.';
import abis from '../test/contracts';
import { Abi } from '.';
interface JSONAbi {
spec: {
+5 -5
View File
@@ -1,11 +1,11 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
import { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageSpec, ContractMessageParamSpec, ContractProject } from '@polkadot/types/interfaces';
import { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
import type { Bytes } from '@polkadot/types';
import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageParamSpec, ContractMessageSpec, ContractProject } from '@polkadot/types/interfaces';
import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
import { Bytes } from '@polkadot/types';
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util';
import { MetaRegistry } from './MetaRegistry';
@@ -1,12 +1,11 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import fs from 'fs';
import path from 'path';
import { Abi } from '.';
import abis from '../test/contracts';
import { Abi } from '.';
describe('MetaRegistry', (): void => {
Object.keys(abis).forEach((abiName) => {
+5 -4
View File
@@ -1,11 +1,12 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ContractDisplayName, ChainProperties, SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefVariant, SiTypeDefSequence, SiTypeDefTuple, SiVariant } from '@polkadot/types/interfaces';
import { InterfaceTypes, TypeDef, TypeDefInfo } from '@polkadot/types/types';
import type { ChainProperties, ContractDisplayName, SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces';
import type { InterfaceTypes, TypeDef } from '@polkadot/types/types';
import { assert, isUndefined } from '@polkadot/util';
import { TypeRegistry, withTypeString } from '@polkadot/types/create';
import { TypeDefInfo } from '@polkadot/types/types';
import { assert, isUndefined } from '@polkadot/util';
interface PartialTypeSpec {
readonly type: SiLookupTypeId;
+4 -4
View File
@@ -1,8 +1,8 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import { AnyJson, Registry } from '@polkadot/types/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { AnyJson, Registry } from '@polkadot/types/types';
import { ApiBase } from '@polkadot/api/base';
import { assert } from '@polkadot/util';
@@ -26,6 +26,6 @@ export abstract class Base<ApiType extends ApiTypes> {
this.registry = this.abi.registry;
this._decorateMethod = decorateMethod;
assert(this.api.rx.tx.contracts && this.api.rx.tx.contracts.putCode, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
assert(api.rx.tx.contracts?.instantiate, 'You need to connect to a node with the contracts module, the metadata does not enable api.tx.contracts on this instance');
}
}
+16 -42
View File
@@ -1,48 +1,22 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
import { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import { AbiConstructor, BlueprintOptions } from '../types';
import { BlueprintDeploy, ContractGeneric, MapConstructorExec } from './types';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { ContractGeneric, MapConstructorExec } from './types';
import BN from 'bn.js';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { Bytes } from '@polkadot/types';
import { isUndefined, stringCamelCase, compactAddLength, u8aToU8a } from '@polkadot/util';
import { randomAsU8a } from '@polkadot/util-crypto';
import { isUndefined, stringCamelCase } from '@polkadot/util';
import { Abi } from '../Abi';
import { applyOnEvent, extractOptions, isOptions } from '../util';
import { applyOnEvent } from '../util';
import { Base } from './Base';
import { Contract } from './Contract';
const EMPTY_SALT = new Uint8Array();
function createTx <ApiType extends ApiTypes> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>>): BlueprintDeploy<ApiType> {
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> =>
isOptions(options)
? fn(options, params)
: fn(...extractOptions(options, params));
}
function createWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
isOptions(options)
? fn(constructorOrId, options, params)
: fn(constructorOrId, ...extractOptions(options, params));
}
function encodeSalt (salt: Uint8Array | string | null = randomAsU8a()) {
return salt instanceof Bytes
? salt
: salt && salt.length
? compactAddLength(u8aToU8a(salt))
: EMPTY_SALT;
}
import { createBluePrintTx, createBluePrintWithId, EMPTY_SALT, encodeSalt } from './util';
export class BlueprintSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
public readonly contract?: Contract<ApiType>;
@@ -72,13 +46,13 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
super(api, abi, decorateMethod);
this.codeHash = this.registry.createType('Hash', codeHash);
this.createContract = createWithId(this.#deploy);
this.createContract = createBluePrintWithId(this.#deploy);
this.abi.constructors.forEach((c): void => {
const messageName = stringCamelCase(c.identifier);
if (isUndefined(this.#tx[messageName])) {
this.#tx[messageName] = createTx((o, p) => this.#deploy(c, o, p));
this.#tx[messageName] = createBluePrintTx((o, p) => this.#deploy(c, o, p));
}
});
}
@@ -87,18 +61,18 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
return this.#tx;
}
#deploy = (constructorOrId: AbiConstructor | string| number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
const encodedSalt = encodeSalt(salt);
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
const tx = withSalt
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore new style with salt included
? this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded, encodedSalt)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore old style with salt included
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encoded);
return tx.withResultTransform((result: ISubmittableResult) =>
new BlueprintSubmittableResult(result, applyOnEvent(result, 'Instantiated', ([record]: EventRecord[]) =>
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
))
);
+3 -2
View File
@@ -1,14 +1,15 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import fs from 'fs';
import path from 'path';
import { decorateMethod } from '@polkadot/api/promise';
import contractFlipper from '../../test/contracts/ink/flipper.contract.json';
import abiFlipper from '../../test/contracts/ink/flipper.json';
import { mockApi } from './mock';
import { Code } from './Code';
import { mockApi } from './mock';
const wasmFlipper = fs.readFileSync(path.join(__dirname, '../../test/contracts/ink/flipper.wasm'));
+78 -8
View File
@@ -1,33 +1,42 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import { EventRecord, Hash } from '@polkadot/types/interfaces';
import { AnyJson, ISubmittableResult } from '@polkadot/types/types';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { EventRecord, Hash } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { MapConstructorExec } from './types';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { assert, compactAddLength, isWasm, u8aToU8a } from '@polkadot/util';
import { assert, compactAddLength, isFunction, isUndefined, isWasm, stringCamelCase, u8aToU8a } from '@polkadot/util';
import { blake2AsU8a } from '@polkadot/util-crypto';
import { Abi } from '../Abi';
import { applyOnEvent } from '../util';
import { Base } from './Base';
import { Blueprint } from './Blueprint';
import { Contract } from './Contract';
import { createBluePrintTx, EMPTY_SALT, encodeSalt } from './util';
export class CodeSubmittableResult<ApiType extends ApiTypes> extends SubmittableResult {
public readonly blueprint?: Blueprint<ApiType>;
public readonly contract?: Contract<ApiType>;
constructor (result: ISubmittableResult, blueprint?: Blueprint<ApiType>) {
constructor (result: ISubmittableResult, blueprint?: Blueprint<ApiType>, contract?: Contract<ApiType>) {
super(result);
this.blueprint = blueprint;
this.contract = contract;
}
}
export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
public readonly code: Uint8Array;
readonly #tx: MapConstructorExec<ApiType> = {};
constructor (api: ApiBase<ApiType>, abi: AnyJson | Abi, wasm: Uint8Array | string | Buffer | null | undefined, decorateMethod: DecorateMethod<ApiType>) {
super(api, abi, decorateMethod);
@@ -36,18 +45,79 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
: u8aToU8a(wasm);
assert(isWasm(this.code), 'No WASM code provided');
this.abi.constructors.forEach((c): void => {
const messageName = stringCamelCase(c.identifier);
if (isUndefined(this.#tx[messageName])) {
this.#tx[messageName] = createBluePrintTx((o, p) => this.#instantiate(c, o, p));
}
});
}
/**
* @description Deploy the code bundle, creating a Blueprint.
* @deprecated Use the `code.tx.<constructor>(...) format to put code and deploy
*/
public createBlueprint (): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
return this.api.tx.contracts
.putCode(compactAddLength(this.code))
.withResultTransform((result: ISubmittableResult) =>
new CodeSubmittableResult(result, applyOnEvent(result, 'CodeStored', ([record]: EventRecord[]) =>
new CodeSubmittableResult(result, applyOnEvent(result, ['CodeStored'], ([record]: EventRecord[]) =>
new Blueprint<ApiType>(this.api, this.abi, record.event.data[0] as Hash, this._decorateMethod)
))
);
}
/**
* @description Deploy the code bundle and the contract, creating a Blueprint.
* @deprecated Use the `code.tx.<constructor>(...) format to put code and deploy
*/
public createContract (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> {
return this.#instantiate(constructorOrId, options, params);
}
public get tx (): MapConstructorExec<ApiType> {
return this.#tx;
}
#instantiate = (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
return isFunction(this.api.tx.contracts.instantiateWithCode)
? this.#instantiateSingle(constructorOrId, options, params)
: this.#instantiateBatch(constructorOrId, options, params);
}
#instantiateSingle = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
return this.api.tx.contracts
.instantiateWithCode(value, gasLimit, compactAddLength(this.code), this.abi.findConstructor(constructorOrId).toU8a(params), encodeSalt(salt))
.withResultTransform(this.#transformEvents);
}
#instantiateBatch = (constructorOrId: AbiConstructor | string | number, { gasLimit = 0, salt, value = 0 }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
const encodedSalt = encodeSalt(salt);
const withSalt = this.api.tx.contracts.instantiate.meta.args.length === 5;
const encoded = this.abi.findConstructor(constructorOrId).toU8a(params, withSalt ? EMPTY_SALT : encodedSalt);
const codeHash = blake2AsU8a(this.code);
return this.api.tx.utility.batch([
this.api.tx.contracts.putCode(compactAddLength(this.code)),
withSalt
? this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded, encodedSalt)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore old style with salt included in the params itself
: this.api.tx.contracts.instantiate(value, gasLimit, codeHash, encoded)
]).withResultTransform(this.#transformEvents);
}
#transformEvents = (result: ISubmittableResult): CodeSubmittableResult<ApiType> => {
return new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
records.reduce(([blueprint, contract], { event }): [Blueprint<ApiType>?, Contract<ApiType>?] =>
this.api.events.contracts.Instantiated.is(event)
? [blueprint, new Contract<ApiType>(this.api, this.abi, event.data[1], this._decorateMethod)]
: this.api.events.contracts.CodeStored.is(event)
? [new Blueprint<ApiType>(this.api, this.abi, event.data[0], this._decorateMethod), contract]
: [blueprint, contract],
[] as [Blueprint<ApiType>?, Contract<ApiType>?])
) || []));
}
}
+15 -11
View File
@@ -1,19 +1,20 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import { AccountId, ContractExecResult, EventRecord } from '@polkadot/types/interfaces';
import { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
import { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
import { ContractCallResult, ContractCallSend, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { Bytes } from '@polkadot/types';
import type { AccountId, ContractExecResult, EventRecord, Weight } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult, Registry } from '@polkadot/types/types';
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
import type { ContractCallResult, ContractCallSend, ContractGeneric, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
import BN from 'bn.js';
import { map } from 'rxjs/operators';
import { SubmittableResult } from '@polkadot/api';
import { ApiBase } from '@polkadot/api/base';
import { Bytes } from '@polkadot/types';
import { assert, bnToBn, isFunction, isUndefined, logger, stringCamelCase } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
import { Abi } from '../Abi';
import { applyOnEvent, extractOptions, formatData, isOptions } from '../util';
@@ -144,7 +145,10 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
return gasLimit.lten(0)
? isCall
? MAX_CALL_GAS
: this.api.consts.system.maximumBlockWeight.muln(64).divn(100)
: (this.api.consts.system.blockWeights
? this.api.consts.system.blockWeights.maxBlock
: this.api.consts.system.maximumBlockWeight as Weight
).muln(64).divn(100)
: gasLimit;
}
@@ -152,7 +156,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
return this.api.tx.contracts
.call(this.address, value, this.#getGas(gasLimit), this.abi.findMessage(messageOrId).toU8a(params))
.withResultTransform((result: ISubmittableResult) =>
new ContractSubmittableResult(result, applyOnEvent(result, 'ContractExecution', (records: EventRecord[]) =>
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractExecution'], (records: EventRecord[]) =>
records
.map(({ event: { data: [, data] } }): DecodedEvent | null => {
try {
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api authors & contributors
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { Blueprint, BlueprintSubmittableResult } from './Blueprint';
+4 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiBase } from '@polkadot/api/base';
@@ -11,6 +11,9 @@ export const mockApi = {
rx: {
tx: {
contracts: {
instantiate: (): never => {
throw new Error('mock');
},
putCode: (): never => {
throw new Error('mock');
}
+8 -9
View File
@@ -1,14 +1,13 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes, ObsInnerType } from '@polkadot/api/types';
import { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import { AccountId } from '@polkadot/types/interfaces';
import { CodecArg } from '@polkadot/types/types';
import { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
import BN from 'bn.js';
import { Observable } from 'rxjs';
import type BN from 'bn.js';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { CodecArg } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
export interface BlueprintDeploy<ApiType extends ApiTypes> {
(options: BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
+41
View File
@@ -0,0 +1,41 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { SubmittableResult } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes } from '@polkadot/api/types';
import type { CodecArg } from '@polkadot/types/types';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { BlueprintDeploy, ContractGeneric } from './types';
import BN from 'bn.js';
import { Bytes } from '@polkadot/types';
import { compactAddLength, u8aToU8a } from '@polkadot/util';
import { randomAsU8a } from '@polkadot/util-crypto';
import { extractOptions, isOptions } from '../util';
export const EMPTY_SALT = new Uint8Array();
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, R> =>
isOptions(options)
? fn(options, params)
: fn(...extractOptions(options, params));
}
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
isOptions(options)
? fn(constructorOrId, options, params)
: fn(constructorOrId, ...extractOptions(options, params));
}
export function encodeSalt (salt: Uint8Array | string | null = randomAsU8a()): Uint8Array {
return salt instanceof Bytes
? salt
: salt && salt.length
? compactAddLength(u8aToU8a(salt))
: EMPTY_SALT;
}
@@ -1,10 +1,10 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Simple non-runnable checks to test type definitions in the editor itself
import { ApiPromise } from '@polkadot/api';
import { TestKeyringMap, createTestPairs } from '@polkadot/keyring/testingPairs';
import { createTestPairs, TestKeyringMap } from '@polkadot/keyring/testingPairs';
import abiIncrementer from '../test/contracts/ink/incrementer.json';
import { BlueprintPromise, ContractPromise } from '.';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { Abi } from './Abi';
@@ -1,8 +1,8 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { Hash } from '@polkadot/types/interfaces';
import { AnyJson } from '@polkadot/types/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { AnyJson } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { decorateMethod } from '@polkadot/api/promise';
+4 -3
View File
@@ -1,9 +1,10 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiPromise } from '@polkadot/api';
import type { ApiPromise } from '@polkadot/api';
import type { AnyJson } from '@polkadot/types/types';
import { decorateMethod } from '@polkadot/api/promise';
import { AnyJson } from '@polkadot/types/types';
import { Abi } from '../Abi';
import { Code as BaseCode } from '../base';
@@ -1,8 +1,8 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId } from '@polkadot/types/interfaces';
import { AnyJson } from '@polkadot/types/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { AnyJson } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { decorateMethod } from '@polkadot/api/promise';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { Blueprint } from './Blueprint';
+2 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
+3 -3
View File
@@ -1,8 +1,8 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { Hash } from '@polkadot/types/interfaces';
import { AnyJson } from '@polkadot/types/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { AnyJson } from '@polkadot/types/types';
import { ApiRx } from '@polkadot/api';
import { decorateMethod } from '@polkadot/api/rx';
+3 -3
View File
@@ -1,9 +1,9 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AnyJson } from '@polkadot/types/types';
import type { ApiRx } from '@polkadot/api';
import type { AnyJson } from '@polkadot/types/types';
import { ApiRx } from '@polkadot/api';
import { decorateMethod } from '@polkadot/api/rx';
import { Abi } from '../Abi';
+3 -3
View File
@@ -1,8 +1,8 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId } from '@polkadot/types/interfaces';
import { AnyJson } from '@polkadot/types/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { AnyJson } from '@polkadot/types/types';
import { ApiRx } from '@polkadot/api';
import { decorateMethod } from '@polkadot/api/rx';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { Blueprint } from './Blueprint';
+2 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
+8 -10
View File
@@ -1,15 +1,13 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiTypes } from '@polkadot/api/types';
import { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
import { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
import BN from 'bn.js';
import { ApiBase } from '@polkadot/api/base';
import { Text, u64 } from '@polkadot/types';
import { Abi } from '.';
import type BN from 'bn.js';
import type { ApiBase } from '@polkadot/api/base';
import type { ApiTypes } from '@polkadot/api/types';
import type { Text, u64 } from '@polkadot/types';
import type { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
import type { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
import type { Abi } from '.';
export interface ContractBase<ApiType extends ApiTypes> {
readonly abi: Abi;
+11 -10
View File
@@ -1,27 +1,28 @@
// Copyright 2017-2020 @polkadot/rpc-contract authors & contributors
// Copyright 2017-2021 @polkadot/rpc-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { SubmittableResult } from '@polkadot/api';
import { EventRecord } from '@polkadot/types/interfaces';
import { Codec, CodecArg, Registry, TypeDef } from '@polkadot/types/types';
import { BlueprintOptions, ContractOptions } from './types';
import type { SubmittableResult } from '@polkadot/api';
import type { Raw } from '@polkadot/types';
import type { EventRecord } from '@polkadot/types/interfaces';
import type { Codec, CodecArg, Registry, TypeDef } from '@polkadot/types/types';
import type { BlueprintOptions, ContractOptions } from './types';
import BN from 'bn.js';
import { Raw } from '@polkadot/types';
import { createTypeUnsafe } from '@polkadot/types/create';
import { isBn, isBigInt, isNumber, isString } from '@polkadot/util';
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
type ContractEvents = 'CodeStored' | 'ContractExecution' | 'Instantiated';
type TOptions = BlueprintOptions | ContractOptions;
export function formatData (registry: Registry, data: Raw, { type }: TypeDef): Codec {
return createTypeUnsafe(registry, type, [data], true);
return createTypeUnsafe(registry, type, [data], { isPedantic: true });
}
export function applyOnEvent <T> (result: SubmittableResult, type: ContractEvents, fn: (records: EventRecord[]) => T): T | undefined {
export function applyOnEvent <T> (result: SubmittableResult, types: ContractEvents[], fn: (records: EventRecord[]) => T): T | undefined {
if (result.isInBlock || result.isFinalized) {
const records = result.filterRecords('contracts', type);
const records = result.filterRecords('contracts', types);
if (records.length) {
return fn(records);
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import * as ink from './ink';
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { default as delegator } from './delegator.json';
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { default as ints256 } from './ints256.json';
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
export { default as assetTransfer } from './assetTransfer.json';
+11 -17
View File
@@ -1,14 +1,9 @@
{
"name": "@polkadot/api-derive",
"version": "2.8.1",
"version": "3.9.1",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"sideEffects": false,
"keywords": [
"Polkadot",
"Promise",
"RxJs"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
"contributors": [],
@@ -17,18 +12,17 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@polkadot/api": "2.8.1",
"@polkadot/rpc-core": "2.8.1",
"@polkadot/types": "2.8.1",
"@polkadot/util": "^4.2.1",
"@polkadot/util-crypto": "^4.2.1",
"bn.js": "^4.11.9",
"memoizee": "^0.4.14",
"rxjs": "^6.6.3"
"@babel/runtime": "^7.12.13",
"@polkadot/api": "3.9.1",
"@polkadot/rpc-core": "3.9.1",
"@polkadot/types": "3.9.1",
"@polkadot/util": "^5.6.2",
"@polkadot/util-crypto": "^5.6.2",
"@polkadot/x-rxjs": "^5.6.2",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^4.2.1",
"@polkadot/rpc-provider": "2.8.1"
"@polkadot/keyring": "^5.6.2",
"@polkadot/rpc-provider": "3.9.1"
}
}
@@ -1,13 +1,14 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { isU8a, assertReturn } from '@polkadot/util';
import { assertReturn, isU8a } from '@polkadot/util';
import { decodeAddress } from '@polkadot/util-crypto';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
+9 -8
View File
@@ -1,14 +1,15 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, Address, Balance } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveAccountFlags } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Vec } from '@polkadot/types';
import type { AccountId, Address, Balance } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveAccountFlags } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { Vec } from '@polkadot/types';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
+11 -10
View File
@@ -1,18 +1,19 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { AccountIdAndIndex } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { AccountIdAndIndex } from '../types';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { isU8a } from '@polkadot/util';
import { decodeAddress } from '@polkadot/util-crypto';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIndex | string | null | undefined): Observable<AccountIdAndIndex> {
function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIndex | Uint8Array | string | null | undefined): Observable<AccountIdAndIndex> {
try {
// yes, this can fail, don't care too much, catch will catch it
const decoded = isU8a(address)
@@ -39,7 +40,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
/**
* @name idAndIndex
* @param {(Address | AccountId | AccountIndex | string | null)} address - An accounts address in various formats.
* @param {(Address | AccountId | AccountIndex | Uint8Array | string | null)} address - An accounts address in various formats.
* @description An array containing the [[AccountId]] and [[AccountIndex]] as optional values.
* @example
* <BR>
@@ -50,7 +51,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
* });
* ```
*/
export function idAndIndex (instanceId: string, api: ApiInterfaceRx): (address?: Address | AccountId | AccountIndex | string | null) => Observable<AccountIdAndIndex> {
return memo(instanceId, (address?: Address | AccountId | AccountIndex | string | null): Observable<AccountIdAndIndex> =>
export function idAndIndex (instanceId: string, api: ApiInterfaceRx): (address?: Address | AccountId | AccountIndex | Uint8Array | string | null) => Observable<AccountIdAndIndex> {
return memo(instanceId, (address?: Address | AccountId | AccountIndex | Uint8Array | string | null): Observable<AccountIdAndIndex> =>
retrieve(api, address));
}
@@ -1,12 +1,12 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
import { AccountIndexes } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, AccountIndex } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { AccountIndexes } from '../types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -0,0 +1,141 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Data, Option } from '@polkadot/types';
import type { AccountId, IdentityInfoAdditional, Registration } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveAccountRegistration, DeriveHasIdentity } from '../types';
import { isHex, u8aToString } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
const UNDEF_HEX = { toHex: () => undefined };
function dataAsString (data: Data): string | undefined {
return data.isRaw
? u8aToString(data.asRaw.toU8a(true))
: data.isNone
? undefined
: data.toHex();
}
function extractOther (additional: IdentityInfoAdditional[]): Record<string, string> {
return additional.reduce((other: Record<string, string>, [_key, _value]): Record<string, string> => {
const key = dataAsString(_key);
const value = dataAsString(_value);
if (key && value) {
other[key] = value;
}
return other;
}, {});
}
function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
if (!identityOfOpt?.isSome) {
return { judgements: [] };
}
const { info, judgements } = identityOfOpt.unwrap();
const topDisplay = dataAsString(info.display);
return {
display: (superOf && dataAsString(superOf[1])) || topDisplay,
displayParent: superOf && topDisplay,
email: dataAsString(info.email),
image: dataAsString(info.image),
judgements,
legal: dataAsString(info.legal),
other: extractOther(info.additional),
parent: superOf && superOf[0],
pgp: info.pgpFingerprint.unwrapOr(UNDEF_HEX).toHex(),
riot: dataAsString(info.riot),
twitter: dataAsString(info.twitter),
web: dataAsString(info.web)
};
}
function getParent (api: ApiInterfaceRx, identityOfOpt: Option<Registration> | undefined, superOfOpt: Option<ITuple<[AccountId, Data]>> | undefined): Observable<[Option<Registration> | undefined, [AccountId, Data] | undefined]> {
if (identityOfOpt?.isSome) {
// this identity has something set
return of([identityOfOpt, undefined]);
} else if (superOfOpt?.isSome) {
const superOf = superOfOpt.unwrap();
// we have a super
return combineLatest([
api.query.identity.identityOf<Option<Registration>>(superOf[0]),
of(superOf)
]);
}
// nothing of value returned
return of([undefined, undefined]);
}
function getBase (api: ApiInterfaceRx, accountId?: AccountId | Uint8Array | string): Observable<[Option<Registration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]> {
return accountId && api.query.identity?.identityOf
? api.queryMulti<[Option<Registration>, Option<ITuple<[AccountId, Data]>>]>([
[api.query.identity.identityOf, accountId],
[api.query.identity.superOf, accountId]
])
: of([undefined, undefined]);
}
/**
* @name identity
* @description Returns identity info for an account
*/
export function identity (instanceId: string, api: ApiInterfaceRx): (accountId?: AccountId | Uint8Array | string) => Observable<DeriveAccountRegistration> {
return memo(instanceId, (accountId?: AccountId | Uint8Array | string): Observable<DeriveAccountRegistration> =>
getBase(api, accountId).pipe(
switchMap(([identityOfOpt, superOfOpt]) => getParent(api, identityOfOpt, superOfOpt)),
map(([identityOfOpt, superOf]) => extractIdentity(identityOfOpt, superOf))
)
);
}
export function hasIdentity (instanceId: string, api: ApiInterfaceRx): (accountId: AccountId | Uint8Array | string) => Observable<DeriveHasIdentity> {
return memo(instanceId, (accountId: AccountId | Uint8Array | string): Observable<DeriveHasIdentity> =>
api.derive.accounts.hasIdentityMulti([accountId]).pipe(
map(([first]) => first)
)
);
}
export function hasIdentityMulti (instanceId: string, api: ApiInterfaceRx): (accountIds: (AccountId | Uint8Array | string)[]) => Observable<DeriveHasIdentity[]> {
return memo(instanceId, (accountIds: (AccountId | Uint8Array | string)[]): Observable<DeriveHasIdentity[]> =>
api.query.identity?.identityOf
? combineLatest([
api.query.identity.identityOf.multi<Option<Registration>>(accountIds),
api.query.identity.superOf.multi<Option<ITuple<[AccountId, Data]>>>(accountIds)
]).pipe(
map(([identities, supers]) =>
identities.map((identityOfOpt, index): DeriveHasIdentity => {
const superOfOpt = supers[index];
const parentId = superOfOpt && superOfOpt.isSome
? superOfOpt.unwrap()[0].toString()
: undefined;
let display: string | undefined;
if (identityOfOpt && identityOfOpt.isSome) {
const value = dataAsString(identityOfOpt.unwrap().info.display);
if (value && !isHex(value)) {
display = value;
}
}
return { display, hasIdentity: !!(display || parentId), parentId };
})
)
)
: of(accountIds.map(() => ({ hasIdentity: false })))
);
}
+2 -1
View File
@@ -1,10 +1,11 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './accountId';
export * from './flags';
export * from './idAndIndex';
export * from './idToIndex';
export * from './identity';
export * from './indexToId';
export * from './indexes';
export * from './info';
+13 -34
View File
@@ -1,40 +1,17 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable, of } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
import { Option, Vec } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
function queryEnumSet (api: ApiInterfaceRx, _accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
const accountIndex = _accountIndex instanceof api.registry.createClass('AccountIndex')
? _accountIndex
: api.registry.createType('AccountIndex', _accountIndex);
return api.query.indices.enumSet<Vec<AccountId>>(accountIndex.div(ENUMSET_SIZE)).pipe(
startWith([]),
map((accounts): AccountId | undefined =>
(accounts || [])[accountIndex.mod(ENUMSET_SIZE).toNumber()]
)
);
}
// current
function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
return api.query.indices.accounts<Option<ITuple<[AccountId, BalanceOf]>>>(accountIndex).pipe(
map((optResult): AccountId | undefined =>
optResult.unwrapOr([])[0]
)
);
}
/**
* @name indexToId
* @param {( AccountIndex | string )} accountIndex - An accounts index in different formats.
@@ -51,9 +28,11 @@ function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Obser
export function indexToId (instanceId: string, api: ApiInterfaceRx): (accountIndex: AccountIndex | string) => Observable<AccountId | undefined> {
return memo(instanceId, (accountIndex: AccountIndex | string): Observable<AccountId | undefined> =>
api.query.indices
? isFunction(api.query.indices.accounts)
? query(api, accountIndex)
: queryEnumSet(api, accountIndex)
? api.query.indices.accounts<Option<ITuple<[AccountId, BalanceOf]>>>(accountIndex).pipe(
map((optResult): AccountId | undefined =>
optResult.unwrapOr([])[0]
)
)
: of(undefined)
);
}
+8 -40
View File
@@ -1,53 +1,23 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, AccountIndex } from '@polkadot/types/interfaces';
import { AccountIndexes } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { AccountIndexes } from '../types';
import { Observable, of } from 'rxjs';
import { map, startWith, switchMap } from 'rxjs/operators';
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
import { Vec } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { of } from '@polkadot/x-rxjs';
import { map, startWith } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
const enumsetSize = ENUMSET_SIZE.toNumber();
let indicesCache: AccountIndexes | null = null;
function queryEnumSet (api: ApiInterfaceRx): Observable<AccountIndexes> {
return api.query.indices.nextEnumSet<AccountIndex>().pipe(
// use the nextEnumSet (which is a counter of the number of sets) to construct
// a range of values to query [0, 1, 2, ...]. Retrieve the full enum set for the
// specific index - each query can return up to ENUMSET_SIZE (64) records, each
// containing an AccountId
switchMap((next: AccountIndex): Observable<Vec<AccountId>[]> =>
api.query.indices.enumSet.multi<Vec<AccountId>>([...Array(next.toNumber() + 1).keys()])
),
map((all: AccountId[][]): AccountIndexes =>
all.reduce((indexes: AccountIndexes, list, outerIndex): AccountIndexes => {
(list || []).forEach((accountId, innerIndex): void => {
// re-create the index based on position 0 is [0][0] and likewise
// 64 (0..63 in first) is [1][0] (the first index value in set 2)
const index = (outerIndex * enumsetSize) + innerIndex;
indexes[accountId.toString()] = api.registry.createType('AccountIndex', index);
});
return indexes;
}, {})
)
);
}
function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
return api.query.indices.accounts.entries().pipe(
map((entries): AccountIndexes =>
entries.reduce((indexes: AccountIndexes, [key, idOpt]): AccountIndexes => {
if (idOpt.isSome) {
indexes[idOpt.unwrap()[0].toString()] = key.args[0] as AccountIndex;
indexes[idOpt.unwrap()[0].toString()] = key.args[0];
}
return indexes;
@@ -77,9 +47,7 @@ export function indexes (instanceId: string, api: ApiInterfaceRx): () => Observa
? of(indicesCache)
: (
api.query.indices
? isFunction(api.query.indices.accounts)
? queryAccounts(api).pipe(startWith({}))
: queryEnumSet(api).pipe(startWith({}))
? queryAccounts(api).pipe(startWith({}))
: of({} as AccountIndexes)
).pipe(
map((indices): AccountIndexes => {
+12 -90
View File
@@ -1,28 +1,19 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, AccountIndex, Address, Balance, IdentityInfoAdditional, Registration } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option, u32 } from '@polkadot/types';
import type { AccountId, AccountIndex, Address, Balance } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveAccountInfo, DeriveAccountRegistration } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Bytes, Data, Option, u32 } from '@polkadot/types';
import { u8aToString } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
const UNDEF_HEX = { toHex: () => undefined };
function dataAsString (data: Data): string | undefined {
return data.isRaw
? u8aToString(data.asRaw.toU8a(true))
: data.isNone
? undefined
: data.toHex();
}
function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<string | undefined> {
return ((
accountId && api.query.nicks?.nameOf
@@ -37,86 +28,17 @@ function retrieveNick (api: ApiInterfaceRx, accountId?: AccountId): Observable<s
);
}
function extractOther (additional: IdentityInfoAdditional[]): Record<string, string> {
return additional.reduce((other: Record<string, string>, [_key, _value]): Record<string, string> => {
const key = dataAsString(_key);
const value = dataAsString(_value);
if (key && value) {
other[key] = value;
}
return other;
}, {});
}
function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
if (!identityOfOpt?.isSome) {
return { judgements: [] };
}
const { info, judgements } = identityOfOpt.unwrap();
const topDisplay = dataAsString(info.display);
return {
display: (superOf && dataAsString(superOf[1])) || topDisplay,
displayParent: superOf && topDisplay,
email: dataAsString(info.email),
image: dataAsString(info.image),
judgements,
legal: dataAsString(info.legal),
other: extractOther(info.additional),
parent: superOf && superOf[0],
pgp: info.pgpFingerprint.unwrapOr(UNDEF_HEX).toHex(),
riot: dataAsString(info.riot),
twitter: dataAsString(info.twitter),
web: dataAsString(info.web)
};
}
function retrieveIdentity (api: ApiInterfaceRx, accountId?: AccountId): Observable<DeriveAccountRegistration> {
return ((
accountId && api.query.identity?.identityOf
? api.queryMulti([
[api.query.identity.identityOf, accountId],
[api.query.identity.superOf, accountId]
])
: of([undefined, undefined])
) as Observable<[Option<Registration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]>).pipe(
switchMap(([identityOfOpt, superOfOpt]): Observable<[Option<Registration> | undefined, [AccountId, Data] | undefined]> => {
if (identityOfOpt?.isSome) {
// this identity has something set
return of([identityOfOpt, undefined]);
} else if (superOfOpt?.isSome) {
const superOf = superOfOpt.unwrap();
// we have a super
return combineLatest([
api.query.identity.identityOf<Option<Registration>>(superOf[0]),
of(superOf)
]);
}
// nothing of value returned
return of([undefined, undefined]);
}),
map(([identityOfOpt, superOf]): DeriveAccountRegistration =>
extractIdentity(identityOfOpt, superOf)
)
);
}
/**
* @name info
* @description Returns aux. info with regards to an account, current that includes the accountId, accountIndex and nickname
*/
export function info (instanceId: string, api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | string | null) => Observable<DeriveAccountInfo> {
return memo(instanceId, (address?: AccountIndex | AccountId | Address | string | null): Observable<DeriveAccountInfo> =>
export function info (instanceId: string, api: ApiInterfaceRx): (address?: AccountIndex | AccountId | Address | Uint8Array | string | null) => Observable<DeriveAccountInfo> {
return memo(instanceId, (address?: AccountIndex | AccountId | Address | Uint8Array | string | null): Observable<DeriveAccountInfo> =>
api.derive.accounts.idAndIndex(address).pipe(
switchMap(([accountId, accountIndex]): Observable<[Partial<DeriveAccountInfo>, DeriveAccountRegistration, string?]> =>
combineLatest([
of({ accountId, accountIndex }),
retrieveIdentity(api, accountId),
api.derive.accounts.identity(accountId),
retrieveNick(api, accountId)
])
),
+8 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, RegistrationJudgement } from '@polkadot/types/interfaces';
import type { AccountId, AccountIndex, RegistrationJudgement } from '@polkadot/types/interfaces';
export type AccountIdAndIndex = [AccountId?, AccountIndex?];
@@ -35,3 +35,9 @@ export interface DeriveAccountInfo {
identity: DeriveAccountRegistration;
nickname?: string;
}
export interface DeriveHasIdentity {
display?: string;
hasIdentity: boolean;
parentId?: string;
}
+58 -30
View File
@@ -1,23 +1,24 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountData, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveBalancesAccount } from '../types';
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { isFunction } from '@polkadot/util';
import { assert, isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
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 {
accountId,
accountNonce,
freeBalance,
frozenFee,
frozenMisc,
@@ -26,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
function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
return api.queryMulti<[Balance, Balance, Index]>([
@@ -33,21 +47,25 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
[api.query.balances.reservedBalance, accountId],
[api.query.system.accountNonce, accountId]
]).pipe(
map(([freeBalance, reservedBalance, accountNonce]): Result =>
[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance'), accountNonce]
)
map(([freeBalance, reservedBalance, accountNonce]): Result => [
accountNonce,
[[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance')]]
])
);
}
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
return api.queryMulti<[AccountData, Index]>([
[api.query.balances.account, accountId],
[api.query.system.accountNonce, accountId]
]).pipe(
map(([{ feeFrozen, free, miscFrozen, reserved }, accountNonce]): Result =>
[free, reserved, feeFrozen, miscFrozen, accountNonce]
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
const balances = modules.map((m): QueryableStorageMultiArg<'rxjs'> => [api.query[m].account, accountId]);
const extract = (data: AccountData[]) =>
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
return isFunction(api.query.system.account)
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
)
);
: api.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> {
@@ -59,7 +77,7 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
: (infoOrTuple as [Index, AccountData])[1];
const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
return [free, reserved, feeFrozen, miscFrozen, accountNonce];
return [accountNonce, [[free, reserved, feeFrozen, miscFrozen]]];
})
);
}
@@ -80,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> {
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
api.derive.accounts.accountId(address).pipe(
switchMap((accountId): Observable<[AccountId, Result]> =>
(accountId
? combineLatest([
of(accountId),
isFunction(api.query.system.account)
? queryCurrent(api, accountId)
: isFunction(api.query.balances.account)
? queryBalancesAccount(api, accountId)
: queryBalancesFree(api, accountId)
balanceInstances
? queryBalancesAccount(api, accountId, balanceInstances)
: isFunction(api.query.system.account)
? queryCurrent(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))
+61 -41
View File
@@ -1,19 +1,23 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
import { DeriveBalancesAccount, DeriveBalancesAll } from '../types';
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
import BN from 'bn.js';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option, Vec } from '@polkadot/types';
import { bnMax, isFunction } from '@polkadot/util';
import { bnMax } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
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];
interface AllLocked {
@@ -48,8 +52,21 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
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 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,
// - offset = balance locked at startingBlock
// - perBlock is the unlock amount
@@ -57,29 +74,21 @@ function calcBalances (api: ApiInterfaceRx, [{ accountId, accountNonce, freeBala
const isStarted = bestNumber.gt(startingBlock);
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
const isVesting = isStarted && !vestingLocked.isZero();
const vestedClaimable = api.registry.createType('Balance', isVesting ? vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), freeBalance.sub(lockedBalance)));
const isVesting = isStarted && !shared.vestingLocked.isZero();
const vestedClaimable = api.registry.createType('Balance', isVesting ? shared.vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
return {
accountId,
accountNonce,
availableBalance,
freeBalance,
frozenFee,
frozenMisc,
...shared,
accountId: data.accountId,
accountNonce: data.accountNonce,
additional: allLocks.filter((_, index) => index !== 0).map((l, index) => calcShared(api, bestNumber, data.additional[index], l)),
isVesting,
lockedBalance,
lockedBreakdown,
reservedBalance,
vestedBalance,
vestedClaimable,
vestingEndBlock,
vestingLocked,
vestingPerBlock: perBlock,
vestingTotal,
votingBalance
vestingTotal
};
}
@@ -98,28 +107,37 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock });
}
return [vestingNew, locks];
return [vestingNew, [locks]];
})
);
}
// current (balances vesting)
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
// current (balances, vesting)
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 (
api.query.vesting?.vesting
? api.queryMulti<[Vec<BalanceLock>, Option<VestingInfo>]>([
[api.query.balances.locks, accountId],
[api.query.vesting.vesting, accountId]
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([
[api.query.vesting.vesting, accountId],
...lockQueries
])
: api.query.balances.locks(accountId).pipe(
map((locks): [Vec<BalanceLock>, Option<VestingInfo>] =>
[locks, api.registry.createType('Option<VestingInfo>')]
// TODO We need to check module instances here as well, not only the balances module
: lockQueries.length
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(lockQueries).pipe(
map((locks): [Option<VestingInfo>, ...BalanceLocks] =>
[api.registry.createType('Option<VestingInfo>'), ...locks]
)
)
)
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
).pipe(
map(([locks, optVesting]): ResultBalance =>
[optVesting.unwrapOr(null), locks]
)
map(([optVesting, ...locks]): ResultBalance => {
let offset = -1;
return [optVesting.unwrapOr(null), lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])];
})
);
}
@@ -139,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> {
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAll> =>
api.derive.balances.account(address).pipe(
switchMap((account): Observable<Result> =>
@@ -146,11 +166,11 @@ export function all (instanceId: string, api: ApiInterfaceRx): (address: Account
? combineLatest([
of(account),
api.derive.chain.bestNumber(),
isFunction(api.query.system.account) || isFunction(api.query.balances.account)
? queryCurrent(api, account.accountId)
api.query.system?.account || api.query.balances?.account
? queryCurrent(api, account.accountId, balanceInstances)
: 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))
+7 -6
View File
@@ -1,12 +1,13 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Balance } from '@polkadot/types/interfaces';
import { DeriveFees } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Balance } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveFees } from '../types';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { all } from './all';
@@ -1,11 +1,12 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import { DeriveBalancesAccount } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, AccountIndex, Address } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { memo } from '../util';
@@ -0,0 +1,161 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx, SubmittableExtrinsic } from '@polkadot/api/types';
import type { Bytes, Option, StorageKey } from '@polkadot/types';
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import type { Codec, InterfaceTypes } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import { Proposal } from '@polkadot/types/interfaces';
import { of } from '@polkadot/x-rxjs';
import { BountyFactory } from '../../test/bountyFactory';
import { BytesFactory } from '../../test/bytesFactory';
import { createApiWithAugmentations } from '../../test/helpers';
import { ProposalFactory } from '../../test/proposalFactory';
import { bounties } from '.';
const DEFAULT_PROPOSER = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM';
describe('bounties derive', () => {
let storageKey: (index: number) => StorageKey;
let defaultBounty: () => Bounty;
let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
let optionOf: <T extends Codec> (value: T)=> Option<T>;
let bountyIndex: (index: number) => BountyIndex;
let proposalIndex: (index: number) => ProposalIndex;
let bytes: (value: string) => Bytes;
let api: ApiPromise;
let createProposal: (method: SubmittableExtrinsic<'promise'>) => Proposal;
let defaultMockApi: ApiInterfaceRx;
beforeAll(() => {
api = createApiWithAugmentations();
({ bountyIndex, defaultBounty, emptyOption, optionOf, storageKey } = new BountyFactory(api));
({ 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 () {
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 () => {
const mockApi = {
...defaultMockApi,
query: {
...defaultMockApi.query,
treasury: {
bounties: {
keys: () => of([storageKey(0), storageKey(2), storageKey(3)]),
multi: () => of([optionOf(defaultBounty()), emptyOption('Bounty'), optionOf(defaultBounty())])
},
bountyCount: () => of(bountyIndex(3)),
bountyDescriptions: {
multi: () => of([
optionOf(bytes('make polkadot even better')),
optionOf(bytes('this will be totally ignored')),
emptyOption('Bytes')
])
}
}
}
} 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[1].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
expect(result[1].description).toEqual('');
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');
});
});
@@ -0,0 +1,61 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { DeriveBounties, DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import type { Bytes, Option } from '@polkadot/types';
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import { memo } from '@polkadot/api-derive/util';
import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { filterBountiesProposals } from './helpers/filterBountyProposals';
type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
function parseResult ([maybeBounties, maybeDescriptions, ids, bountyProposals]: Result): DeriveBounties {
const bounties: DeriveBounties = [];
maybeBounties.forEach((bounty, index) => {
if (bounty.isSome) {
bounties.push({
bounty: bounty.unwrap(),
description: maybeDescriptions[index].unwrapOrDefault().toUtf8(),
index: ids[index],
proposals: bountyProposals.filter((bountyProposal) => ids[index].eq(bountyProposal.proposal.args[0]))
});
}
});
return bounties;
}
export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveBounties> {
const bountyBase = api.query.bounties || api.query.treasury;
return memo(instanceId, (): Observable<DeriveBounties> =>
combineLatest([
bountyBase.bountyCount<BountyIndex>(),
api.query.council ? api.query.council.proposalCount<ProposalIndex>() : of(0)
]).pipe(
switchMap(() =>
combineLatest([
bountyBase.bounties.keys<[BountyIndex]>(),
api.derive.council ? api.derive.council.proposals() : of([])
])
),
switchMap(([keys, proposals]): Observable<Result> => {
const ids = keys.map(({ args: [id] }) => id);
return combineLatest([
bountyBase.bounties.multi<Option<Bounty>>(ids),
bountyBase.bountyDescriptions.multi<Option<Bytes>>(ids),
of(ids),
of(filterBountiesProposals(api, proposals))
]);
}),
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)));
}
@@ -0,0 +1,4 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './bounties';
+5 -5
View File
@@ -1,11 +1,11 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber } from '@polkadot/types/interfaces';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BlockNumber } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,11 +1,11 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber } from '@polkadot/types/interfaces';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BlockNumber } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,11 +1,12 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber } from '@polkadot/types/interfaces';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { BlockNumber } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable, combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { combineLatest } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
+8 -6
View File
@@ -1,10 +1,11 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { catchError, map } from '@polkadot/x-rxjs/operators';
import { SignedBlockExtended } from '../type';
import { memo } from '../util';
@@ -26,12 +27,13 @@ export function getBlock (instanceId: string, api: ApiInterfaceRx): (hash: Uint8
return memo(instanceId, (hash: Uint8Array | string): Observable<SignedBlockExtended | undefined> =>
combineLatest([
api.rpc.chain.getBlock(hash),
api.query.system.events.at(hash),
api.query.session
? api.query.session.validators.at(hash)
: of([])
]).pipe(
map(([signedBlock, validators]): SignedBlockExtended =>
new SignedBlockExtended(api.registry, signedBlock, validators)
map(([signedBlock, events, validators]): SignedBlockExtended =>
new SignedBlockExtended(api.registry, signedBlock, events, validators)
),
catchError((): Observable<undefined> =>
// where rpc.chain.getHeader throws, we will land here - it can happen that
+5 -4
View File
@@ -1,10 +1,11 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { catchError, map } from '@polkadot/x-rxjs/operators';
import { HeaderExtended } from '../type';
import { memo } from '../util';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './bestNumber';
@@ -1,32 +1,35 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { EventRecord, Hash, SignedBlock } from '@polkadot/types/interfaces';
import { FullNewBlock } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, EventRecord, SignedBlock } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { SignedBlockExtended } from '../type';
import { memo } from '../util';
/**
* @name subscribeNewBlocks
* @returns The latest block & events for that block
*/
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<FullNewBlock> {
return memo(instanceId, (): Observable<FullNewBlock> =>
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<SignedBlockExtended> {
return memo(instanceId, (): Observable<SignedBlockExtended> =>
api.derive.chain.subscribeNewHeads().pipe(
switchMap((header): Observable<[Hash, EventRecord[], SignedBlock]> => {
switchMap((header): Observable<[SignedBlock, EventRecord[], AccountId[] | undefined]> => {
const blockHash = header.hash;
return combineLatest(
of(blockHash),
api.rpc.chain.getBlock(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)
)
)
);
}
@@ -1,10 +1,11 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable, combineLatest, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { HeaderExtended } from '../type';
import { memo } from '../util';
-12
View File
@@ -1,12 +0,0 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { Block, BlockNumber, EventRecord, Hash, Justification } from '@polkadot/types/interfaces';
export interface FullNewBlock {
block: Block;
blockHash: Hash;
blockNumber: BlockNumber;
events: EventRecord[];
justification: Justification;
}
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './proposals';
@@ -1,14 +1,15 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
import { DeriveCollectiveProposal } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveCollectiveProposal } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { catchError, map, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { catchError, map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
+7 -5
View File
@@ -1,12 +1,14 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveContractFees } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveContractFees } from '../types';
import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './fees';
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './proposals';
+5 -5
View File
@@ -1,11 +1,11 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Hash } from '@polkadot/types/interfaces';
import { DeriveCollectiveProposal } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveCollectiveProposal } from '../types';
import { Observable } from 'rxjs';
import { proposal as collectiveProposal, proposals as collectiveProposals } from '../collective';
import { memo } from '../util';
+2 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance } from '@polkadot/types/interfaces';
import type { AccountId, Balance } from '@polkadot/types/interfaces';
export interface DeriveCouncilVote {
stake: Balance;
+27 -16
View File
@@ -1,29 +1,37 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Vec } from '@polkadot/types';
import type { AccountId, Balance, Voter } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
import { Observable, combineLatest } from 'rxjs';
import { map } from 'rxjs/operators';
import { Vec } from '@polkadot/types';
import { combineLatest } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
// Voter is current tuple is 2.x-era
type VoteEntry = Voter | ITuple<[Balance, Vec<AccountId>]>;
function isVoter (value: VoteEntry): value is Voter {
return !Array.isArray(value);
}
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance>().pipe(
return (api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
map((entries) =>
entries.map(([key, stake]) => [key.args[0] as AccountId, stake])
entries.map(([{ args: [accountId] }, stake]) => [accountId, stake])
)
);
}
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>>().pipe(
return (api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
map((entries) =>
entries.map(([key, votes]) => [key.args[0] as AccountId, votes])
entries.map(([{ args: [accountId] }, votes]) => [accountId, votes])
)
);
}
@@ -55,11 +63,14 @@ function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
const elections = (api.query.electionsPhragmen || api.query.elections);
return elections.voting.entries<ITuple<[Balance, Vec<AccountId>]>>().pipe(
return elections.voting.entries<VoteEntry, [AccountId]>().pipe(
map((entries): DeriveCouncilVotes =>
entries.map(([key, [stake, votes]]): [AccountId, DeriveCouncilVote] =>
[key.args[0] as AccountId, { stake, votes }]
)
entries.map(([{ args: [accountId] }, value]): [AccountId, DeriveCouncilVote] => [
accountId,
isVoter(value)
? { stake: value.stake, votes: value.votes }
: { stake: value[0], votes: value[1] }
])
)
);
}
+7 -6
View File
@@ -1,12 +1,13 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveCouncilVote } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveCouncilVote } from '../types';
import { map } from '@polkadot/x-rxjs/operators';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { memo } from '../util';
export function votesOf (instanceId: string, api: ApiInterfaceRx): (accountId: string | Uint8Array | AccountId) => Observable<DeriveCouncilVote> {
@@ -1,15 +1,16 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveDispatch, DeriveProposalImage } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, u64, Vec } from '@polkadot/types';
import type { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveDispatch, DeriveProposalImage } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option, Vec, u64 } from '@polkadot/types';
import { isFunction, stringToHex } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -50,7 +51,7 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], Opti
api.query.scheduler.agenda.keys()
),
switchMap((keys) => {
const blockNumbers = keys.map((key) => key.args[0] as BlockNumber);
const blockNumbers = keys.map(({ args: [blockNumber] }) => blockNumber);
return combineLatest([
of(blockNumbers),
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './dispatchQueue';
+9 -7
View File
@@ -1,15 +1,17 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveDemocracyLock } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveDemocracyLock } from '../types';
import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
import { BN_ZERO, isUndefined } from '@polkadot/util';
import { of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,14 +1,15 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { Hash, VoteThreshold } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveProposalExternal } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { Hash, VoteThreshold } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveProposalExternal } from '../types';
import { Observable, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option } from '@polkadot/types';
import { of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,14 +1,14 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveProposalImage } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveProposalImage } from '../types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Bytes, Option } from '@polkadot/types';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
import { parseImage } from './util';
@@ -1,14 +1,14 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveProposalImage } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveProposalImage } from '../types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { Bytes, Option } from '@polkadot/types';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
import { parseImage } from './util';
@@ -1,15 +1,16 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, Hash, PropIndex } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveProposalImage, DeriveProposal } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, Balance, Hash, PropIndex } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveProposal, DeriveProposalImage } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Option, Vec } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,12 +1,14 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ReferendumIndex } from '@polkadot/types/interfaces';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { ReferendumIndex } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import BN from 'bn.js';
import { Observable, of } from 'rxjs';
import { map } from 'rxjs/operators';
import { of } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,11 +1,12 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveReferendumExt } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveReferendumExt } from '../types';
import { Observable, combineLatest, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,11 +1,12 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveReferendum } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveReferendum } from '../types';
import { Observable, of } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { of } from '@polkadot/x-rxjs';
import { switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,12 +1,12 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { ReferendumInfo, ReferendumInfoFinished } from '@polkadot/types/interfaces';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { ReferendumInfo, ReferendumInfoFinished } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { Observable } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option } from '@polkadot/types';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
@@ -1,15 +1,17 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, ReferendumInfo, ReferendumInfoTo239, Vote, Voting, VotingDirectVote, VotingDelegating } from '@polkadot/types/interfaces';
import { DeriveBalancesAccount, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, ReferendumInfo, ReferendumInfoTo239, Vote, Voting, VotingDelegating, VotingDirectVote } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveBalancesAccount, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes } from '../types';
import BN from 'bn.js';
import { Observable, of, combineLatest } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { Option, Vec } from '@polkadot/types';
import { isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
import { calcVotes, getStatus, parseImage } from './util';
@@ -65,9 +67,9 @@ function extractVotes (mapped: [AccountId, Voting][], referendumId: BN): DeriveR
}
function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votingOf.entries<Voting>().pipe(
return api.query.democracy.votingOf.entries<Voting, [AccountId]>().pipe(
map((allVoting): DeriveReferendumVote[] => {
const mapped = allVoting.map(([key, voting]): [AccountId, Voting] => [key.args[0] as AccountId, voting]);
const mapped = allVoting.map(([{ args: [accountId] }, voting]): [AccountId, Voting] => [accountId, voting]);
const votes = extractVotes(mapped, referendumId);
const delegations = mapped
.filter(([, voting]) => voting.isDelegating)
@@ -1,12 +1,13 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Observable } from '@polkadot/x-rxjs';
import BN from 'bn.js';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { bnSqrt } from '@polkadot/util';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
+3 -4
View File
@@ -1,10 +1,9 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import { AccountId, Balance, BlockNumber, Hash, Proposal, PropIndex, ReferendumInfoTo239, ReferendumStatus, Vote, ReferendumIndex, VoteThreshold } from '@polkadot/types/interfaces';
import { Vec } from '@polkadot/types';
import type { Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash, PropIndex, Proposal, ReferendumIndex, ReferendumInfoTo239, ReferendumStatus, Vote, VoteThreshold } from '@polkadot/types/interfaces';
export interface DeriveDemocracyLock {
balance: Balance;
+7 -6
View File
@@ -1,13 +1,14 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { AccountId, Balance, BlockNumber, PreimageStatus, Proposal, ReferendumInfo, ReferendumInfoTo239, ReferendumStatus, Tally, VoteThreshold } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveProposalImage, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes, DeriveReferendumVoteState } from '../types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, PreimageStatus, Proposal, ReferendumInfo, ReferendumInfoTo239, ReferendumStatus, Tally, VoteThreshold } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveProposalImage, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes, DeriveReferendumVoteState } from '../types';
import BN from 'bn.js';
import { Bytes, Option } from '@polkadot/types';
import { bnSqrt } from '@polkadot/util';
type PreimageInfo = [Bytes, AccountId, Balance, BlockNumber];
+1 -1
View File
@@ -1,4 +1,4 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
export * from './info';
+25 -12
View File
@@ -1,25 +1,38 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces';
import { ITuple } from '@polkadot/types/types';
import { DeriveElectionsInfo } from './types';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { u32, Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, SeatHolder } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Observable } from '@polkadot/x-rxjs';
import type { DeriveElectionsInfo } from './types';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { ApiInterfaceRx } from '@polkadot/api/types';
import { Vec, u32 } from '@polkadot/types';
import { map } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
function sortAccounts ([, balanceA]: ITuple<[AccountId, Balance]>, [, balanceB]: ITuple<[AccountId, Balance]>): number {
// SeatHolder is current tuple is 2.x-era Substrate
type Member = SeatHolder | ITuple<[AccountId, Balance]>;
function isSeatHolder (value: Member): value is SeatHolder {
return !Array.isArray(value);
}
function getAccountTuple (value: Member): [AccountId, Balance] {
return isSeatHolder(value)
? [value.who, value.stake]
: value;
}
function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [AccountId, Balance]): number {
return balanceB.cmp(balanceA);
}
function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
const section = api.query.electionsPhragmen ? 'electionsPhragmen' : 'elections';
return api.queryMulti<[Vec<AccountId>, Vec<AccountId>, Vec<ITuple<[AccountId, Balance]>>, Vec<ITuple<[AccountId, Balance]>>]>([
return api.queryMulti<[Vec<AccountId>, Vec<AccountId>, Vec<Member>, Vec<Member>]>([
api.query.council.members,
api.query[section].candidates,
api.query[section].members,
@@ -32,9 +45,9 @@ function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
desiredRunnersUp: api.consts[section].desiredRunnersUp as u32,
desiredSeats: api.consts[section].desiredMembers as u32,
members: members.length
? members.sort(sortAccounts)
? members.map(getAccountTuple).sort(sortAccounts)
: councilMembers.map((accountId): [AccountId, Balance] => [accountId, api.registry.createType('Balance')]),
runnersUp: runnersUp.sort(sortAccounts),
runnersUp: runnersUp.map(getAccountTuple).sort(sortAccounts),
termDuration: api.consts[section].termDuration as BlockNumber,
votingBond: api.consts[section].votingBond as Balance
}))
+3 -4
View File
@@ -1,9 +1,8 @@
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { AccountId, Balance, BlockNumber, SetIndex, VoteIndex } from '@polkadot/types/interfaces';
import { u32 } from '@polkadot/types';
import type { u32 } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, SetIndex, VoteIndex } from '@polkadot/types/interfaces';
export interface DeriveElectionsInfo {
candidates: AccountId[];

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