Compare commits

...
200 Commits
Author SHA1 Message Date
Github Actions 8475130a22 [CI Skip] release/stable 6.2.1
skip-checks: true
2021-10-04 08:33:37 +00:00
Jaco a7e824ff09 6.2.1 (#4016)
* 6.2.1

* CHANGELOG

* Bump static metadata

* CHANGELOG
2021-10-04 11:17:55 +03:00
Alexander Popiak 9d5fb2bf72 Add asset id in signing (#4009)
* add assetId to SignerOptions

* pull assetId into extrinsic signing

* set assetId to optional AnyNumber throughout

* add logging of extrinsic options

* add assetId to _injectSignature & add getters

* re-add import

* longer doc comments
2021-10-04 10:02:28 +03:00
Github Actions 2cf0e306dd [CI Skip] release/beta 6.1.3-3
skip-checks: true
2021-10-01 10:17:38 +00:00
Jaco 72d5330727 Use lookup types in derives (#4012)
* Use lookup types in derives

* additional

* society
2021-10-01 13:02:24 +03:00
Github Actions 1c3bdda08f [CI Skip] release/beta 6.1.3-2
skip-checks: true
2021-10-01 08:51:17 +00:00
Jaco 668ad3dfe5 Handle plain multi queries diguised as map-form (#4011) 2021-10-01 11:29:12 +03:00
Github Actions 651afaeb9a [CI Skip] release/beta 6.1.3-1
skip-checks: true
2021-09-30 06:54:52 +00:00
Jaco 5036aa9ef4 Better error messages for misformed queries (#4007)
* Better error messages for misformed queries

* Cater for raw function (no meta)
2021-09-30 09:39:13 +03:00
Github Actions 3598cc25f4 [CI Skip] release/beta 6.1.3-0
skip-checks: true
2021-09-29 12:28:47 +00:00
Jaco 987a2ec2df Adjust multi to infer return types (#4002)
* Adjust multi to infer return types

* some linting

* Additional

* Dedupe
2021-09-29 14:07:29 +02:00
Github Actions 389c4c5255 [CI Skip] release/stable 6.1.2
skip-checks: true
2021-09-29 08:08:58 +00:00
Jaco 493287cedf 6.1.2 (#4001) 2021-09-29 09:50:25 +02:00
Github Actions fe52dc8006 [CI Skip] release/beta 6.1.2-3
skip-checks: true
2021-09-29 06:08:50 +00:00
Jaco f26008ab95 Fix .at queries/decoration for pre-V13 metadata (#4000)
* Fix `.at` queries/decoration for pre-V13 metadata

* fields fix (or rather... protection against upcoming change)
2021-09-29 07:46:13 +02:00
Github Actions 0952720237 [CI Skip] release/beta 6.1.2-2
skip-checks: true
2021-09-27 11:20:10 +00:00
Jaco 04058fe95e Bump metadata (#3996)
* Bump metadata

* Ensure WrapperOquaque is applied

* Use field for mapping

* Handle WrapperOpaque

* Adjust
2021-09-27 13:02:18 +02:00
Github Actions eb96371e59 [CI Skip] release/beta 6.1.2-1
skip-checks: true
2021-09-27 09:20:29 +00:00
Jaco a313fe13e7 Add support for WrapperOpaque (#3997)
* Add support for WrapperOpaque

* Dedupe dual params

* Adjust case

* Re-adjust to Vec
2021-09-27 11:02:37 +02:00
Github Actions 243c263485 [CI Skip] release/beta 6.1.2-0
skip-checks: true
2021-09-27 06:31:40 +00:00
Jaco 311d8b792c Additional types for bridges (#3995) 2021-09-27 08:08:42 +02:00
Github Actions 878f631745 [CI Skip] release/stable 6.1.1
skip-checks: true
2021-09-27 05:54:41 +00:00
Jaco d7753839a2 6.1.1 (#3994)
* 6.1.1

* bumps
2021-09-27 07:36:47 +02:00
Github Actions fc74d88bbb [CI Skip] release/beta 6.0.6-4
skip-checks: true
2021-09-24 08:24:35 +00:00
HackFisher 47bbeee14b fix OutboundLaneData types (#3992) 2021-09-24 10:05:56 +02:00
Github Actions ba01620ba1 [CI Skip] release/beta 6.0.6-3
skip-checks: true
2021-09-23 09:30:55 +00:00
Jaco 6e66387a8d CHANGELOG (#3986) 2021-09-23 11:10:10 +02:00
Github Actions c58687b3c6 [CI Skip] release/beta 6.0.6-2
skip-checks: true
2021-09-22 09:22:01 +00:00
Jaco 2801088b0a Scale-info v0 -> v1 conversion (as needed by contracts) (#3987)
* Scale-info v0 -> v1 conversion (as needed by contracts)

* Renames

* V1 types same as v0 where applicable
2021-09-22 11:01:39 +02:00
Github Actions fc5af92a03 [CI Skip] release/beta 6.0.6-1
skip-checks: true
2021-09-22 04:07:20 +00:00
Furqan A 8f8bb2aa23 fix: fixed 404 to the docs from the api readme (#3985) 2021-09-22 06:48:18 +03:00
Github Actions 3f69b3fc73 [CI Skip] release/beta 6.0.6-0
skip-checks: true
2021-09-20 18:48:01 +00:00
Jaco 4ea170a83a Add childstate_getStorageEntries RPC (#3980)
* Add `childstate_getStorageEntries` RPC

* Remove extra ,
2021-09-20 20:33:30 +02:00
Github Actions 26649c429a [CI Skip] release/stable 6.0.5
skip-checks: true
2021-09-20 13:57:16 +00:00
Jaco 7c57778389 6.0.5 (#3977) 2021-09-20 15:38:54 +02:00
Github Actions dbb5d66de3 [CI Skip] release/stable 6.0.4
skip-checks: true
2021-09-20 09:10:12 +00:00
Jaco 6bc92a6d31 6.0.4 (#3975)
* 6.0.4

* Update CHANGELOG.md
2021-09-20 10:53:34 +02:00
Github Actions 6462327ea5 [CI Skip] release/beta 6.0.4-1
skip-checks: true
2021-09-20 06:17:50 +00:00
Jaco 3b4c2ac323 Extract getSiName conversion (#3974) 2021-09-20 07:56:33 +02:00
Github Actions d0ecfdafc1 [CI Skip] release/beta 6.0.4-0
skip-checks: true
2021-09-20 05:19:55 +00:00
Jaco 870bb8d3cb User api.at for all .at queries (#3973) 2021-09-20 06:59:35 +02:00
Github Actions 2fdb68d3bc [CI Skip] release/stable 6.0.3
skip-checks: true
2021-09-19 19:47:24 +00:00
Jaco 6ef410e375 Share TypeSpec between registry instances (#3972)
* Share TypeSpec between registry instances

* 6.0.3
2021-09-19 21:29:11 +02:00
Github Actions 962c741139 [CI Skip] release/beta 6.0.3-0
skip-checks: true
2021-09-19 06:38:13 +00:00
Jaco 598e69002a Formatting for metadata documentation (#3969)
* Formatting for metadata documentation

* unwrap
2021-09-19 08:18:13 +02:00
Github Actions f6e50f14b5 [CI Skip] release/stable 6.0.2
skip-checks: true
2021-09-18 09:12:35 +00:00
Jaco caec49a8dc Fix Substrate key generation (#3968)
* Fix Substrate key generation

* 6.0.2
2021-09-18 10:56:35 +02:00
Github Actions 0865b91f88 [CI Skip] release/stable 6.0.1
skip-checks: true
2021-09-18 05:26:37 +00:00
Jaco 6b45d5606d 6.0.1 (#3966) 2021-09-18 08:08:57 +03:00
Github Actions a22f66f044 [CI Skip] release/beta 5.9.2-10
skip-checks: true
2021-09-17 14:58:58 +00:00
Jaco 41fd67c24e Bump deps (#3965) 2021-09-17 16:40:46 +02:00
Github Actions 19e7d6dbdb [CI Skip] release/beta 5.9.2-9
skip-checks: true
2021-09-17 05:02:17 +00:00
Jaco 8fea8872fc Additional augmentation fixes (#3964)
* Additional augmentation fixes

* Update packages/api/src/checkTypes.manual.ts
2021-09-17 06:44:49 +02:00
Github Actions d17fc3b63b [CI Skip] release/beta 5.9.2-8
skip-checks: true
2021-09-17 04:18:28 +00:00
Jaco f8e012cf87 Ensure lookup augmentation is exported (#3963) 2021-09-17 05:59:59 +02:00
Github Actions 830af4a928 [CI Skip] release/beta 5.9.2-7
skip-checks: true
2021-09-16 05:14:13 +00:00
Jaco 345c536380 Fix v13 toCallsOnly path (#3957) 2021-09-16 06:57:13 +02:00
Github Actions d527a02d2f [CI Skip] release/beta 5.9.2-6
skip-checks: true
2021-09-15 17:05:19 +00:00
Jaco 22aafbdd4c Parsing for metadata v14 (#3759)
* Adjust

* Better, need a BoundedVec solution...

* Composites

* Storage optional types

* Better... not perfect

* v14 tests passing

* Always perform asLatest

* Keep portable registry seperate

* Cleanup derived types

* Cleanups

* Adjust

* Cleanups

* Pass wraps

* Rename types (PortableRegistry) -> lookup

* Back on-track...

* SiLookup strings

* Allow building

* unsafe create on registry

* createTypeUnsafe typing

* Adjust

* Fix bool check

* Remove WrappedConstructor

* Additional

* Additional cleanups

* On-demand even type creation

* Rework

* Adjust

* Revert createClass to master (with adjustments)

* Running through v14

* Registry from master

* Run against v14

* Adjust

* Adjust

* Adjust generation (non-complete)

* Adjust

* Definition from metadata (round 1)

* Some linting fixes

* v13

* Adjust

* Dedupe

* Some linting

* Additional linting (md generation, not all)

* md additional

* calls update

* Additional linting

* Cleanups

* Remove extra arg

* Remove unneeded assert

* Revert < 12 index adjustments

* Cleanups

* v13 compat types

* Some tests

* Registry revert

* Additional test fixes

* Adjust sorting

* Adjust tests with lookups

* CodeClimate cleanups

* Additional tests

* Compat with prev-generation args

* Error & events compat args

* Fix Error/Event metadata creation

* Fix lookup circular

* Registry types

* Adjust

* Adjust lookup generation

* Short-circuit full type (with lookupIndex)

* Defaults for type expansion

* Tuple with extra spaces removed

* Fill in generated types

* Checks

* Adjust generation

* Adjust tests

* Adjust

* Adjust type encoding

* Adjust

* Use registry for name generation

* Update v13 lookup generation

* Adjust looup with typeDef (optional)

* Format lookup definitions

* Start with TS interface generation

* Adjust

* Adjust

* Adjust

* Don't short-cisrcuit type evaluation

* Adjust

* Correct plain imports

* Adjust

* Don't remove already-set lookupName

* Bytes

* Cleanups

* Adjust with unused

* Embed non-named structs

* Enum without name throws error

* Case-sensitivity on path duplication

* s/lookupNameOrig/lookupNameRoot/

* Don't export Lookup* type interfaces

* Shortcut lookup

* Adjust

* Revert api/Decorate

* Adjust import name generation

* Don't clobber root lookups

* Root exports

* Remove duplicated fields creation

* Adjust less-important name parts

* Cleanups & imports

* Adjust with correct imports

* Storage optionality

* Rebuild, fix (some) tests

* Extract identity BitFlags

* Additional cleanups

* Adjust

* No IdentityFields override

* v13 for extrinsic test

* Dedupe getUniqTypes

* Simplify?

* Adjust

* Update sorting

* Adjust expansion

* Dedupe

* Strip generics, sub-part * matching

* Name matching

* Align

* Adjust set matching

* hex/json split

* naming

* v13 for extrinsic injection test

* Adjust test signature

* Dedupe tests

* Adjust

* Update import

* augment @polkadot/types/lookup

* Sort import names

* Handle BitSequence in PortableRegistry

* Use Kusama-dev v14 metadata

* Merge bitSequence support

* Polkadot/Substrate split

* Template formatting

* Hobbling along

* Adjust

* Recode subs

* Fix circular in dual fashion

* Adjust

* Also generate Substrate

* Exclude Substrate types from Polkadot

* Remove duplicate phantoms

* Cleanup lookup typegen

* Additional

* Extract names with params (as applicable)

* Ensure path is always available

* renames

* Metadata v14 only has combined Map

* v14 Map conversion de-duped

* Substrate Map conversion

* v13 tests

* Apply suggestions from code review

* Housekeeping

* v14 bump

* NMap -> Map (& others removed)

* Adjust generation

* Decorate linting

* Tuple & non-tuple types

* hashers check

* Condense

* Additional asTuple check

* Consistent pre-v14 Map handling

* Fix metadata tests

* Fix (some) tests

* Fix test expectations

* Fail create early

* Additional fixes

* Additional

* Movement

* Remove CodecArg

* Dump it

* Apply param expansion

* Remove only

* Allow no-args to StorageKey

* linting

* multi fixes

* Map adjustments

* Rebuild

* Rebuild

* Rebuild

* Latest

* Bump metadata

* Rewrite

* Fix lookup formatting

* Rebuild after merge

* Latest substrate v14

* Rebuild

* Rebuild (+ no enum trailing ,)

* trigger

* Fix JSON checks

* Remove unneeded check

* Bump Kusama/Polkadot

* Dedupe testUtil

* Metadata v14
2021-09-15 19:46:48 +03:00
Github Actions 88e5b26532 [CI Skip] release/beta 5.9.2-5
skip-checks: true
2021-09-15 09:46:16 +00:00
Jaco a203168126 Add RuntimeEnvironmentUpdated to Digest (#3955)
* Add RuntimeEnvironmentUpdated to Digest

* CHANGELOG
2021-09-15 11:34:13 +02:00
Github Actions 538544be84 [CI Skip] release/beta 5.9.2-4
skip-checks: true
2021-09-15 08:58:54 +00:00
Jaco 264bbf12c9 Bump static metadata (#3954) 2021-09-15 10:49:18 +02:00
Github Actions 5c144a8ae7 [CI Skip] release/beta 5.9.2-3
skip-checks: true
2021-09-15 03:43:12 +00:00
Ian He f28d648fac HttpProvider support clone() (#3949)
* HttpProvider support clone()

* fix lint
2021-09-15 06:31:35 +03:00
Github Actions f695cd0835 [CI Skip] release/beta 5.9.2-2
skip-checks: true
2021-09-14 12:00:39 +00:00
Jaco 44fdbdffd5 Bump deps (#3952) 2021-09-14 13:48:53 +02:00
Github Actions ee5ae49df7 [CI Skip] release/beta 5.9.2-1
skip-checks: true
2021-09-14 06:53:58 +00:00
Jaco febcabe109 Allow null values in bundles min/max (#3950)
* Allow null values in bundles min/max

* Adjust bundle type definition

* Backwards compat

* Lenient types
2021-09-14 08:43:56 +02:00
Github Actions 367efda128 [CI Skip] release/beta 5.9.2-0
skip-checks: true
2021-09-13 11:58:27 +00:00
Jaco 3583e758cd IdentityInfo <= Substrate 198 (#3947) 2021-09-13 13:46:49 +02:00
Github Actions d6fe638c5b [CI Skip] release/stable 5.9.1
skip-checks: true
2021-09-13 06:04:16 +00:00
Jaco ea72e3eb5b 5.9.1 (#3944) 2021-09-13 07:53:34 +02:00
Github Actions 45c0e16ecd [CI Skip] release/beta 5.8.4-4
skip-checks: true
2021-09-11 09:54:45 +00:00
Branan Riley 5b1823f7eb Add proxy type for Centrifuge (#3940) 2021-09-11 12:42:44 +03:00
Github Actions 6e998cce3d [CI Skip] release/beta 5.8.4-3
skip-checks: true
2021-09-11 07:45:40 +00:00
Jaco c46740e4e8 Adjust Xcm Error enum types (#3943) 2021-09-11 09:36:15 +02:00
Github Actions 4e5b98725b [CI Skip] release/beta 5.8.4-2
skip-checks: true
2021-09-08 06:18:18 +00:00
Jaco fca973cd53 Enhance type narrow checks (#3939) 2021-09-08 08:07:07 +02:00
Github Actions d1c9a507d9 [CI Skip] release/beta 5.8.4-1
skip-checks: true
2021-09-07 07:54:42 +00:00
Jaco 2cfd2f4d20 DisputeState types (#3937) 2021-09-07 09:43:52 +02:00
Github Actions d3b90c068f [CI Skip] release/beta 5.8.4-0
skip-checks: true
2021-09-07 07:27:46 +00:00
Jaco 3127c00d05 Polkadot 9090 upgrade (#3936) 2021-09-07 09:16:05 +02:00
Github Actions 3cdf3065d7 [CI Skip] release/stable 5.8.3
skip-checks: true
2021-09-06 12:43:42 +00:00
Jaco 973b1fcffb 5.8.3 (#3935) 2021-09-06 14:32:02 +02:00
Github Actions 4195833d6f [CI Skip] release/stable 5.8.2
skip-checks: true
2021-09-06 09:21:36 +00:00
Jaco 8f4e62c278 5.8.2 (#3934) 2021-09-06 11:10:32 +02:00
Jaco 2c294af116 Kusama MultiLocation to v0 (#3933) 2021-09-06 10:57:53 +02:00
Github Actions 0f1f3b88b2 [CI Skip] release/beta 5.8.2-0
skip-checks: true
2021-09-06 08:52:15 +00:00
Alexander Popiak 56b7697dda Version Junction and MultiLocation Types (#3932)
* version Junction and MultiLocation types

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

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

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

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

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

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

* a-e

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

* Handle Range in PortableRegistry

* Cleanups

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

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

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

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

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

* Result/Range

* INumber as Range inner

* Update

* .with on Range

* Basic range decoding

* With

* RangeName

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

* Bump dev

* Update CHANGELOG

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

* Simplify

* Correct __IntType

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

* Lint

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

* Santize fixed vecs

* __Tokenize

* Shortcut ending sequences

* Update tests & checks

* greedy matching

* Additional linting

* s/extends Codec/extends Codec | undefined/

* Adjust

* Shortcut interfacetypes

* Cleanups

* set & enum

* Adjust getTypeClass fallback set

* CC

* Adjust

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

* Adjust

* Template struct extraction

* Adjust

* Additional

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

* CHANGELOG

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

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

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

* Additional detect overrides

* additional

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

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

* type as 'OtherType' cast removal

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

* v14 Map conversion de-duped

* Substrate Map conversion

* v13 tests

* Apply suggestions from code review

* Housekeeping

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

* jest config fix

* typegen lookups

* Build fixes

* Explicit kusama naming

* testMeta for v14 (local)

* CI test failure

* CI test failure v14

* Update with corrected data after test

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

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

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

* BitVec

* BitVec
2021-08-03 09:39:32 +02:00
Github Actions 9c611e9414 [CI Skip] release/beta 5.3.2-0
skip-checks: true
2021-08-03 05:44:26 +00:00
Jaco da14679b65 v14 metadata bump (#3834) 2021-08-03 07:32:47 +02:00
392 changed files with 99806 additions and 14509 deletions
+12 -1
View File
@@ -1,4 +1,4 @@
32
33
1.4.2
1.6.2
1.11.2
@@ -24,3 +24,14 @@
4.9.2
4.11.2
4.16.2
5.3.2
5.5.2
5.8.2
5.8.3
6.0.2
6.0.3
6.0.4
6.0.5
6.1.2
File diff suppressed because one or more lines are too long
+631
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -10,4 +10,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
yarnPath: .yarn/releases/yarn-3.0.0-rc.2.cjs
yarnPath: .yarn/releases/yarn-3.0.1.cjs
+245
View File
@@ -1,5 +1,250 @@
# CHANGELOG
## 6.2.1 Oct 4, 2021
Upgrade priority: Low. Maintenance updates.
Contributed:
- Cater for new asset fee payment extension (Thanks to https://github.com/apopiak)
Changes:
- Extend error messages for malformed `queryMulti` inputs
- Correctly handle non-map queries passed to `queryMulti` in map form
- Use new metadata v14 lookup type in derive results
- Adjust definitions to infer TS types in `.multi` queries
- Fix TS lookup enum generation with nested Option & Tuple
- Bump static metadata for latest Substrate, Polkadot & Kusama
## 6.1.2 Sep 29, 2021
Upgrade priority: Low. Recommended for 6.x users using historic queries.
Changes:
- Fix `.at` queries/decoration for pre-V13 metadata
- Added `BridgeMessageId` & `SpecVersion` types for bridges
- Added `WrapperOpaque` encoding/decoding (as per latest Substrate)
- Bump static metadata for latest Substrate, Polkadot & Kusama
## 6.1.1 Sep 27, 2021
Upgrade priority: Low. Minor maintenance changes from the 6.0.x versions.
Contributed:
- Adjust bridges `OutboundLaneData` type (Thanks to https://github.com/HackFisher)
- Fix README 404 (Thanks to https://github.com/nblogist)
Changes:
- Add `childstate_getStorageEntries` RPC
- Allow for scale-info v0 -> v1 conversion
## 6.0.5 Sep 20, 2021
Upgrade priority: Low. Recommended for all users on 6.0.4 using `api.query.*.*.at` calls
Changes:
- Revert cross-registry (now-inactive) change introduced in 6.0.3
- Ensure `Option` is correctly imported for TS query generation
## 6.0.4 Sep 20, 2021
Upgrade priority: Low. Recommended for all users on 6.0.3 using `api.query.*.*.at` calls
Changes:
- `api.query.<module>.<method>.at` will now use `at.at(<hash>)`
- Use and expose `metadata/util/getSiName` to get human type names
## 6.0.3 Sep 19, 2021
Upgrade priority: Low. Recommended for all users on 6.0.2 using `api.query.*.*.at` calls
Changes:
- Fix `api.query.<module>.<method>.at` queries
- Adjust typegen formatting for metadata documentation
## 6.0.2 Sep 18, 2021
Upgrade priority: Low. Recommended for all users on 6.0.1, especially those using `api.query.substrate.*` calls
Changes:
- Fix `api.query.substrate.*` key generation
## 6.0.1 Sep 18, 2021
Upgrade priority: Low. Recommended for users of the latest Substrate/Polkadot with Metadata v14.
- **Important** The Metadata v14 change allows the metadata to expose the chain types. This has been a major overhaul of the metadata handling, hence the major version bump.
Contributed:
- Allow for `.clone` on Http provider (Thanks to https://github.com/ianhe8x)
Changes:
- Allow for Metadata v14 parsing & usage
- Align `DigestItem` to latest Substrate
- Adjust Kusama `IdentityInfo` type for historic versions
- All `null` values in bundles min/max
- Bump static metadata for latest Substrate, Polkadot & Kusama
## 5.9.1 Sep 13, 2021
Upgrade priority: Low. Recommended for chains using Xcm.
Contributed:
- Adjust Centrifuge `ProxyType` (Thanks to https://github.com/branan)
Changes:
- Additional types for parachain Disputes
- Adjust Xcm Error enum types
- Add Polkadot 9090 upgrade block
- Decoding enhancements with narrowing checks for TS
## 5.8.3 Sep 6, 2021
Upgrade priority: Low.
Changes:
- Adjust Statemint, Rococo and Westend Xcm overrides
## 5.8.2 Sep 6, 2021
Upgrade priority: Low.
Contributed:
- Correct Xcm V1 `MultiLocation` definitions (Thanks to https://github.com/apopiak)
Changes:
- Adjust Kusama Xcm overrides
## 5.8.1 Sep 6, 2021
Upgrade priority: Low.
Changes:
- Add `Auction` to Kusama `ProxyType` definition
- Adjust Xcm definitions with latest v1 & v2 types
- Support for `scale-info` 1.0 `Range` mapping
- Bump static metadata for latest Substrate, Polkadot & Kusama
## 5.7.1 Aug 29, 2021
Upgrade priority: Low.
Changes:
- Optimize `Vec` construction (no re-create on new arrays)
- Adjust output for enums in `toHuman`
- Adjust aliases for new parachain module locations
- Support for versioned xcm types (Polkadot master)
- Add support for `Range` in `PortableRegistry` (used in Metadata 14)
- Adjust balances derive for non-existent instances
- Ensure Statemint (current) defaults to xcm v0
- Add Kusama 9090 upgrade block
## 5.6.1 Aug 23, 2021
Upgrade priority: Low. Recommended for users of Xcm, preparing for Kusama/Westend 9100
Contributed:
- Support 0...N-1 args on `keys/entries` (Thanks to https://github.com/hamidra)
Changes:
- Updated XCM types, `AssetId`, `MultiAssets`, `MultiAssetV1`, `AssetInstanceV1`, `XcmOrderV1`
- Rename `Null` entry in `MultiLocation` to `Here` (Xcm V1)
- Westend 9090 upgrade block
- Bump static Substrate, Kusama & Polkadot metadata
## 5.5.2 Aug 19, 2021
Upgrade priority: Medium. Contains fixes for parachain types, affecting historic block retrieval on Kusama.
Changes:
- Adjust `ValidDisputeStatementKind` enum to latest version
- Only enable API health keepalive on connections supporting subscriptions
## 5.5.1 Aug 15, 2021
Upgrade priority: Low. Recommended for users of TS (`createType` and `bigint` adjustments)
Contributed:
- Add `Range` & `RangeInclusive` types (Thanks to https://github.com/c410-f3r)
- Always use TS `bigint` type (Thanks to https://github.com/ntduan)
Changes:
- Loosen pedantic check not to fail on all-empty values
- Extend `createType` auto-TS decoration for `BreeMap`, `BTreeSet`, `HashMap`, `Range`
- Add Polkadot 9080 upgrade block
## 5.4.1 Aug 9, 2021
Upgrade priority: Low. Recommended for potential users of NMap.
- **Important** The `ClassOf` alias for `createClass` has been removed, use `createClass` (with new generics) directly
Contributed:
- Enable `.keys()/.entries()` on NMap (Thanks to https://github.com/hamidra)
Changes:
- `createType<T = Codec>('...': K)` now returns `Codec` when `K` is not known
- `createType` does basic TypeScript type matching on the input type
- Handle `BitSequence` in `PortableRegistry`
- Ensure API `isConnected` is set before connect/disconnect events are fired
- Move all static test support files into `@polkadot/types-support`
- Align static Metadata with latest Substrate, Polkadot & Kusama
- Adjust v14 Metadata definitions to latest version
## 5.3.2 Aug 3, 2021
Upgrade priority: Low. Recommended for users of bridges.
Contributed:
- Add missing bridges types (Thanks to https://github.com/tomusdrw)
Changes:
- Align static metadata with latest Substrate
## 5.3.1 Aug 2, 2021
Upgrade priority: Low. Recommended for users of `api.at(...)` interfaces
+2 -14
View File
@@ -12,21 +12,9 @@ module.exports = {
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
'@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1',
'@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1',
'@polkadot/types-(known|support)(.*)$': '<rootDir>/packages/types-$1/src/$2',
// eslint-disable-next-line sort-keys
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
},
modulePathIgnorePatterns: [
'<rootDir>/packages/api/build',
'<rootDir>/packages/api-contract/build',
'<rootDir>/packages/api-derive/build',
'<rootDir>/packages/metadata/build',
'<rootDir>/packages/rpc-core/build',
'<rootDir>/packages/rpc-provider/build',
'<rootDir>/packages/typegen/build',
'<rootDir>/packages/types/build',
'<rootDir>/packages/types-known/build'
],
testTimeout: 30000,
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
testTimeout: 30000
};
+9 -8
View File
@@ -8,7 +8,7 @@
"packages/*"
],
"resolutions": {
"typescript": "^4.3.5"
"typescript": "^4.4.3"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts",
@@ -26,14 +26,15 @@
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.14.8",
"@babel/register": "^7.14.5",
"@babel/runtime": "^7.14.8",
"@polkadot/dev": "^0.62.57",
"@polkadot/ts": "^0.4.4",
"@babel/core": "^7.15.5",
"@babel/register": "^7.15.3",
"@babel/runtime": "^7.15.4",
"@polkadot/dev": "^0.62.68",
"@polkadot/ts": "^0.4.8",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.24",
"@types/jest": "^27.0.2",
"copyfiles": "^2.4.1"
},
"version": "5.3.1"
"version": "6.2.1",
"packageManager": "yarn@3.0.1"
}
+6 -6
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-contract",
"version": "5.3.1",
"version": "6.2.1",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
@@ -19,10 +19,10 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/api": "5.3.1",
"@polkadot/types": "5.3.1",
"@polkadot/util": "^7.1.1",
"rxjs": "^7.2.0"
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.2.1",
"@polkadot/types": "6.2.1",
"@polkadot/util": "^7.4.1",
"rxjs": "^7.3.0"
}
}
+3 -3
View File
@@ -3,7 +3,7 @@
import type { Bytes } from '@polkadot/types';
import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageParamSpec, ContractMessageSpec, ContractProject } from '@polkadot/types/interfaces';
import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
import type { AnyJson, Codec } from '@polkadot/types/types';
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@polkadot/util';
@@ -154,7 +154,7 @@ export class Abi {
index,
method: stringCamelCase(identifier),
selector: spec.selector,
toU8a: (params: CodecArg[]) =>
toU8a: (params: unknown[]) =>
this.#encodeArgs(spec, args, params)
};
@@ -185,7 +185,7 @@ export class Abi {
return message.fromU8a(trimmed.subarray(4));
}
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[]): Uint8Array => {
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: unknown[]): Uint8Array => {
assert(data.length === args.length, () => `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
return compactAddLength(
+17 -9
View File
@@ -4,27 +4,35 @@
import fs from 'fs';
import path from 'path';
import { TypeDefInfo } from '@polkadot/types/types';
import abis from '../test/contracts';
import { Abi } from '.';
function stringifyInfo (key: string, value: unknown): unknown {
return key === 'info'
? TypeDefInfo[value as number]
: value;
}
describe('MetaRegistry', (): void => {
Object.keys(abis).forEach((abiName) => {
it(`initializes from a contract ABI (${abiName})`, (): void => {
const abi = new Abi(abis[abiName]);
const json = JSON.stringify(abi.registry.metaTypeDefs, stringifyInfo, 2);
const cmpPath = path.join(__dirname, `../test/compare/${abiName}.test.json`);
try {
const cmpPath = path.join(__dirname, `../test/compare/${abiName}.test.json`);
// eslint-disable-next-line @typescript-eslint/no-var-requires
expect(JSON.parse(json)).toEqual(require(cmpPath));
} catch (error) {
if (process.env.GITHUB_REPOSITORY) {
console.error(JSON.stringify(abi.registry.metaTypeDefs, stringifyInfo));
if (!fs.existsSync(cmpPath)) {
fs.writeFileSync(cmpPath, JSON.stringify(abi.registry.metaTypeDefs, null, 2), { flag: 'w' });
throw error;
}
// eslint-disable-next-line @typescript-eslint/no-var-requires
expect(abi.registry.metaTypeDefs).toEqual(require(cmpPath));
} catch (error) {
console.error(JSON.stringify(abi.registry.metaTypeDefs));
throw error;
fs.writeFileSync(cmpPath, json, { flag: 'w' });
}
});
});
+2 -2
View File
@@ -4,7 +4,7 @@
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { MapConstructorExec } from './types';
@@ -52,7 +52,7 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
return this.#tx;
}
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
return this.api.tx.contracts
.instantiate(
value,
+2 -2
View File
@@ -4,7 +4,7 @@
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
import type { EventRecord } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { MapConstructorExec } from './types';
@@ -56,7 +56,7 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
return this.#tx;
}
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
return this.api.tx.contracts
.instantiateWithCode(
value,
+8 -8
View File
@@ -5,7 +5,7 @@ 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, EventRecord, Weight } from '@polkadot/types/interfaces';
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
@@ -26,15 +26,15 @@ const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is
const l = logger('Contract');
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: CodecArg[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
return (origin: string | AccountId | Uint8Array, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome> =>
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: unknown[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
return (origin: string | AccountId | Uint8Array, options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome> =>
isOptions(options)
? fn(origin, options, params)
: fn(origin, ...extractOptions(options, params));
}
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
return (options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType> =>
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: unknown[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
return (options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType> =>
isOptions(options)
? fn(options, params)
: fn(...extractOptions(options, params));
@@ -90,7 +90,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
return this.#tx;
}
#getGas = (_gasLimit: BigInt | BN | string | number, isCall = false): BN => {
#getGas = (_gasLimit: bigint | BN | string | number, isCall = false): BN => {
const gasLimit = bnToBn(_gasLimit);
return gasLimit.lte(BN_ZERO)
@@ -103,7 +103,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
: gasLimit;
}
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): SubmittableExtrinsic<ApiType> => {
return this.api.tx.contracts
.call(
this.address,
@@ -129,7 +129,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
);
}
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): ContractCallSend<ApiType> => {
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
const message = this.abi.findMessage(messageOrId);
+8 -9
View File
@@ -5,28 +5,27 @@ import type { Observable } from 'rxjs';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { CodecArg } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
export interface BlueprintDeploy<ApiType extends ApiTypes> {
(options: BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
(value: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
(options: BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
(value: bigint | string | number | BN, gasLimit: bigint | string | number | BN, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
}
export interface ContractQuery<ApiType extends ApiTypes> {
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
(origin: AccountId | string | Uint8Array, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
(origin: AccountId | string | Uint8Array, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
}
export interface ContractTx<ApiType extends ApiTypes> {
(options: ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
(value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
(options: ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
(value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
}
export interface ContractGeneric<O, T> {
(messageOrId: AbiMessage | string | number, options: O, ...params: CodecArg[]): T;
(messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): T;
(messageOrId: AbiMessage | string | number, options: O, ...params: unknown[]): T;
(messageOrId: AbiMessage | string | number, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): T;
}
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
+4 -5
View File
@@ -4,7 +4,6 @@
import type { SubmittableResult } from '@polkadot/api';
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
import type { ApiTypes } from '@polkadot/api/types';
import type { CodecArg } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { AbiConstructor, BlueprintOptions } from '../types';
import type { BlueprintDeploy, ContractGeneric } from './types';
@@ -17,15 +16,15 @@ import { extractOptions, isOptions } from '../util';
export const EMPTY_SALT = new Uint8Array();
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, R> =>
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: unknown[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
return (options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType, R> =>
isOptions(options)
? fn(options, params)
: fn(...extractOptions(options, params));
}
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: unknown[]) => T): ContractGeneric<BlueprintOptions, T> {
return (constructorOrId: AbiConstructor | string | number, options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): T =>
isOptions(options)
? fn(constructorOrId, options, params)
: fn(constructorOrId, ...extractOptions(options, params));
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '5.3.1' };
export const packageInfo = { name: '@polkadot/api-contract', version: '6.2.1' };
+6 -6
View File
@@ -5,7 +5,7 @@ import type { ApiBase } from '@polkadot/api/base';
import type { ApiTypes } from '@polkadot/api/types';
import type { Text, u64 } from '@polkadot/types';
import type { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
import type { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
import type { Codec, TypeDef } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { Abi } from '.';
@@ -42,7 +42,7 @@ export interface AbiMessage {
method: string;
returnType?: TypeDef | null;
selector: ContractSelector;
toU8a: (params: CodecArg[]) => Uint8Array;
toU8a: (params: unknown[]) => Uint8Array;
}
export type AbiConstructor = AbiMessage;
@@ -71,12 +71,12 @@ export interface DecodedMessage {
}
export interface BlueprintOptions {
gasLimit?: BigInt | string | number | BN;
gasLimit?: bigint | string | number | BN;
salt?: Uint8Array | string | null;
value?: BigInt | string | number | BN;
value?: bigint | string | number | BN;
}
export interface ContractOptions {
gasLimit?: BigInt | BN | string | number;
value?: BigInt | BN | string | number;
gasLimit?: bigint | BN | string | number;
value?: bigint | BN | string | number;
}
+2 -3
View File
@@ -3,7 +3,6 @@
import type { SubmittableResult } from '@polkadot/api';
import type { EventRecord } from '@polkadot/types/interfaces';
import type { CodecArg } from '@polkadot/types/types';
import type { BN } from '@polkadot/util';
import type { BlueprintOptions, ContractOptions } from './types';
@@ -25,11 +24,11 @@ export function applyOnEvent <T> (result: SubmittableResult, types: ContractEven
return undefined;
}
export function isOptions <T> (options: BigInt | string | number | BN | T): options is T {
export function isOptions <T> (options: bigint | string | number | BN | T): options is T {
return !(isBn(options) || isBigInt(options) || isNumber(options) || isString(options));
}
export function extractOptions <T extends TOptions> (value: BigInt | string | number | BN, params: CodecArg[]): [T, CodecArg[]] {
export function extractOptions <T extends TOptions> (value: bigint | string | number | BN, params: unknown[]): [T, unknown[]] {
const gasLimit = params.shift() as BN;
return [{ gasLimit, value } as T, params];
@@ -2,30 +2,30 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"info": 6,
"info": "Plain",
"type": "i32"
},
{
"displayName": "Hash",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "Hash"
}
]
@@ -2,20 +2,20 @@
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -23,7 +23,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -33,15 +33,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -52,45 +52,45 @@
{
"displayName": "Hash",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "Hash",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Hash\"}}"
},
{
"displayName": "Hash",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "Hash"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -104,23 +104,23 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
@@ -128,7 +128,7 @@
"sub": [
{
"name": "Ok",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
@@ -136,13 +136,13 @@
"name": "Error",
"displayName": "Error",
"namespace": "dns::dns",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "NameAlreadyExists",
"type": "Null"
},
@@ -150,7 +150,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "CallerIsNotOwner",
"type": "Null"
}
@@ -158,24 +158,24 @@
"type": "{\"_enum\":[\"NameAlreadyExists\",\"CallerIsNotOwner\"]}"
}
],
"info": 7,
"info": "Result",
"type": "Result<(), Error>"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
{
"displayName": "Error",
"namespace": "dns::dns",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "NameAlreadyExists",
"type": "Null"
},
@@ -183,7 +183,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "CallerIsNotOwner",
"type": "Null"
}
@@ -195,10 +195,10 @@
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"info": 5,
"info": "Option",
"type": "Option<AccountId>"
}
]
@@ -1,25 +1,25 @@
[
{
"info": 6,
"info": "Plain",
"type": "u128"
},
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -27,7 +27,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -37,15 +37,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -56,45 +56,45 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -106,17 +106,17 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u128",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
},
{
@@ -126,15 +126,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -143,18 +143,18 @@
"name": "Vacant"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
@@ -162,29 +162,29 @@
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(AccountId,AccountId)"
},
{
"info": 6,
"info": "Plain",
"type": "bool"
},
{
@@ -192,10 +192,10 @@
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"info": 5,
"info": "Option",
"type": "Option<AccountId>"
}
]
]
@@ -2,20 +2,20 @@
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -23,7 +23,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -33,15 +33,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -50,26 +50,26 @@
"name": "Vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -83,36 +83,36 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
@@ -122,15 +122,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -141,12 +141,12 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
},
{
@@ -154,17 +154,17 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
},
{
@@ -174,15 +174,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -191,18 +191,18 @@
"name": "Vacant"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
@@ -210,22 +210,22 @@
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
@@ -236,21 +236,21 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "bool",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"bool\",\"key_index\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "bool"
},
{
@@ -258,10 +258,10 @@
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"info": 5,
"info": "Option",
"type": "Option<AccountId>"
},
{
@@ -269,7 +269,7 @@
"sub": [
{
"name": "Ok",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
@@ -277,13 +277,13 @@
"name": "Error",
"displayName": "Error",
"namespace": "erc721::erc721",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "NotOwner",
"type": "Null"
},
@@ -291,7 +291,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "NotApproved",
"type": "Null"
},
@@ -299,7 +299,7 @@
"ext": {
"discriminant": 2
},
"info": 6,
"info": "Plain",
"name": "TokenExists",
"type": "Null"
},
@@ -307,7 +307,7 @@
"ext": {
"discriminant": 3
},
"info": 6,
"info": "Plain",
"name": "TokenNotFound",
"type": "Null"
},
@@ -315,7 +315,7 @@
"ext": {
"discriminant": 4
},
"info": 6,
"info": "Plain",
"name": "CannotInsert",
"type": "Null"
},
@@ -323,7 +323,7 @@
"ext": {
"discriminant": 5
},
"info": 6,
"info": "Plain",
"name": "CannotRemove",
"type": "Null"
},
@@ -331,7 +331,7 @@
"ext": {
"discriminant": 6
},
"info": 6,
"info": "Plain",
"name": "CannotFetchValue",
"type": "Null"
},
@@ -339,7 +339,7 @@
"ext": {
"discriminant": 7
},
"info": 6,
"info": "Plain",
"name": "NotAllowed",
"type": "Null"
}
@@ -347,24 +347,24 @@
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
}
],
"info": 7,
"info": "Result",
"type": "Result<(), Error>"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
{
"displayName": "Error",
"namespace": "erc721::erc721",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "NotOwner",
"type": "Null"
},
@@ -372,7 +372,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "NotApproved",
"type": "Null"
},
@@ -380,7 +380,7 @@
"ext": {
"discriminant": 2
},
"info": 6,
"info": "Plain",
"name": "TokenExists",
"type": "Null"
},
@@ -388,7 +388,7 @@
"ext": {
"discriminant": 3
},
"info": 6,
"info": "Plain",
"name": "TokenNotFound",
"type": "Null"
},
@@ -396,7 +396,7 @@
"ext": {
"discriminant": 4
},
"info": 6,
"info": "Plain",
"name": "CannotInsert",
"type": "Null"
},
@@ -404,7 +404,7 @@
"ext": {
"discriminant": 5
},
"info": 6,
"info": "Plain",
"name": "CannotRemove",
"type": "Null"
},
@@ -412,7 +412,7 @@
"ext": {
"discriminant": 6
},
"info": 6,
"info": "Plain",
"name": "CannotFetchValue",
"type": "Null"
},
@@ -420,11 +420,11 @@
"ext": {
"discriminant": 7
},
"info": 6,
"info": "Plain",
"name": "NotAllowed",
"type": "Null"
}
],
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
}
]
]
@@ -1,6 +1,6 @@
[
{
"info": 6,
"info": "Plain",
"type": "bool"
}
]
@@ -1,6 +1,6 @@
[
{
"info": 6,
"info": "Plain",
"type": "bool"
}
]
@@ -1,6 +1,6 @@
[
{
"info": 6,
"info": "Plain",
"type": "i32"
}
]
@@ -2,20 +2,20 @@
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -23,7 +23,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -33,15 +33,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -50,16 +50,16 @@
"name": "Vacant"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
@@ -67,20 +67,20 @@
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32,AccountId)\"}}"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
@@ -89,34 +89,34 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -128,22 +128,22 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"()\",\"key_index\":\"u32\"}"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
@@ -154,15 +154,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -171,12 +171,12 @@
"name": "Vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
},
{
@@ -184,17 +184,17 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
},
{
@@ -204,15 +204,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -223,41 +223,41 @@
{
"displayName": "Transaction",
"namespace": "multisig_plain::multisig_plain",
"info": 9,
"info": "Struct",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "callee"
},
{
"info": 12,
"info": "VecFixed",
"length": 4,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;4]",
"name": "selector"
},
{
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>",
"name": "input"
},
{
"info": 6,
"info": "Plain",
"type": "u128",
"name": "transferred_value"
},
{
"info": 6,
"info": "Plain",
"type": "u64",
"name": "gas_limit"
}
@@ -266,47 +266,47 @@
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Transaction\"}}"
},
{
"displayName": "Transaction",
"namespace": "multisig_plain::multisig_plain",
"info": 9,
"info": "Struct",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "callee"
},
{
"info": 12,
"info": "VecFixed",
"length": 4,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;4]",
"name": "selector"
},
{
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>",
"name": "input"
},
{
"info": 6,
"info": "Plain",
"type": "u128",
"name": "transferred_value"
},
{
"info": 6,
"info": "Plain",
"type": "u64",
"name": "gas_limit"
}
@@ -314,28 +314,28 @@
"type": "{\"callee\":\"AccountId\",\"selector\":\"[u8;4]\",\"input\":\"Vec<u8>\",\"transferred_value\":\"u128\",\"gas_limit\":\"u64\"}"
},
{
"info": 12,
"info": "VecFixed",
"length": 4,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;4]"
},
{
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>"
},
{
"info": 6,
"info": "Plain",
"type": "u128"
},
{
"info": 6,
"info": "Plain",
"type": "u64"
},
{
@@ -345,15 +345,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -364,44 +364,44 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
},
{
"info": 11,
"info": "Vec",
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"type": "Vec<AccountId>"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
"displayName": "ConfirmationStatus",
"namespace": "multisig_plain::multisig_plain",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Confirmed",
"type": "()"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "ConfirmationsNeeded"
}
@@ -414,16 +414,16 @@
{
"displayName": "ConfirmationStatus",
"namespace": "multisig_plain::multisig_plain",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Confirmed",
"type": "()"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "ConfirmationsNeeded"
}
@@ -435,18 +435,18 @@
"sub": [
{
"name": "Ok",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
},
{
"name": "Error",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
}
],
"info": 7,
"info": "Result",
"type": "Result<(), ()>"
},
{
@@ -454,21 +454,21 @@
"sub": [
{
"name": "Ok",
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>"
},
{
"name": "Error",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
}
],
"info": 7,
"info": "Result",
"type": "Result<Vec<u8>, ()>"
},
{
@@ -478,37 +478,37 @@
"name": "Ok",
"displayName": "Option",
"sub": {
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>"
},
"info": 5,
"info": "Option",
"type": "Option<Vec<u8>>"
},
{
"name": "Error",
"info": 10,
"info": "Tuple",
"sub": [],
"type": "()"
}
],
"info": 7,
"info": "Result",
"type": "Result<Option<Vec<u8>>, ()>"
},
{
"displayName": "Option",
"sub": {
"info": 11,
"info": "Vec",
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "Vec<u8>"
},
"info": 5,
"info": "Option",
"type": "Option<Vec<u8>>"
}
]
]
@@ -1,6 +1,6 @@
[
{
"info": 6,
"info": "Plain",
"type": "u256"
}
]
@@ -1,28 +1,28 @@
[
{
"info": 6,
"info": "Plain",
"type": "u256"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"displayName": "AccountId",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 6,
"info": "Plain",
"type": "Text"
}
]
@@ -1,23 +1,23 @@
[
{
"info": 6,
"info": "Plain",
"type": "i32"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "Variant",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "None",
"type": "()"
@@ -25,13 +25,13 @@
{
"displayName": "Weekday",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "Monday",
"type": "Null"
},
@@ -39,7 +39,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "Tuesday",
"type": "Null"
},
@@ -47,7 +47,7 @@
"ext": {
"discriminant": 2
},
"info": 6,
"info": "Plain",
"name": "Wednesday",
"type": "Null"
},
@@ -55,7 +55,7 @@
"ext": {
"discriminant": 3
},
"info": 6,
"info": "Plain",
"name": "Thursday",
"type": "Null"
},
@@ -63,7 +63,7 @@
"ext": {
"discriminant": 4
},
"info": 6,
"info": "Plain",
"name": "Friday",
"type": "Null"
},
@@ -71,7 +71,7 @@
"ext": {
"discriminant": 5
},
"info": 6,
"info": "Plain",
"name": "Saturday",
"type": "Null"
},
@@ -79,7 +79,7 @@
"ext": {
"discriminant": 6
},
"info": 6,
"info": "Plain",
"name": "Sunday",
"type": "Null"
}
@@ -90,15 +90,15 @@
{
"displayName": "TupleMaybeSigned",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "i32",
"name": "Signed"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "Unsigned"
}
@@ -109,13 +109,13 @@
{
"displayName": "NamedMaybeSigned",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "i32",
"name": "value"
}
@@ -124,10 +124,10 @@
"type": "{\"value\":\"i32\"}"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "value"
}
@@ -142,47 +142,47 @@
{
"displayName": "Color",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Red",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Blue",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Green",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Yellow",
"type": "()"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "r"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "g"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "b"
}
@@ -191,25 +191,25 @@
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "r"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "g"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "b"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "a"
}
@@ -227,13 +227,13 @@
{
"displayName": "Weekday",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"ext": {
"discriminant": 0
},
"info": 6,
"info": "Plain",
"name": "Monday",
"type": "Null"
},
@@ -241,7 +241,7 @@
"ext": {
"discriminant": 1
},
"info": 6,
"info": "Plain",
"name": "Tuesday",
"type": "Null"
},
@@ -249,7 +249,7 @@
"ext": {
"discriminant": 2
},
"info": 6,
"info": "Plain",
"name": "Wednesday",
"type": "Null"
},
@@ -257,7 +257,7 @@
"ext": {
"discriminant": 3
},
"info": 6,
"info": "Plain",
"name": "Thursday",
"type": "Null"
},
@@ -265,7 +265,7 @@
"ext": {
"discriminant": 4
},
"info": 6,
"info": "Plain",
"name": "Friday",
"type": "Null"
},
@@ -273,7 +273,7 @@
"ext": {
"discriminant": 5
},
"info": 6,
"info": "Plain",
"name": "Saturday",
"type": "Null"
},
@@ -281,7 +281,7 @@
"ext": {
"discriminant": 6
},
"info": 6,
"info": "Plain",
"name": "Sunday",
"type": "Null"
}
@@ -291,15 +291,15 @@
{
"displayName": "TupleMaybeSigned",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "i32",
"name": "Signed"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "Unsigned"
}
@@ -309,13 +309,13 @@
{
"displayName": "NamedMaybeSigned",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "i32",
"name": "value"
}
@@ -324,10 +324,10 @@
"type": "{\"value\":\"i32\"}"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "value"
}
@@ -341,47 +341,47 @@
{
"displayName": "Color",
"namespace": "enum_example::enum_example",
"info": 3,
"info": "Enum",
"sub": [
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Red",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Blue",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Green",
"type": "()"
},
{
"info": 10,
"info": "Tuple",
"sub": [],
"name": "Yellow",
"type": "()"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "r"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "g"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "b"
}
@@ -390,25 +390,25 @@
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
},
{
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "r"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "g"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "b"
},
{
"info": 6,
"info": "Plain",
"type": "u8",
"name": "a"
}
@@ -1,25 +1,25 @@
[
{
"info": 6,
"info": "Plain",
"type": "u128"
},
{
"displayName": "Header",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "last_vacant"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "len_entries"
}
@@ -27,7 +27,7 @@
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
},
{
"info": 6,
"info": "Plain",
"type": "u32"
},
{
@@ -37,15 +37,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -56,45 +56,45 @@
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId",
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"info": 12,
"info": "VecFixed",
"length": 32,
"sub": {
"info": 6,
"info": "Plain",
"type": "u8"
},
"type": "[u8;32]"
},
{
"info": 6,
"info": "Plain",
"type": "u8"
},
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -106,17 +106,17 @@
"namespace": "ink_storage::collections::hashmap",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u128",
"name": "value"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "key_index"
}
],
"info": 9,
"info": "Struct",
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
},
{
@@ -126,15 +126,15 @@
{
"displayName": "VacantEntry",
"namespace": "ink_storage::collections::stash",
"info": 9,
"info": "Struct",
"sub": [
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "next"
},
{
"info": 6,
"info": "Plain",
"type": "u32",
"name": "prev"
}
@@ -143,18 +143,18 @@
"name": "Vacant"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
@@ -162,33 +162,33 @@
"name": "Occupied"
}
],
"info": 3,
"info": "Enum",
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
},
{
"info": 10,
"info": "Tuple",
"sub": [
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
{
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
}
],
"type": "(AccountId,AccountId)"
},
{
"info": 6,
"info": "Plain",
"type": "Text"
},
{
"info": 6,
"info": "Plain",
"type": "bool"
},
{
@@ -196,10 +196,10 @@
"sub": {
"displayName": "AccountId",
"namespace": "ink_env::types",
"info": 6,
"info": "Plain",
"type": "AccountId"
},
"info": 5,
"info": "Option",
"type": "Option<AccountId>"
}
]
]
+10 -10
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api-derive",
"version": "5.3.1",
"version": "6.2.1",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
@@ -19,16 +19,16 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/api": "5.3.1",
"@polkadot/rpc-core": "5.3.1",
"@polkadot/types": "5.3.1",
"@polkadot/util": "^7.1.1",
"@polkadot/util-crypto": "^7.1.1",
"rxjs": "^7.2.0"
"@babel/runtime": "^7.15.4",
"@polkadot/api": "6.2.1",
"@polkadot/rpc-core": "6.2.1",
"@polkadot/types": "6.2.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"rxjs": "^7.3.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.1.1",
"@polkadot/rpc-provider": "5.3.1"
"@polkadot/keyring": "^7.4.1",
"@polkadot/rpc-provider": "6.2.1"
}
}
+11 -8
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Data, Option } from '@polkadot/types';
import type { AccountId, IdentityInfoAdditional, Registration } from '@polkadot/types/interfaces';
import type { AccountId } from '@polkadot/types/interfaces';
import type { PalletIdentityIdentityInfo, PalletIdentityRegistration } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveAccountRegistration, DeriveHasIdentity } from '../types';
@@ -14,6 +15,8 @@ import { isHex, u8aToString } from '@polkadot/util';
import { memo } from '../util';
type IdentityInfoAdditional = PalletIdentityIdentityInfo['additional'][0];
const UNDEF_HEX = { toHex: () => undefined };
function dataAsString (data: Data): string | undefined {
@@ -37,7 +40,7 @@ function extractOther (additional: IdentityInfoAdditional[]): Record<string, str
}, {});
}
function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
function extractIdentity (identityOfOpt?: Option<PalletIdentityRegistration>, superOf?: [AccountId, Data]): DeriveAccountRegistration {
if (!identityOfOpt?.isSome) {
return { judgements: [] };
}
@@ -61,7 +64,7 @@ function extractIdentity (identityOfOpt?: Option<Registration>, superOf?: [Accou
};
}
function getParent (api: ApiInterfaceRx, identityOfOpt: Option<Registration> | undefined, superOfOpt: Option<ITuple<[AccountId, Data]>> | undefined): Observable<[Option<Registration> | undefined, [AccountId, Data] | undefined]> {
function getParent (api: ApiInterfaceRx, identityOfOpt: Option<PalletIdentityRegistration> | undefined, superOfOpt: Option<ITuple<[AccountId, Data]>> | undefined): Observable<[Option<PalletIdentityRegistration> | undefined, [AccountId, Data] | undefined]> {
if (identityOfOpt?.isSome) {
// this identity has something set
return of([identityOfOpt, undefined]);
@@ -70,7 +73,7 @@ function getParent (api: ApiInterfaceRx, identityOfOpt: Option<Registration> | u
// we have a super
return combineLatest([
api.query.identity.identityOf<Option<Registration>>(superOf[0]),
api.query.identity.identityOf(superOf[0]),
of(superOf)
]);
}
@@ -79,9 +82,9 @@ function getParent (api: ApiInterfaceRx, identityOfOpt: Option<Registration> | u
return of([undefined, undefined]);
}
function getBase (api: ApiInterfaceRx, accountId?: AccountId | Uint8Array | string): Observable<[Option<Registration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]> {
function getBase (api: ApiInterfaceRx, accountId?: AccountId | Uint8Array | string): Observable<[Option<PalletIdentityRegistration> | undefined, Option<ITuple<[AccountId, Data]>> | undefined]> {
return accountId && api.query.identity?.identityOf
? api.queryMulti<[Option<Registration>, Option<ITuple<[AccountId, Data]>>]>([
? api.queryMulti<[Option<PalletIdentityRegistration>, Option<ITuple<[AccountId, Data]>>]>([
[api.query.identity.identityOf, accountId],
[api.query.identity.superOf, accountId]
])
@@ -113,8 +116,8 @@ export function hasIdentityMulti (instanceId: string, api: ApiInterfaceRx): (acc
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)
api.query.identity.identityOf.multi(accountIds),
api.query.identity.superOf.multi(accountIds)
]).pipe(
map(([identities, supers]) =>
identities.map((identityOfOpt, index): DeriveHasIdentity => {
+41 -38
View File
@@ -2,14 +2,14 @@
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { ApiInterfaceRx, QueryableStorageEntry } from '@polkadot/api/types';
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { assert, isFunction } from '@polkadot/util';
import { isFunction } from '@polkadot/util';
import { memo } from '../util';
@@ -39,15 +39,11 @@ function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenF
};
}
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, balances]]: [AccountId, Result]): DeriveBalancesAccount {
const primary = balances[0];
assert(primary, 'No balances retrieved for account');
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, [primary, ...additional]]]: [AccountId, Result]): DeriveBalancesAccount {
return {
accountId,
accountNonce,
additional: balances.filter((_, index) => index !== 0).map((b) => getBalance(api, b)),
additional: additional.map((b) => getBalance(api, b)),
...getBalance(api, primary)
};
}
@@ -66,34 +62,44 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
);
}
function querySystemNonce (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
return api.query.system.accountNonce<Index>(accountId).pipe(
map((accountNonce): Result => [
accountNonce,
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
])
);
function queryNonceOnly (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
const fill = (nonce: Index): Result => [
nonce,
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
];
return isFunction(api.query.system.account)
? api.query.system.account(accountId).pipe(
map(({ nonce }) => fill(nonce))
)
: isFunction(api.query.system.accountNonce)
? api.query.system.accountNonce<Index>(accountId).pipe(
map((nonce) => fill(nonce))
)
: of(fill(api.registry.createType('Index')));
}
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
const balances = modules.map(
(m): QueryableStorageMultiArg<'rxjs'> => [
(api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m].account,
accountId
]
);
const balances = modules
.map((m): QueryableStorageEntry<'rxjs'> => (api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m]?.account)
.filter((q) => isFunction(q))
.map((q): [QueryableStorageEntry<'rxjs'>, AccountId] => [q, accountId]);
const extract = (data: AccountData[]) =>
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
const extract = (nonce: Index, data: AccountData[]): Result => [
nonce,
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen])
];
// NOTE this is for the first case where we do have instances specified
return 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)])
);
return balances.length
? isFunction(api.query.system.account)
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
map(([{ nonce }, ...balances]) => extract(nonce, balances))
)
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
map(([nonce, ...balances]) => extract(nonce, balances))
)
: queryNonceOnly(api, accountId);
}
function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
@@ -140,10 +146,6 @@ function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observa
*/
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
const empty: Result = [
api.registry.createType('Index'),
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
];
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
api.derive.accounts.accountId(address).pipe(
@@ -159,11 +161,12 @@ export function account (instanceId: string, api: ApiInterfaceRx): (address: Acc
? queryBalancesAccount(api, accountId)
: isFunction(api.query.balances?.freeBalance)
? queryBalancesFree(api, accountId)
: isFunction(api.query.system?.accountNonce)
? querySystemNonce(api, accountId)
: of(empty)
: queryNonceOnly(api, accountId)
])
: of([api.registry.createType('AccountId'), empty])
: of([api.registry.createType('AccountId'), [
api.registry.createType('Index'),
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
]])
)
),
map((result): DeriveBalancesAccount => calcBalances(api, result))
+26 -28
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, AccountIndex, Address, Balance, BalanceLock, BalanceLockTo212, BlockNumber, VestingInfo, VestingSchedule } from '@polkadot/types/interfaces';
import type { AccountId, AccountIndex, Address, Balance, BalanceLockTo212, BlockNumber, VestingSchedule } from '@polkadot/types/interfaces';
import type { PalletBalancesBalanceLock, PalletVestingVestingInfo } from '@polkadot/types/lookup';
import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAll, DeriveBalancesAllAccountData } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -13,15 +14,15 @@ import { BN, bnMax, isFunction } from '@polkadot/util';
import { memo } from '../util';
type BalanceLocksEntry = Vec<BalanceLock | BalanceLockTo212>;
type BalanceLocksEntry = Vec<PalletBalancesBalanceLock | BalanceLockTo212>;
type BalanceLocks = BalanceLocksEntry[];
type ResultBalance = [VestingInfo | null, ((BalanceLock | BalanceLockTo212)[])[]];
type ResultBalance = [PalletVestingVestingInfo | null, ((PalletBalancesBalanceLock | BalanceLockTo212)[])[]];
type Result = [DeriveBalancesAccount, BlockNumber, ResultBalance];
interface AllLocked {
allLocked: boolean,
lockedBalance: Balance,
lockedBreakdown: (BalanceLock | BalanceLockTo212)[],
lockedBreakdown: (PalletBalancesBalanceLock | BalanceLockTo212)[],
vestingLocked: Balance
}
@@ -33,9 +34,9 @@ type DeriveCustomLocks = ApiInterfaceRx['derive'] & {
const VESTING_ID = '0x76657374696e6720';
function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (BalanceLock | BalanceLockTo212)[]): AllLocked {
function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (PalletBalancesBalanceLock | BalanceLockTo212)[]): AllLocked {
let lockedBalance = api.registry.createType('Balance');
let lockedBreakdown: (BalanceLock | BalanceLockTo212)[] = [];
let lockedBreakdown: (PalletBalancesBalanceLock | BalanceLockTo212)[] = [];
let vestingLocked = api.registry.createType('Balance');
let allLocked = false;
@@ -56,7 +57,7 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
return { allLocked, lockedBalance, lockedBreakdown, vestingLocked };
}
function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (BalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (PalletBalancesBalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
return {
@@ -73,7 +74,8 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
// Calculate the vesting balances,
// - offset = balance locked at startingBlock
// - perBlock is the unlock amount
const { locked: vestingTotal, perBlock, startingBlock } = vesting || api.registry.createType('VestingInfo');
const emptyVest = api.registry.createType<PalletVestingVestingInfo>('VestingInfo');
const { locked: vestingTotal, perBlock, startingBlock } = vesting || emptyVest;
const isStarted = bestNumber.gt(startingBlock);
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
@@ -95,7 +97,7 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
// old
function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<ResultBalance> {
return api.queryMulti<[Vec<BalanceLock>, Option<VestingSchedule>]>([
return api.queryMulti<[Vec<PalletBalancesBalanceLock>, Option<VestingSchedule>]>([
[api.query.balances.locks, accountId],
[api.query.balances.vesting, accountId]
]).pipe(
@@ -105,7 +107,7 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
if (optVesting.isSome) {
const { offset: locked, perBlock, startingBlock } = optVesting.unwrap();
vestingNew = api.registry.createType('VestingInfo', { locked, perBlock, startingBlock });
vestingNew = api.registry.createType<PalletVestingVestingInfo>('VestingInfo', { locked, perBlock, startingBlock });
}
return [vestingNew, [locks]];
@@ -117,33 +119,29 @@ const isNonNullable = <T>(nullable: T): nullable is NonNullable<T> => !!nullable
// current (balances, vesting)
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
const lockCalls = balanceInstances.map(
(m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
const calls = balanceInstances.map((m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
);
const lockEmpty = lockCalls.map((c) => !c);
const lockQueries = lockCalls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
const lockEmpty = calls.map((c) => !c);
const queries = calls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
return (
api.query.vesting?.vesting
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([
[api.query.vesting.vesting, accountId],
...lockQueries
])
? api.queryMulti<[Option<PalletVestingVestingInfo>, ...BalanceLocks]>([[api.query.vesting.vesting, accountId], ...queries])
// TODO We need to check module instances here as well, not only the balances module
: lockQueries.length
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(lockQueries).pipe(
map((locks): [Option<VestingInfo>, ...BalanceLocks] =>
[api.registry.createType('Option<VestingInfo>'), ...locks]
)
: queries.length
? api.queryMulti<[...(Vec<PalletBalancesBalanceLock>)[]]>(queries).pipe(
map((r): [Option<PalletVestingVestingInfo>, ...BalanceLocks] => [api.registry.createType('Option<VestingInfo>'), ...r])
)
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
: of([api.registry.createType('Option<VestingInfo>')] as [Option<PalletVestingVestingInfo>])
).pipe(
map(([optVesting, ...locks]): ResultBalance => {
map(([opt, ...locks]): ResultBalance => {
let offset = -1;
return [optVesting.unwrapOr(null), lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])];
return [
opt.unwrapOr(null),
lockEmpty.map((e) => e ? api.registry.createType<Vec<PalletBalancesBalanceLock>>('Vec<BalanceLock>') : locks[++offset])
];
})
);
}
+38
View File
@@ -0,0 +1,38 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { AccountId, Balance, BalanceLockTo212, BlockNumber, Index } from '@polkadot/types/interfaces';
import type { PalletBalancesBalanceLock } from '@polkadot/types/lookup';
export interface DeriveBalancesAccountData {
freeBalance: Balance;
frozenFee: Balance;
frozenMisc: Balance;
reservedBalance: Balance;
votingBalance: Balance;
}
export interface DeriveBalancesAccount extends DeriveBalancesAccountData {
accountId: AccountId;
accountNonce: Index;
additional: DeriveBalancesAccountData[];
}
export interface DeriveBalancesAllAccountData extends DeriveBalancesAccountData {
availableBalance: Balance;
lockedBalance: Balance;
lockedBreakdown: (PalletBalancesBalanceLock | BalanceLockTo212)[];
vestingLocked: Balance;
}
export interface DeriveBalancesAll extends DeriveBalancesAccount, DeriveBalancesAllAccountData {
additional: DeriveBalancesAllAccountData[];
isVesting: boolean;
vestedBalance: Balance;
vestedClaimable: Balance;
vestingEndBlock: BlockNumber;
vestingPerBlock: Balance;
vestingTotal: Balance;
}
export type DeriveBalancesMap = Record<string, DeriveBalancesAll>;
+5 -4
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import type { BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import type { PalletBountiesBounty } from '@polkadot/types/lookup';
import type { DeriveBounties, DeriveCollectiveProposal } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -12,7 +13,7 @@ import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
import { filterBountiesProposals } from './helpers/filterBountyProposals';
type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
type Result = [Option<PalletBountiesBounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
function parseResult ([maybeBounties, maybeDescriptions, ids, bountyProposals]: Result): DeriveBounties {
const bounties: DeriveBounties = [];
@@ -53,8 +54,8 @@ export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observ
const ids = keys.map(({ args: [id] }) => id);
return combineLatest([
bountyBase.bounties.multi<Option<Bounty>>(ids),
bountyBase.bountyDescriptions.multi<Option<Bytes>>(ids),
bountyBase.bounties.multi(ids),
bountyBase.bountyDescriptions.multi(ids),
of(ids),
of(filterBountiesProposals(api, proposals))
]);
@@ -40,9 +40,6 @@ function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: strin
// however we have had cases on Edgeware where the indices have moved around after an
// upgrade, which results in invalid on-chain data
combineLatest(hashes.map((hash) =>
// this should simply be api.query[section].proposalOf.multi<Option<Proposal>>(hashes),
// however we have had cases on Edgeware where the indices have moved around after an
// upgrade, which results in invalid on-chain data
api.query[section].proposalOf<Option<Proposal>>(hash).pipe(
catchError(() => of(null))
)
+4 -3
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableModuleStorage } from '@polkadot/api/types';
import type { Vec } from '@polkadot/types';
import type { AccountId, Balance, Voter } from '@polkadot/types/interfaces';
import type { AccountId, Balance } from '@polkadot/types/interfaces';
import type { PalletElectionsPhragmenVoter } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
@@ -13,9 +14,9 @@ import { combineLatest, map, of } from 'rxjs';
import { memo } from '../util';
// Voter is current tuple is 2.x-era
type VoteEntry = Voter | ITuple<[Balance, Vec<AccountId>]>;
type VoteEntry = PalletElectionsPhragmenVoter | ITuple<[Balance, Vec<AccountId>]>;
function isVoter (value: VoteEntry): value is Voter {
function isVoter (value: VoteEntry): value is PalletElectionsPhragmenVoter {
return !Array.isArray(value);
}
@@ -3,8 +3,9 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, u64, Vec } from '@polkadot/types';
import type { BlockNumber, Hash, ReferendumIndex, Scheduled } from '@polkadot/types/interfaces';
import type { Option, Vec } from '@polkadot/types';
import type { BlockNumber, Hash, ReferendumIndex } from '@polkadot/types/interfaces';
import type { PalletSchedulerScheduledV2 } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveDispatch, DeriveProposalImage } from '../types';
@@ -42,7 +43,7 @@ function queryQueue (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
);
}
function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], (Option<Scheduled>[] | null)[]]> {
function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], (Option<PalletSchedulerScheduledV2>[] | null)[]]> {
// We don't get entries, but rather we get the keys (triggered via finished referendums) and
// the subscribe to those keys - this means we pickup when the schedulers actually executes
// at a block, the entry for that block will become empty
@@ -56,11 +57,11 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], (Opt
return blockNumbers.length
? combineLatest([
of(blockNumbers),
// this should simply be api.query.scheduler.agenda.multi<Vec<Option<Scheduled>>>,
// this should simply be api.query.scheduler.agenda.multi,
// however we have had cases on Darwinia where the indices have moved around after an
// upgrade, which results in invalid on-chain data
combineLatest(blockNumbers.map((blockNumber) =>
api.query.scheduler.agenda<Vec<Option<Scheduled>>>(blockNumber).pipe(
api.query.scheduler.agenda(blockNumber).pipe(
// this does create an issue since it discards all at that block
catchError(() => of(null))
)
@@ -86,7 +87,7 @@ function queryScheduler (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
const id = scheduled.maybeId.unwrap().toHex();
if (id.startsWith(DEMOCRACY_ID)) {
const [, index] = api.registry.createType('(u64, ReferendumIndex)' as any, id) as ITuple<[u64, ReferendumIndex]>;
const [, index] = api.registry.createType('(u64, ReferendumIndex)', id);
const imageHash = scheduled.call.args[0] as Hash;
result.push({ at, imageHash, index });
+11 -6
View File
@@ -3,8 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
import type { AccountId, ReferendumInfoTo239, Vote } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumInfo, PalletDemocracyVoteVoting } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveDemocracyLock } from '../types';
@@ -14,6 +14,11 @@ import { BN_ZERO, isUndefined } from '@polkadot/util';
import { memo } from '../util';
type ReferendumInfoFinished = PalletDemocracyReferendumInfo['asFinished'];
type VotingDelegating = PalletDemocracyVoteVoting['asDelegating'];
type VotingDirect = PalletDemocracyVoteVoting['asDirect'];
type VotingDirectVote = VotingDirect['votes'][0];
const LOCKUPS = [0, 1, 2, 4, 8, 16, 32];
function parseEnd (api: ApiInterfaceRx, vote: Vote, { approved, end }: ReferendumInfoFinished): [BN, BN] {
@@ -25,7 +30,7 @@ function parseEnd (api: ApiInterfaceRx, vote: Vote, { approved, end }: Referendu
];
}
function parseLock (api: ApiInterfaceRx, [referendumId, accountVote]: VotingDirectVote, referendum: ReferendumInfo): DeriveDemocracyLock {
function parseLock (api: ApiInterfaceRx, [referendumId, accountVote]: VotingDirectVote, referendum: PalletDemocracyReferendumInfo): DeriveDemocracyLock {
const { balance, vote } = accountVote.asStandard;
const [referendumEnd, unlockAt] = referendum.isFinished
? parseEnd(api, vote, referendum.asFinished)
@@ -57,13 +62,13 @@ function directLocks (api: ApiInterfaceRx, { votes }: VotingDirect): Observable<
return of([]);
}
return api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo | ReferendumInfoTo239>>(votes.map(([referendumId]) => referendumId)).pipe(
return api.query.democracy.referendumInfoOf.multi(votes.map(([referendumId]) => referendumId)).pipe(
map((referendums) =>
votes
.map((vote, index): [VotingDirectVote, ReferendumInfo | ReferendumInfoTo239 | null] =>
.map((vote, index): [VotingDirectVote, PalletDemocracyReferendumInfo | ReferendumInfoTo239 | null] =>
[vote, referendums[index].unwrapOr(null)]
)
.filter((item): item is [VotingDirectVote, ReferendumInfo] =>
.filter((item): item is [VotingDirectVote, PalletDemocracyReferendumInfo] =>
!!item[1] && isUndefined((item[1] as ReferendumInfoTo239).end) && item[0][1].isStandard
)
.map(([directVote, referendum]) =>
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { Hash, VoteThreshold } from '@polkadot/types/interfaces';
import type { H256 } from '@polkadot/types/interfaces';
import type { PalletDemocracyVoteThreshold } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveProposalExternal } from '../types';
@@ -12,7 +13,7 @@ import { map, of, switchMap } from 'rxjs';
import { memo } from '../util';
function withImage (api: ApiInterfaceRx, nextOpt: Option<ITuple<[Hash, VoteThreshold]>>): Observable<DeriveProposalExternal | null> {
function withImage (api: ApiInterfaceRx, nextOpt: Option<ITuple<[H256, PalletDemocracyVoteThreshold]>>): Observable<DeriveProposalExternal | null> {
if (nextOpt.isNone) {
return of(null);
}
@@ -31,7 +32,7 @@ function withImage (api: ApiInterfaceRx, nextOpt: Option<ITuple<[Hash, VoteThres
export function nextExternal (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveProposalExternal | null> {
return memo(instanceId, (): Observable<DeriveProposalExternal | null> =>
api.query.democracy?.nextExternal
? api.query.democracy.nextExternal<Option<ITuple<[Hash, VoteThreshold]>>>().pipe(
? api.query.democracy.nextExternal().pipe(
switchMap((nextOpt) => withImage(api, nextOpt))
)
: of(null)
@@ -3,9 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { DeriveProposalImage } from '../types';
import { map } from 'rxjs';
@@ -13,11 +11,9 @@ import { map } from 'rxjs';
import { memo } from '../util';
import { parseImage } from './util';
type PreImage = Option<ITuple<[Bytes, AccountId, Balance, BlockNumber]>>;
export function preimage (instanceId: string, api: ApiInterfaceRx): (hash: Hash) => Observable<DeriveProposalImage | undefined> {
return memo(instanceId, (hash: Hash): Observable<DeriveProposalImage | undefined> =>
api.query.democracy.preimages<PreImage>(hash).pipe(
api.query.democracy.preimages(hash).pipe(
map((imageOpt) => parseImage(api, imageOpt))
)
);
@@ -3,9 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { DeriveProposalImage } from '../types';
import { map, of } from 'rxjs';
@@ -13,12 +11,10 @@ import { map, of } from 'rxjs';
import { memo } from '../util';
import { parseImage } from './util';
type PreImage = Option<ITuple<[Bytes, AccountId, Balance, BlockNumber]>>;
export function preimages (instanceId: string, api: ApiInterfaceRx): (hashes: Hash[]) => Observable<(DeriveProposalImage | undefined)[]> {
return memo(instanceId, (hashes: Hash[]): Observable<(DeriveProposalImage | undefined)[]> =>
hashes.length
? api.query.democracy.preimages.multi<PreImage>(hashes).pipe(
? api.query.democracy.preimages.multi(hashes).pipe(
map((images): (DeriveProposalImage | undefined)[] =>
images.map((imageOpt) => parseImage(api, imageOpt))
)
@@ -58,9 +58,9 @@ export function proposals (instanceId: string, api: ApiInterfaceRx): () => Obser
? combineLatest([
of(proposals),
api.derive.democracy.preimages(
proposals.map(([, hash]): Hash => hash)),
api.query.democracy.depositOf.multi<Depositors>(
proposals.map(([index]): PropIndex => index))
proposals.map(([, hash]) => hash)),
api.query.democracy.depositOf.multi(
proposals.map(([index]) => index))
])
: of<Result>([[], [], []])
),
@@ -3,23 +3,24 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { ReferendumInfo, ReferendumInfoFinished } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumInfo } from '@polkadot/types/lookup';
import { map, switchMap } from 'rxjs';
import { memo } from '../util';
type ReferendumInfoFinished = PalletDemocracyReferendumInfo['asFinished'];
export function referendumsFinished (instanceId: string, api: ApiInterfaceRx): () => Observable<ReferendumInfoFinished[]> {
return memo(instanceId, (): Observable<ReferendumInfoFinished[]> =>
api.derive.democracy.referendumIds().pipe(
switchMap((ids) =>
api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo>>(ids)
api.query.democracy.referendumInfoOf.multi(ids)
),
map((infos): ReferendumInfoFinished[] =>
infos
.map((optInfo) => optInfo.unwrapOr(null))
.filter((info): info is ReferendumInfo => !!info && info.isFinished)
.filter((info): info is PalletDemocracyReferendumInfo => !!info && info.isFinished)
.map((info) => info.asFinished)
)
)
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
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 { AccountId, ReferendumInfoTo239, Vote } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumInfo, PalletDemocracyVoteVoting } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveBalancesAccount, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes } from '../types';
@@ -15,6 +16,10 @@ import { isFunction } from '@polkadot/util';
import { memo } from '../util';
import { calcVotes, getStatus, parseImage } from './util';
type VotingDelegating = PalletDemocracyVoteVoting['asDelegating'];
type VotingDirect = PalletDemocracyVoteVoting['asDirect'];
type VotingDirectVote = VotingDirect['votes'][0];
function votesPrev (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votersFor<Vec<AccountId>>(referendumId).pipe(
switchMap((votersFor): Observable<[Vec<AccountId>, Vote[], DeriveBalancesAccount[]]> =>
@@ -41,7 +46,7 @@ function votesPrev (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveRef
);
}
function extractVotes (mapped: [AccountId, Voting][], referendumId: BN): DeriveReferendumVote[] {
function extractVotes (mapped: [AccountId, PalletDemocracyVoteVoting][], referendumId: BN): DeriveReferendumVote[] {
return mapped
.filter(([, voting]) => voting.isDirect)
.map(([accountId, voting]): [AccountId, VotingDirectVote[]] => [
@@ -66,9 +71,9 @@ function extractVotes (mapped: [AccountId, Voting][], referendumId: BN): DeriveR
}
function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votingOf.entries<Voting, [AccountId]>().pipe(
return api.query.democracy.votingOf.entries().pipe(
map((allVoting): DeriveReferendumVote[] => {
const mapped = allVoting.map(([{ args: [accountId] }, voting]): [AccountId, Voting] => [accountId, voting]);
const mapped = allVoting.map(([{ args: [accountId] }, voting]): [AccountId, PalletDemocracyVoteVoting] => [accountId, voting]);
const votes = extractVotes(mapped, referendumId);
const delegations = mapped
.filter(([, voting]) => voting.isDelegating)
@@ -123,8 +128,8 @@ export function _referendumsVotes (instanceId: string, api: ApiInterfaceRx): (re
);
}
export function _referendumInfo (instanceId: string, api: ApiInterfaceRx): (index: BN, info: Option<ReferendumInfo | ReferendumInfoTo239>) => Observable<DeriveReferendum | null> {
return memo(instanceId, (index: BN, info: Option<ReferendumInfo | ReferendumInfoTo239>): Observable<DeriveReferendum | null> => {
export function _referendumInfo (instanceId: string, api: ApiInterfaceRx): (index: BN, info: Option<PalletDemocracyReferendumInfo | ReferendumInfoTo239>) => Observable<DeriveReferendum | null> {
return memo(instanceId, (index: BN, info: Option<PalletDemocracyReferendumInfo | ReferendumInfoTo239>): Observable<DeriveReferendum | null> => {
const status = getStatus(info);
return status
@@ -143,7 +148,7 @@ export function _referendumInfo (instanceId: string, api: ApiInterfaceRx): (inde
export function referendumsInfo (instanceId: string, api: ApiInterfaceRx): (ids: BN[]) => Observable<DeriveReferendum[]> {
return memo(instanceId, (ids: BN[]): Observable<DeriveReferendum[]> =>
ids.length
? api.query.democracy.referendumInfoOf.multi<Option<ReferendumInfo>>(ids).pipe(
? api.query.democracy.referendumInfoOf.multi(ids).pipe(
switchMap((infos): Observable<(DeriveReferendum | null)[]> =>
combineLatest(
ids.map((id, index): Observable<DeriveReferendum | null> =>
+4 -3
View File
@@ -2,7 +2,8 @@
// SPDX-License-Identifier: Apache-2.0
import type { Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, Hash, PropIndex, Proposal, ReferendumIndex, ReferendumInfoTo239, ReferendumStatus, Vote, VoteThreshold } from '@polkadot/types/interfaces';
import type { AccountId, Balance, BlockNumber, Hash, PropIndex, Proposal, ReferendumIndex, ReferendumInfoTo239, Vote } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumStatus, PalletDemocracyVoteThreshold } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
export interface DeriveDemocracyLock {
@@ -41,14 +42,14 @@ export interface DeriveProposal {
export interface DeriveProposalExternal {
image?: DeriveProposalImage;
imageHash: Hash;
threshold: VoteThreshold;
threshold: PalletDemocracyVoteThreshold;
}
export interface DeriveReferendum {
index: ReferendumIndex;
image?: DeriveProposalImage;
imageHash: Hash;
status: ReferendumStatus | ReferendumInfoTo239;
status: PalletDemocracyReferendumStatus | ReferendumInfoTo239;
}
export interface DeriveReferendumVote {
+10 -9
View File
@@ -3,7 +3,8 @@
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 { AccountId, Balance, BlockNumber, PreimageStatus, Proposal, ReferendumInfoTo239, Tally } from '@polkadot/types/interfaces';
import type { PalletDemocracyReferendumInfo, PalletDemocracyReferendumStatus, PalletDemocracyVoteThreshold } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveProposalImage, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes, DeriveReferendumVoteState } from '../types';
@@ -18,12 +19,12 @@ interface ApproxState {
votedTotal: BN;
}
function isOldInfo (info: ReferendumInfo | ReferendumInfoTo239): info is ReferendumInfoTo239 {
function isOldInfo (info: PalletDemocracyReferendumInfo | ReferendumInfoTo239): info is ReferendumInfoTo239 {
return !!(info as ReferendumInfoTo239).proposalHash;
}
function isCurrentStatus (status: ReferendumStatus | ReferendumInfoTo239): status is ReferendumStatus {
return !!(status as ReferendumStatus).tally;
function isCurrentStatus (status: PalletDemocracyReferendumStatus | ReferendumInfoTo239): status is PalletDemocracyReferendumStatus {
return !!(status as PalletDemocracyReferendumStatus).tally;
}
function isCurrentPreimage (api: ApiInterfaceRx, imageOpt: Option<OldPreimage> | Option<PreimageStatus>): imageOpt is Option<PreimageStatus> {
@@ -57,18 +58,18 @@ export function compareRationals (n1: BN, d1: BN, n2: BN, d2: BN): boolean {
}
}
function calcPassingOther (threshold: VoteThreshold, sqrtElectorate: BN, { votedAye, votedNay, votedTotal }: ApproxState): boolean {
function calcPassingOther (threshold: PalletDemocracyVoteThreshold, sqrtElectorate: BN, { votedAye, votedNay, votedTotal }: ApproxState): boolean {
const sqrtVoters = bnSqrt(votedTotal);
return sqrtVoters.isZero()
? false
: threshold.isSupermajorityapproval
: threshold.isSuperMajorityApprove
? compareRationals(votedNay, sqrtVoters, votedAye, sqrtElectorate)
: compareRationals(votedNay, sqrtElectorate, votedAye, sqrtVoters);
}
export function calcPassing (threshold: VoteThreshold, sqrtElectorate: BN, state: ApproxState): boolean {
return threshold.isSimplemajority
export function calcPassing (threshold: PalletDemocracyVoteThreshold, sqrtElectorate: BN, state: ApproxState): boolean {
return threshold.isSimpleMajority
? state.votedAye.gt(state.votedNay)
: calcPassingOther(threshold, sqrtElectorate, state);
}
@@ -134,7 +135,7 @@ export function calcVotes (sqrtElectorate: BN, referendum: DeriveReferendum, vot
};
}
export function getStatus (info: Option<ReferendumInfo | ReferendumInfoTo239>): ReferendumStatus | ReferendumInfoTo239 | null {
export function getStatus (info: Option<PalletDemocracyReferendumInfo | ReferendumInfoTo239>): PalletDemocracyReferendumStatus | ReferendumInfoTo239 | null {
if (info.isNone) {
return null;
}
@@ -3,8 +3,9 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Bytes, Option, u32 } from '@polkadot/types';
import type { Option, u32, WrapperOpaque } from '@polkadot/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { PalletImOnlineBoundedOpaqueNetworkState } from '@polkadot/types/lookup';
import type { DeriveHeartbeats } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -13,7 +14,9 @@ import { BN_ZERO } from '@polkadot/util';
import { memo } from '../util';
function mapResult ([result, validators, heartbeats, numBlocks]: [DeriveHeartbeats, AccountId[], Option<Bytes>[], u32[]]): DeriveHeartbeats {
type HeartbeatsOpt = Option<WrapperOpaque<PalletImOnlineBoundedOpaqueNetworkState>>;
function mapResult ([result, validators, heartbeats, numBlocks]: [DeriveHeartbeats, AccountId[], HeartbeatsOpt[], u32[]]): DeriveHeartbeats {
validators.forEach((validator, index): void => {
const validatorId = validator.toString();
const blockCount = numBlocks[index];
@@ -39,13 +42,13 @@ export function receivedHeartbeats (instanceId: string, api: ApiInterfaceRx): ()
return memo(instanceId, (): Observable<DeriveHeartbeats> =>
api.query.imOnline?.receivedHeartbeats
? api.derive.staking.overview().pipe(
switchMap(({ currentIndex, validators }): Observable<[DeriveHeartbeats, AccountId[], Option<Bytes>[], u32[]]> =>
switchMap(({ currentIndex, validators }): Observable<[DeriveHeartbeats, AccountId[], HeartbeatsOpt[], u32[]]> =>
combineLatest([
of({}),
of(validators),
api.query.imOnline.receivedHeartbeats.multi<Option<Bytes>>(
api.query.imOnline.receivedHeartbeats.multi(
validators.map((_address, index) => [currentIndex, index])),
api.query.imOnline.authoredBlocks.multi<u32>(
api.query.imOnline.authoredBlocks.multi(
validators.map((address) => [currentIndex, address]))
])
),
+4 -6
View File
@@ -14,10 +14,7 @@ import { TypeRegistry } from '@polkadot/types/create';
import { ExactDerive } from '.';
const testFunction = (api: ApiRx): any => {
return <
Section extends keyof ExactDerive,
Method extends keyof (typeof api.derive[Section])
>(section: Section, method: Method, inputs: any[]): void => {
return <S extends keyof ExactDerive, M extends keyof (typeof api.derive[S])>(section: S, method: M, inputs: any[]): void => {
describe(`derive.${section}.${method}`, (): void => {
it('should be a function', (): void => {
expect(typeof api.derive[section][method]).toBe('function');
@@ -81,7 +78,8 @@ describe('derive', (): void => {
}
},
provider: new MockProvider(registry),
registry
registry,
throwOnConnect: true
});
beforeAll((done): void => {
@@ -96,7 +94,7 @@ describe('derive', (): void => {
testFunction(api)('balances', 'fees', ['a', 'b']);
// new
testFunction(api)('custom' as any, 'test', [1, 2, 3]);
testFunction(api)('custom', 'test', [1, 2, 3]);
// existing
testFunction(api)('chain', 'bestNumber', []);
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '5.3.1' };
export const packageInfo = { name: '@polkadot/api-derive', version: '6.2.1' };
+2 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Option, u32 } from '@polkadot/types';
import type { Option, u32, u64 } from '@polkadot/types';
import type { BlockNumber, EraIndex, Moment, SessionIndex } from '@polkadot/types/interfaces';
export interface DeriveSessionIndexes {
@@ -15,7 +15,7 @@ export interface DeriveSessionIndexes {
export interface DeriveSessionInfo extends DeriveSessionIndexes {
eraLength: BlockNumber;
isEpoch: boolean;
sessionLength: BlockNumber;
sessionLength: u64;
sessionsPerEra: SessionIndex;
}
+10 -8
View File
@@ -3,8 +3,9 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, BalanceOf, Bid, BidKind } from '@polkadot/types/interfaces';
import type { Option } from '@polkadot/types';
import type { BalanceOf } from '@polkadot/types/interfaces';
import type { PalletSocietyBid, PalletSocietyBidKind } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveSocietyCandidate } from '../types';
@@ -12,20 +13,21 @@ import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
type ResultSuspend = Option<ITuple<[BalanceOf, BidKind]>>;
type Result = [Bid[], ResultSuspend[]]
type ResultSuspend = Option<ITuple<[BalanceOf, PalletSocietyBidKind]>>;
type Result = [PalletSocietyBid[], ResultSuspend[]]
/**
* @description Get the candidate info for a society
*/
export function candidates (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSocietyCandidate[]> {
return memo(instanceId, (): Observable<DeriveSocietyCandidate[]> =>
api.query.society.candidates<Vec<Bid>>().pipe(
switchMap((candidates: Vec<Bid>): Observable<Result> =>
api.query.society.candidates().pipe(
switchMap((candidates): Observable<Result> =>
combineLatest([
of(candidates),
api.query.society.suspendedCandidates.multi<ResultSuspend>(
candidates.map(({ who }): AccountId => who))
api.query.society.suspendedCandidates.multi(
candidates.map(({ who }) => who)
)
])
),
map(([candidates, suspended]: Result): DeriveSocietyCandidate[] =>
+3 -2
View File
@@ -4,14 +4,15 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, u32, Vec } from '@polkadot/types';
import type { AccountId, BalanceOf, Bid } from '@polkadot/types/interfaces';
import type { AccountId, BalanceOf } from '@polkadot/types/interfaces';
import type { PalletSocietyBid } from '@polkadot/types/lookup';
import type { DeriveSociety } from '../types';
import { map } from 'rxjs';
import { memo } from '../util';
type Result = [Vec<Bid>, Option<AccountId>, Option<AccountId>, Option<AccountId>, u32, BalanceOf]
type Result = [Vec<PalletSocietyBid>, Option<AccountId>, Option<AccountId>, Option<AccountId>, u32, BalanceOf]
/**
* @description Get the overall info for a society
+6 -8
View File
@@ -3,9 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { bool, Option, Vec } from '@polkadot/types';
import type { AccountId, Balance, BlockNumber, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces';
import type { ITuple } from '@polkadot/types/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { DeriveSocietyMember } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -16,11 +14,11 @@ export function _members (instanceId: string, api: ApiInterfaceRx): (accountIds:
return memo(instanceId, (accountIds: AccountId[]): Observable<DeriveSocietyMember[]> =>
combineLatest([
of(accountIds),
api.query.society.payouts.multi<Vec<ITuple<[BlockNumber, Balance]>>>(accountIds),
api.query.society.strikes.multi<StrikeCount>(accountIds),
api.query.society.defenderVotes.multi<Option<SocietyVote>>(accountIds),
api.query.society.suspendedMembers.multi<bool>(accountIds),
api.query.society.vouching.multi<Option<VouchingStatus>>(accountIds)
api.query.society.payouts.multi(accountIds),
api.query.society.strikes.multi(accountIds),
api.query.society.defenderVotes.multi(accountIds),
api.query.society.suspendedMembers.multi(accountIds),
api.query.society.vouching.multi(accountIds)
]).pipe(
map(([accountIds, payouts, strikes, defenderVotes, suspended, vouching]) =>
accountIds.map((accountId, index) => ({
+33
View File
@@ -0,0 +1,33 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { u32 } from '@polkadot/types';
import type { AccountId, Balance, BalanceOf, BlockNumber, StrikeCount } from '@polkadot/types/interfaces';
import type { PalletSocietyBid, PalletSocietyBidKind, PalletSocietyVote, PalletSocietyVouchingStatus } from '@polkadot/types/lookup';
export interface DeriveSociety {
bids: PalletSocietyBid[];
defender?: AccountId;
hasDefender: boolean;
head?: AccountId;
founder?: AccountId;
maxMembers: u32;
pot: BalanceOf;
}
export interface DeriveSocietyCandidate {
accountId: AccountId;
kind: PalletSocietyBidKind;
value: Balance;
isSuspended: boolean;
}
export interface DeriveSocietyMember {
accountId: AccountId;
isDefenderVoter: boolean;
isSuspended: boolean;
payouts: [BlockNumber, Balance][];
strikes: StrikeCount;
vote?: PalletSocietyVote;
vouching?: PalletSocietyVouchingStatus;
}
+6 -5
View File
@@ -3,7 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Balance, StakingLedger, UnlockChunk } from '@polkadot/types/interfaces';
import type { Balance } from '@polkadot/types/interfaces';
import type { PalletStakingStakingLedger, PalletStakingUnlockChunk } from '@polkadot/types/lookup';
import type { DeriveSessionInfo, DeriveStakingAccount, DeriveStakingKeys, DeriveStakingQuery, DeriveUnlocking } from '../types';
import { combineLatest, map, switchMap } from 'rxjs';
@@ -19,7 +20,7 @@ const QUERY_OPTS = {
withPrefs: true
};
function groupByEra (list: UnlockChunk[]): Record<string, BN> {
function groupByEra (list: PalletStakingUnlockChunk[]): Record<string, BN> {
return list.reduce((map: Record<string, BN>, { era, value }): Record<string, BN> => {
const key = era.toString();
@@ -29,7 +30,7 @@ function groupByEra (list: UnlockChunk[]): Record<string, BN> {
}, {});
}
function calculateUnlocking (api: ApiInterfaceRx, stakingLedger: StakingLedger | undefined, sessionInfo: DeriveSessionInfo): DeriveUnlocking[] | undefined {
function calculateUnlocking (api: ApiInterfaceRx, stakingLedger: PalletStakingStakingLedger | undefined, sessionInfo: DeriveSessionInfo): DeriveUnlocking[] | undefined {
const results = Object
.entries(groupByEra(
(stakingLedger?.unlocking || []).filter(({ era }) => era.unwrap().gt(sessionInfo.activeEra))
@@ -44,8 +45,8 @@ function calculateUnlocking (api: ApiInterfaceRx, stakingLedger: StakingLedger |
: undefined;
}
function redeemableSum (api: ApiInterfaceRx, stakingLedger: StakingLedger | undefined, sessionInfo: DeriveSessionInfo): Balance {
return api.registry.createType('Balance', (stakingLedger?.unlocking || [] as UnlockChunk[]).reduce((total, { era, value }): BN => {
function redeemableSum (api: ApiInterfaceRx, stakingLedger: PalletStakingStakingLedger | undefined, sessionInfo: DeriveSessionInfo): Balance {
return api.registry.createType('Balance', (stakingLedger?.unlocking || [] as PalletStakingUnlockChunk[]).reduce((total, { era, value }): BN => {
return sessionInfo.activeEra.gte(era.unwrap())
? total.iadd(value.unwrap())
: total;
@@ -3,7 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EraRewardPoints } from '@polkadot/types/interfaces';
import type { PalletStakingEraRewardPoints } from '@polkadot/types/lookup';
import { switchMap } from 'rxjs';
@@ -12,11 +12,11 @@ import { memo } from '../util';
/**
* @description Retrieve the staking overview, including elected and points earned
*/
export function currentPoints (instanceId: string, api: ApiInterfaceRx): () => Observable<EraRewardPoints> {
return memo(instanceId, (): Observable<EraRewardPoints> =>
export function currentPoints (instanceId: string, api: ApiInterfaceRx): () => Observable<PalletStakingEraRewardPoints> {
return memo(instanceId, (): Observable<PalletStakingEraRewardPoints> =>
api.derive.session.indexes().pipe(
switchMap(({ activeEra }) =>
api.query.staking.erasRewardPoints<EraRewardPoints>(activeEra)
api.query.staking.erasRewardPoints<PalletStakingEraRewardPoints>(activeEra)
)
));
}
@@ -4,14 +4,15 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { StorageKey } from '@polkadot/types';
import type { AccountId, EraIndex, Exposure } from '@polkadot/types/interfaces';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure } from '@polkadot/types/lookup';
import type { DeriveEraExposure, DeriveEraNominatorExposure, DeriveEraValidatorExposure } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { deriveCache, memo } from '../util';
type KeysAndExposures = [StorageKey<[EraIndex, AccountId]>, Exposure][];
type KeysAndExposures = [StorageKey<[EraIndex, AccountId]>, PalletStakingExposure][];
const CACHE_KEY = 'eraExposure';
@@ -3,7 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EraIndex, EraRewardPoints } from '@polkadot/types/interfaces';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingEraRewardPoints } from '@polkadot/types/lookup';
import type { DeriveEraPoints, DeriveEraValPoints } from '../types';
import { map, of, switchMap } from 'rxjs';
@@ -15,7 +16,7 @@ import { filterEras } from './util';
const CACHE_KEY = 'eraPoints';
function mapValidators ({ individual }: EraRewardPoints): DeriveEraValPoints {
function mapValidators ({ individual }: PalletStakingEraRewardPoints): DeriveEraValPoints {
return [...individual.entries()]
.filter(([, points]) => points.gt(BN_ZERO))
.reduce((result: DeriveEraValPoints, [validatorId, points]): DeriveEraValPoints => {
@@ -25,7 +26,7 @@ function mapValidators ({ individual }: EraRewardPoints): DeriveEraValPoints {
}, {});
}
function mapPoints (eras: EraIndex[], points: EraRewardPoints[]): DeriveEraPoints[] {
function mapPoints (eras: EraIndex[], points: PalletStakingEraRewardPoints[]): DeriveEraPoints[] {
return eras.map((era, index): DeriveEraPoints => ({
era,
eraPoints: points[index].total,
@@ -48,7 +49,7 @@ export function _erasPoints (instanceId: string, api: ApiInterfaceRx): (eras: Er
return !remaining.length
? of(cached)
: api.query.staking.erasRewardPoints.multi<EraRewardPoints>(remaining).pipe(
: api.query.staking.erasRewardPoints.multi(remaining).pipe(
map((points): DeriveEraPoints[] => {
const query = mapPoints(remaining, points);
+3 -2
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { StorageKey } from '@polkadot/types';
import type { EraIndex, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingValidatorPrefs } from '@polkadot/types/lookup';
import type { DeriveEraPrefs, DeriveEraValPrefs } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
@@ -13,7 +14,7 @@ import { deriveCache, memo } from '../util';
const CACHE_KEY = 'eraPrefs';
function mapPrefs (era: EraIndex, all: [StorageKey, ValidatorPrefs][]): DeriveEraPrefs {
function mapPrefs (era: EraIndex, all: [StorageKey, PalletStakingValidatorPrefs][]): DeriveEraPrefs {
const validators: DeriveEraValPrefs = {};
all.forEach(([key, prefs]): void => {
@@ -38,7 +38,7 @@ export function _erasRewards (instanceId: string, api: ApiInterfaceRx): (eras: E
return of(cached);
}
return api.query.staking.erasValidatorReward.multi<Option<Balance>>(remaining).pipe(
return api.query.staking.erasValidatorReward.multi(remaining).pipe(
map((optRewards) => {
const query = mapRewards(remaining, optRewards);
+13 -8
View File
@@ -4,7 +4,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option, Vec } from '@polkadot/types';
import type { AccountId, Keys } from '@polkadot/types/interfaces';
import type { AccountId } from '@polkadot/types/interfaces';
import type { NodeRuntimeSessionKeys } from '@polkadot/types/lookup';
import type { ITuple } from '@polkadot/types/types';
import type { DeriveStakingKeys } from './types';
@@ -12,13 +13,17 @@ import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
function extractsIds (stashId: Uint8Array | string, queuedKeys: [AccountId, Keys][], nextKeys: Option<Keys>): DeriveStakingKeys {
function extractsIds (stashId: Uint8Array | string, queuedKeys: [AccountId, NodeRuntimeSessionKeys | AccountId[]][], nextKeys: Option<NodeRuntimeSessionKeys>): DeriveStakingKeys {
const sessionIds = (queuedKeys.find(([currentId]) => currentId.eq(stashId)) || [undefined, [] as AccountId[]])[1];
const nextSessionIds = nextKeys.unwrapOr([] as AccountId[]);
return {
nextSessionIds,
sessionIds
nextSessionIds: Array.isArray(nextSessionIds)
? nextSessionIds
: [...nextSessionIds.values()] as AccountId[],
sessionIds: Array.isArray(sessionIds)
? sessionIds
: [...sessionIds.values()] as AccountId[]
};
}
@@ -33,13 +38,13 @@ export function keys (instanceId: string, api: ApiInterfaceRx): (stashId: Uint8A
export function keysMulti (instanceId: string, api: ApiInterfaceRx): (stashIds: (Uint8Array | string)[]) => Observable<DeriveStakingKeys[]> {
return memo(instanceId, (stashIds: (Uint8Array | string)[]): Observable<DeriveStakingKeys[]> =>
stashIds.length
? api.query.session.queuedKeys<Vec<ITuple<[AccountId, Keys]>>>().pipe(
switchMap((queuedKeys): Observable<[Vec<ITuple<[AccountId, Keys]>>, Option<Keys>[]]> =>
? api.query.session.queuedKeys().pipe(
switchMap((queuedKeys): Observable<[Vec<ITuple<[AccountId, NodeRuntimeSessionKeys]>>, Option<NodeRuntimeSessionKeys>[]]> =>
combineLatest([
of(queuedKeys),
api.consts.session?.dedupKeyPrefix
? api.query.session.nextKeys.multi<Option<Keys>>(stashIds.map((stashId) => [api.consts.session.dedupKeyPrefix, stashId]))
: api.query.session.nextKeys.multi<Option<Keys>>(stashIds)
? api.query.session.nextKeys.multi(stashIds.map((stashId) => [api.consts.session.dedupKeyPrefix, stashId]))
: api.query.session.nextKeys.multi(stashIds)
])
),
map(([queuedKeys, nextKeys]) =>
@@ -3,7 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
import type { EraIndex, Exposure } from '@polkadot/types/interfaces';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure } from '@polkadot/types/lookup';
import type { DeriveOwnExposure } from '../types';
import { map, of, switchMap } from 'rxjs';
@@ -14,7 +15,7 @@ export function _ownExposures (instanceId: string, api: ApiInterfaceRx): (accoun
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], _withActive: boolean): Observable<DeriveOwnExposure[]> =>
eras.length
? api.queryMulti<Exposure[]>([
? api.queryMulti<PalletStakingExposure[]>([
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakersClipped, [era, accountId]]),
...eras.map((era): QueryableStorageMultiArg<'rxjs'> => [api.query.staking.erasStakers, [era, accountId]])
]).pipe(
+18 -17
View File
@@ -4,14 +4,15 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { Option } from '@polkadot/types';
import type { AccountId, EraIndex, Exposure, Nominations, RewardDestination, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingExposure, PalletStakingNominations, PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs } from '@polkadot/types/lookup';
import type { DeriveStakingQuery, StakingQueryFlags } from '../types';
import { combineLatest, map, of, switchMap } from 'rxjs';
import { memo } from '../util';
function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<Nominations>, rewardDestination: RewardDestination, validatorPrefs: ValidatorPrefs, exposure: Exposure, stakingLedgerOpt: Option<StakingLedger>): DeriveStakingQuery {
function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<PalletStakingNominations>, rewardDestination: PalletStakingRewardDestination, validatorPrefs: PalletStakingValidatorPrefs, exposure: PalletStakingExposure, stakingLedgerOpt: Option<PalletStakingStakingLedger>): DeriveStakingQuery {
return {
accountId: stashId,
controllerId: controllerIdOpt && controllerIdOpt.unwrapOr(null),
@@ -26,21 +27,21 @@ function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> |
};
}
function getLedgers (api: ApiInterfaceRx, optIds: (Option<AccountId> | null)[], { withLedger = false }: StakingQueryFlags): Observable<Option<StakingLedger>[]> {
function getLedgers (api: ApiInterfaceRx, optIds: (Option<AccountId> | null)[], { withLedger = false }: StakingQueryFlags): Observable<Option<PalletStakingStakingLedger>[]> {
const ids = optIds
.filter((opt): opt is Option<AccountId> => withLedger && !!opt && opt.isSome)
.map((opt) => opt.unwrap());
const emptyLed = api.registry.createType('Option<StakingLedger>');
const emptyLed = api.registry.createType<Option<PalletStakingStakingLedger>>('Option<StakingLedger>');
return (
ids.length
? api.query.staking.ledger.multi<Option<StakingLedger>>(ids)
? api.query.staking.ledger.multi(ids)
: of([])
).pipe(
map((optLedgers): Option<StakingLedger>[] => {
map((optLedgers): Option<PalletStakingStakingLedger>[] => {
let offset = -1;
return optIds.map((opt): Option<StakingLedger> =>
return optIds.map((opt): Option<PalletStakingStakingLedger> =>
opt && opt.isSome
? optLedgers[++offset] || emptyLed
: emptyLed
@@ -49,27 +50,27 @@ function getLedgers (api: ApiInterfaceRx, optIds: (Option<AccountId> | null)[],
);
}
function getStashInfo (api: ApiInterfaceRx, stashIds: AccountId[], activeEra: EraIndex, { withController, withDestination, withExposure, withLedger, withNominations, withPrefs }: StakingQueryFlags): Observable<[(Option<AccountId> | null)[], Option<Nominations>[], RewardDestination[], ValidatorPrefs[], Exposure[]]> {
const emptyNoms = api.registry.createType('Option<Nominations>');
const emptyRewa = api.registry.createType('RewardDestination');
const emptyExpo = api.registry.createType('Exposure');
const emptyPrefs = api.registry.createType('ValidatorPrefs');
function getStashInfo (api: ApiInterfaceRx, stashIds: AccountId[], activeEra: EraIndex, { withController, withDestination, withExposure, withLedger, withNominations, withPrefs }: StakingQueryFlags): Observable<[(Option<AccountId> | null)[], Option<PalletStakingNominations>[], PalletStakingRewardDestination[], PalletStakingValidatorPrefs[], PalletStakingExposure[]]> {
const emptyNoms = api.registry.createType<Option<PalletStakingNominations>>('Option<Nominations>');
const emptyRewa = api.registry.createType<PalletStakingRewardDestination>('RewardDestination');
const emptyExpo = api.registry.createType<PalletStakingExposure>('Exposure');
const emptyPrefs = api.registry.createType<PalletStakingValidatorPrefs>('ValidatorPrefs');
return combineLatest([
withController || withLedger
? api.query.staking.bonded.multi<Option<AccountId>>(stashIds)
? api.query.staking.bonded.multi(stashIds)
: of(stashIds.map(() => null)),
withNominations
? api.query.staking.nominators.multi<Option<Nominations>>(stashIds)
? api.query.staking.nominators.multi(stashIds)
: of(stashIds.map(() => emptyNoms)),
withDestination
? api.query.staking.payee.multi<RewardDestination>(stashIds)
? api.query.staking.payee.multi(stashIds)
: of(stashIds.map(() => emptyRewa)),
withPrefs
? api.query.staking.validators.multi<ValidatorPrefs>(stashIds)
? api.query.staking.validators.multi(stashIds)
: of(stashIds.map(() => emptyPrefs)),
withExposure
? api.query.staking.erasStakers.multi<Exposure>(stashIds.map((stashId) => [activeEra, stashId]))
? api.query.staking.erasStakers.multi(stashIds.map((stashId) => [activeEra, stashId]))
: of(stashIds.map(() => emptyExpo))
]);
}
@@ -3,7 +3,7 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EraIndex, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { EraIndex } from '@polkadot/types/interfaces';
import type { DeriveStakerPrefs } from '../types';
import { map, switchMap } from 'rxjs';
@@ -13,7 +13,7 @@ import { memo } from '../util';
export function _stakerPrefs (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, eras: EraIndex[], withActive: boolean) => Observable<DeriveStakerPrefs[]> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return memo(instanceId, (accountId: Uint8Array | string, eras: EraIndex[], _withActive: boolean): Observable<DeriveStakerPrefs[]> =>
api.query.staking.erasValidatorPrefs.multi<ValidatorPrefs>(eras.map((era) => [era, accountId])).pipe(
api.query.staking.erasValidatorPrefs.multi(eras.map((era) => [era, accountId])).pipe(
map((all): DeriveStakerPrefs[] =>
all.map((validatorPrefs, index): DeriveStakerPrefs => ({
era: eras[index],
@@ -3,7 +3,8 @@
import type { Observable } from 'rxjs';
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, EraIndex, StakingLedger } from '@polkadot/types/interfaces';
import type { AccountId, EraIndex } from '@polkadot/types/interfaces';
import type { PalletStakingStakingLedger } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
import type { DeriveStakingQuery } from './types';
@@ -108,7 +109,7 @@ function removeClaimed (validators: string[], queryValidators: DeriveStakingQuer
});
}
function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][], { rewards, stakingLedger }: { rewards: DeriveStakerReward[]; stakingLedger: StakingLedger }): DeriveStakerReward[] {
function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][], { rewards, stakingLedger }: { rewards: DeriveStakerReward[]; stakingLedger: PalletStakingStakingLedger }): DeriveStakerReward[] {
const filter = eras.filter((era) => !stakingLedger.claimedRewards.some((e) => e.eq(era)));
const validators = valInfo.map(([v]) => v);
const queryValidators = valInfo.map(([, q]) => q);
+11 -10
View File
@@ -1,13 +1,14 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { AccountId, Balance, EraIndex, Exposure, RewardDestination, RewardPoint, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
import type { AccountId, Balance, EraIndex, RewardPoint } from '@polkadot/types/interfaces';
import type { PalletStakingExposure, PalletStakingRewardDestination, PalletStakingStakingLedger, PalletStakingValidatorPrefs } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
import type { DeriveSessionIndexes } from '../session/types';
export type DeriveEraValPoints = Record<string, RewardPoint>;
export type DeriveEraValPrefs = Record<string, ValidatorPrefs>;
export type DeriveEraValPrefs = Record<string, PalletStakingValidatorPrefs>;
export type DeriveEraValSlash = Record<string, Balance>;
@@ -40,9 +41,9 @@ export interface DeriveStakerPoints {
}
export interface DeriveOwnExposure {
clipped: Exposure;
clipped: PalletStakingExposure;
era: EraIndex;
exposure: Exposure;
exposure: PalletStakingExposure;
}
export interface DeriveEraExposureNominating {
@@ -52,7 +53,7 @@ export interface DeriveEraExposureNominating {
export type DeriveEraNominatorExposure = Record<string, DeriveEraExposureNominating[]>;
export type DeriveEraValidatorExposure = Record<string, Exposure>;
export type DeriveEraValidatorExposure = Record<string, PalletStakingExposure>;
export interface DeriveEraExposure {
era: EraIndex;
@@ -70,7 +71,7 @@ export interface DeriveStakerExposure {
export interface DeriveStakerPrefs {
era: EraIndex;
validatorPrefs: ValidatorPrefs;
validatorPrefs: PalletStakingValidatorPrefs;
}
export interface DeriveStakerRewardValidator {
@@ -106,16 +107,16 @@ export interface DeriveStakingValidators {
export interface DeriveStakingStash {
controllerId: AccountId | null;
exposure: Exposure;
exposure: PalletStakingExposure;
nominators: AccountId[];
rewardDestination: RewardDestination;
rewardDestination: PalletStakingRewardDestination;
stashId: AccountId;
validatorPrefs: ValidatorPrefs;
validatorPrefs: PalletStakingValidatorPrefs;
}
export interface DeriveStakingQuery extends DeriveStakingStash {
accountId: AccountId;
stakingLedger: StakingLedger;
stakingLedger: PalletStakingStakingLedger;
}
export interface DeriveStakingElected {
@@ -59,7 +59,7 @@ function retrieveProposals (api: ApiInterfaceRx, proposalCount: ProposalIndex, a
const allIds = [...proposalIds, ...approvalIds];
return combineLatest([
api.query.treasury.proposals.multi<Option<TreasuryProposal>>(allIds),
api.query.treasury.proposals.multi(allIds),
api.derive.council
? api.derive.council.proposals()
: of([] as DeriveCollectiveProposal[])
+5 -62
View File
@@ -2,52 +2,22 @@
// SPDX-License-Identifier: Apache-2.0
import type { u32 } from '@polkadot/types';
import type { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Bounty, BountyIndex, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VouchingStatus } from '@polkadot/types/interfaces';
import type { Balance, BlockNumber, BountyIndex, Hash, Proposal, ProposalIndex, SetIndex, TreasuryProposal, Votes } from '@polkadot/types/interfaces';
import type { PalletBountiesBounty } from '@polkadot/types/lookup';
import type { BN } from '@polkadot/util';
export * from './accounts/types';
export * from './balances/types';
export * from './council/types';
export * from './crowdloan/types';
export * from './democracy/types';
export * from './elections/types';
export * from './parachains/types';
export * from './session/types';
export * from './society/types';
export * from './staking/types';
export * from './type/types';
export interface DeriveBalancesAccountData {
freeBalance: Balance;
frozenFee: Balance;
frozenMisc: Balance;
reservedBalance: Balance;
votingBalance: Balance;
}
export interface DeriveBalancesAccount extends DeriveBalancesAccountData {
accountId: AccountId;
accountNonce: Index;
additional: DeriveBalancesAccountData[];
}
export interface DeriveBalancesAllAccountData extends DeriveBalancesAccountData {
availableBalance: Balance;
lockedBalance: Balance;
lockedBreakdown: (BalanceLock | BalanceLockTo212)[];
vestingLocked: Balance;
}
export interface DeriveBalancesAll extends DeriveBalancesAccount, DeriveBalancesAllAccountData {
additional: DeriveBalancesAllAccountData[];
isVesting: boolean;
vestedBalance: Balance;
vestedClaimable: Balance;
vestingEndBlock: BlockNumber;
vestingPerBlock: Balance;
vestingTotal: Balance;
}
export type DeriveBalancesMap = Record<string, DeriveBalancesAll>;
export interface DeriveContractFees {
callBaseFee: BN;
contractFee: BN;
@@ -90,33 +60,6 @@ export interface RecentlyOffline {
export type DeriveRecentlyOffline = Record<string, RecentlyOffline[]>;
export interface DeriveSociety {
bids: Bid[];
defender?: AccountId;
hasDefender: boolean;
head?: AccountId;
founder?: AccountId;
maxMembers: u32;
pot: BalanceOf;
}
export interface DeriveSocietyCandidate {
accountId: AccountId;
kind: BidKind;
value: Balance;
isSuspended: boolean;
}
export interface DeriveSocietyMember {
accountId: AccountId;
isDefenderVoter: boolean;
isSuspended: boolean;
payouts: [BlockNumber, Balance][];
strikes: StrikeCount;
vote?: SocietyVote;
vouching?: VouchingStatus;
}
export interface DeriveTreasuryProposal {
council: DeriveCollectiveProposal[];
id: ProposalIndex;
@@ -138,7 +81,7 @@ export interface VoterPosition {
export type DeriveVoterPositions = Record<string, VoterPosition>;
export interface DeriveBounty {
bounty: Bounty;
bounty: PalletBountiesBounty;
description: string;
index: BountyIndex;
proposals: DeriveCollectiveProposal[];
+1 -1
View File
@@ -3,7 +3,7 @@
import { ApiPromise, WsProvider } from '@polkadot/api';
import { Metadata, TypeRegistry } from '@polkadot/types';
import metaStatic from '@polkadot/types/metadata/static-substrate';
import metaStatic from '@polkadot/types-support/metadata/static-substrate';
export function createApiWithAugmentations (): ApiPromise {
const registry = new TypeRegistry();
+4 -4
View File
@@ -7,13 +7,13 @@ The API wrappers provide a standard interface for use -
- A static `.create(<optional ApiOptions>)` that returns an API instance when connected, decorated and ready-to use. ApiOptions can include an optional WsProvider and optional custom type definitions `{ provider: <Optional WsProvider>, types: <Optional RegistryTypes> }`.
- The above is just a wrapper for `new Api(<optional ApiOptions>) `, exposing the `isReady` getter
- `api.rpc.<section>.<method>` provides access to actual RPC calls, be it for queries, submission or retrieving chain information
- [RPC (node interface)](https://polkadot.js.org/docs/substrate/rpc.html)
- [RPC (node interface)](https://polkadot.js.org/docs/substrate/rpc)
- `api.query.<section>.<method>` provides access to chain state queries. These are dynamically populated based on what the runtime provides
- [Storage chain state (runtime node interface)](https://polkadot.js.org/docs/substrate/storage.html)
- [Storage chain state (runtime node interface)](https://polkadot.js.org/docs/substrate/storage)
- `api.tx.<section>.<method>` provides the ability to create a transaction, like chain state, this list is populated from a runtime query
- [Extrinsics (runtime node interface)](https://polkadot.js.org/docs/substrate/extrinsics.html)
- [Extrinsics (runtime node interface)](https://polkadot.js.org/docs/substrate/extrinsics)
- `api.consts.<section>.<constant>` provides access to the module constants (parameter types).
- [Constants (runtime node interface)](https://polkadot.js.org/docs/substrate/constants.html)
- [Constants (runtime node interface)](https://polkadot.js.org/docs/substrate/constants)
## API Selection
+11 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/api",
"version": "5.3.1",
"version": "6.2.1",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
@@ -19,16 +19,16 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/api-derive": "5.3.1",
"@polkadot/keyring": "^7.1.1",
"@polkadot/rpc-core": "5.3.1",
"@polkadot/rpc-provider": "5.3.1",
"@polkadot/types": "5.3.1",
"@polkadot/types-known": "5.3.1",
"@polkadot/util": "^7.1.1",
"@polkadot/util-crypto": "^7.1.1",
"@babel/runtime": "^7.15.4",
"@polkadot/api-derive": "6.2.1",
"@polkadot/keyring": "^7.4.1",
"@polkadot/rpc-core": "6.2.1",
"@polkadot/rpc-provider": "6.2.1",
"@polkadot/types": "6.2.1",
"@polkadot/types-known": "6.2.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"eventemitter3": "^4.0.7",
"rxjs": "^7.2.0"
"rxjs": "^7.3.0"
}
}
+229 -182
View File
@@ -1,17 +1,11 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable */
import type { Vec, bool, u16, u32, u64 } from '@polkadot/types';
import type { Codec } from '@polkadot/types/types';
import type { Schedule } from '@polkadot/types/interfaces/contracts';
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, TransactionPriority, Weight } from '@polkadot/types/interfaces/runtime';
import type { SessionIndex } from '@polkadot/types/interfaces/session';
import type { EraIndex } from '@polkadot/types/interfaces/staking';
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import type { BlockLength, BlockWeights } from '@polkadot/types/interfaces/system';
import type { DepositBalanceOf } from '@polkadot/types/interfaces/uniques';
import type { ApiTypes } from '@polkadot/api/types';
import type { U8aFixed, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types';
import type { Perbill, Percent, Permill } from '@polkadot/types/interfaces/runtime';
import type { FrameSupportPalletId, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, PalletContractsSchedule, SpVersionRuntimeVersion } from '@polkadot/types/lookup';
import type { Codec } from '@polkadot/types/types';
declare module '@polkadot/api/types/consts' {
export interface AugmentedConsts<ApiType> {
@@ -19,20 +13,20 @@ declare module '@polkadot/api/types/consts' {
/**
* The amount of funds that must be reserved when creating a new approval.
**/
approvalDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
approvalDeposit: u128 & AugmentedConst<ApiType>;
/**
* The basic amount of funds that must be reserved for an asset.
**/
assetDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
assetDeposit: u128 & AugmentedConst<ApiType>;
/**
* The basic amount of funds that must be reserved when adding metadata to your asset.
**/
metadataDepositBase: DepositBalanceOf & AugmentedConst<ApiType>;
metadataDepositBase: u128 & AugmentedConst<ApiType>;
/**
* The additional funds that must be reserved for the number of bytes you store in your
* metadata.
**/
metadataDepositPerByte: DepositBalanceOf & AugmentedConst<ApiType>;
metadataDepositPerByte: u128 & AugmentedConst<ApiType>;
/**
* The maximum length of a name or symbol stored on-chain.
**/
@@ -48,7 +42,7 @@ declare module '@polkadot/api/types/consts' {
* This means that we will deal with uncle-parents that are
* `UncleGenerations + 1` before `now`.
**/
uncleGenerations: BlockNumber & AugmentedConst<ApiType>;
uncleGenerations: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -68,7 +62,63 @@ declare module '@polkadot/api/types/consts' {
* duration and the security parameter `c` (where `1 - c` represents
* the probability of a slot being empty).
**/
expectedBlockTime: Moment & AugmentedConst<ApiType>;
expectedBlockTime: u64 & AugmentedConst<ApiType>;
/**
* Max number of authorities allowed
**/
maxAuthorities: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
bagsList: {
/**
* The list of thresholds separating the various bags.
*
* Ids are separated into unsorted bags according to their vote weight. This specifies the
* thresholds separating the bags. An id's bag is the largest bag for which the id's weight
* is less than or equal to its upper threshold.
*
* When ids are iterated, higher bags are iterated completely before lower bags. This means
* that iteration is _semi-sorted_: ids of higher weight tend to come before ids of lower
* weight, but peer ids within a particular bag are sorted in insertion order.
*
* # Expressing the constant
*
* This constant must be sorted in strictly increasing order. Duplicate items are not
* permitted.
*
* There is an implied upper limit of `VoteWeight::MAX`; that value does not need to be
* specified within the bag. For any two threshold lists, if one ends with
* `VoteWeight::MAX`, the other one does not, and they are otherwise equal, the two lists
* will behave identically.
*
* # Calculation
*
* It is recommended to generate the set of thresholds in a geometric series, such that
* there exists some constant ratio such that `threshold[k + 1] == (threshold[k] *
* constant_ratio).max(threshold[k] + 1)` for all `k`.
*
* The helpers in the `/utils/frame/generate-bags` module can simplify this calculation.
*
* # Examples
*
* - If `BagThresholds::get().is_empty()`, then all ids are put into the same bag, and
* iteration is strictly in insertion order.
* - If `BagThresholds::get().len() == 64`, and the thresholds are determined according to
* the procedure given above, then the constant ratio is equal to 2.
* - If `BagThresholds::get().len() == 200`, and the thresholds are determined according to
* the procedure given above, then the constant ratio is approximately equal to 1.248.
* - If the threshold list begins `[1, 2, 3, ...]`, then an id with weight 0 or 1 will fall
* into bag 0, an id with weight 2 will fall into bag 1, etc.
*
* # Migration
*
* In the event that this list ever changes, a copy of the old bags list must be retained.
* With that `List::migrate` can be called, which will perform the appropriate migration.
**/
bagThresholds: Vec<u64> & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -78,7 +128,7 @@ declare module '@polkadot/api/types/consts' {
/**
* The minimum amount required to keep an account open.
**/
existentialDeposit: Balance & AugmentedConst<ApiType>;
existentialDeposit: u128 & AugmentedConst<ApiType>;
/**
* The maximum number of locks that should exist on an account.
* Not strictly enforced, but used for weight estimation.
@@ -95,29 +145,30 @@ declare module '@polkadot/api/types/consts' {
};
bounties: {
/**
* Percentage of the curator fee that will be reserved upfront as deposit for bounty curator.
* Percentage of the curator fee that will be reserved upfront as deposit for bounty
* curator.
**/
bountyCuratorDeposit: Permill & AugmentedConst<ApiType>;
/**
* The amount held on deposit for placing a bounty proposal.
**/
bountyDepositBase: BalanceOf & AugmentedConst<ApiType>;
bountyDepositBase: u128 & AugmentedConst<ApiType>;
/**
* The delay period for which a bounty beneficiary need to wait before claim the payout.
**/
bountyDepositPayoutDelay: BlockNumber & AugmentedConst<ApiType>;
bountyDepositPayoutDelay: u32 & AugmentedConst<ApiType>;
/**
* Bounty duration in blocks.
**/
bountyUpdatePeriod: BlockNumber & AugmentedConst<ApiType>;
bountyUpdatePeriod: u32 & AugmentedConst<ApiType>;
/**
* Minimum value for a bounty.
**/
bountyValueMinimum: BalanceOf & AugmentedConst<ApiType>;
bountyValueMinimum: u128 & AugmentedConst<ApiType>;
/**
* The amount held on deposit per byte within bounty description.
* The amount held on deposit per byte within the tip report reason or bounty description.
**/
dataDepositPerByte: BalanceOf & AugmentedConst<ApiType>;
dataDepositPerByte: u128 & AugmentedConst<ApiType>;
/**
* Maximum acceptable reason length.
**/
@@ -128,6 +179,13 @@ declare module '@polkadot/api/types/consts' {
[key: string]: Codec;
};
contracts: {
/**
* The deposit that must be placed into the contract's account to instantiate it.
* This is in **addition** to the [`pallet_balances::Pallet::ExistenialDeposit`].
* The minimum balance for a contract's account can be queried using
* [`Pallet::subsistence_threshold`].
**/
contractDeposit: u128 & AugmentedConst<ApiType>;
/**
* The maximum number of tries that can be queued for deletion.
**/
@@ -135,61 +193,11 @@ declare module '@polkadot/api/types/consts' {
/**
* The maximum amount of weight that can be consumed per block for lazy trie removal.
**/
deletionWeightLimit: Weight & AugmentedConst<ApiType>;
/**
* The balance every contract needs to deposit to stay alive indefinitely.
*
* This is different from the [`Self::TombstoneDeposit`] because this only needs to be
* deposited while the contract is alive. Costs for additional storage are added to
* this base cost.
*
* This is a simple way to ensure that contracts with empty storage eventually get deleted by
* making them pay rent. This creates an incentive to remove them early in order to save rent.
**/
depositPerContract: BalanceOf & AugmentedConst<ApiType>;
/**
* The balance a contract needs to deposit per storage byte to stay alive indefinitely.
*
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
* then it would pay 500 BU/day.
**/
depositPerStorageByte: BalanceOf & AugmentedConst<ApiType>;
/**
* The balance a contract needs to deposit per storage item to stay alive indefinitely.
*
* It works the same as [`Self::DepositPerStorageByte`] but for storage items.
**/
depositPerStorageItem: BalanceOf & AugmentedConst<ApiType>;
/**
* The fraction of the deposit that should be used as rent per block.
*
* When a contract hasn't enough balance deposited to stay alive indefinitely it needs
* to pay per block for the storage it consumes that is not covered by the deposit.
* This determines how high this rent payment is per block as a fraction of the deposit.
**/
rentFraction: Perbill & AugmentedConst<ApiType>;
deletionWeightLimit: u64 & AugmentedConst<ApiType>;
/**
* Cost schedule and limits.
**/
schedule: Schedule & AugmentedConst<ApiType>;
/**
* Number of block delay an extrinsic claim surcharge has.
*
* When claim surcharge is called by an extrinsic the rent is checked
* for current_block - delay
**/
signedClaimHandicap: BlockNumber & AugmentedConst<ApiType>;
/**
* Reward that is received by the party whose touch has led
* to removal of a contract.
**/
surchargeReward: BalanceOf & AugmentedConst<ApiType>;
/**
* The minimum amount required to generate a tombstone.
**/
tombstoneDeposit: BalanceOf & AugmentedConst<ApiType>;
schedule: PalletContractsSchedule & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -199,29 +207,29 @@ declare module '@polkadot/api/types/consts' {
/**
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
**/
cooloffPeriod: BlockNumber & AugmentedConst<ApiType>;
cooloffPeriod: u32 & AugmentedConst<ApiType>;
/**
* The minimum period of locking and the period between a proposal being approved and enacted.
* The period between a proposal being approved and enacted.
*
* It should generally be a little more than the unstake period to ensure that
* voting stakers have an opportunity to remove themselves from the system in the case where
* they are on the losing side of a vote.
* voting stakers have an opportunity to remove themselves from the system in the case
* where they are on the losing side of a vote.
**/
enactmentPeriod: BlockNumber & AugmentedConst<ApiType>;
enactmentPeriod: u32 & AugmentedConst<ApiType>;
/**
* Minimum voting period allowed for a fast-track referendum.
**/
fastTrackVotingPeriod: BlockNumber & AugmentedConst<ApiType>;
fastTrackVotingPeriod: u32 & AugmentedConst<ApiType>;
/**
* Indicator for whether an emergency origin is even allowed to happen. Some chains may want
* to set this permanently to `false`, others may want to condition it on things such as
* an upgrade having happened recently.
* Indicator for whether an emergency origin is even allowed to happen. Some chains may
* want to set this permanently to `false`, others may want to condition it on things such
* as an upgrade having happened recently.
**/
instantAllowed: bool & AugmentedConst<ApiType>;
/**
* How often (in blocks) new public referenda are launched.
**/
launchPeriod: BlockNumber & AugmentedConst<ApiType>;
launchPeriod: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of public proposals that can exist at any time.
**/
@@ -236,26 +244,28 @@ declare module '@polkadot/api/types/consts' {
/**
* The minimum amount to be used as a deposit for a public referendum proposal.
**/
minimumDeposit: BalanceOf & AugmentedConst<ApiType>;
minimumDeposit: u128 & AugmentedConst<ApiType>;
/**
* The amount of balance that must be deposited per byte of preimage stored.
**/
preimageByteDeposit: BalanceOf & AugmentedConst<ApiType>;
preimageByteDeposit: u128 & AugmentedConst<ApiType>;
/**
* The minimum period of vote locking.
*
* It should be no shorter than enactment period to ensure that in the case of an approval,
* those successful voters are locked into the consequences that their votes entail.
**/
voteLockingPeriod: u32 & AugmentedConst<ApiType>;
/**
* How often (in blocks) to check for new votes.
**/
votingPeriod: BlockNumber & AugmentedConst<ApiType>;
votingPeriod: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
electionProviderMultiPhase: {
/**
* Maximum number of iteration of balancing that will be executed in the embedded miner of
* the pallet.
**/
minerMaxIterations: u32 & AugmentedConst<ApiType>;
/**
* Maximum length (bytes) that the mined solution should consume.
*
@@ -269,30 +279,30 @@ declare module '@polkadot/api/types/consts' {
* The miner will ensure that the total weight of the unsigned solution will not exceed
* this value, based on [`WeightInfo::submit_unsigned`].
**/
minerMaxWeight: Weight & AugmentedConst<ApiType>;
minerMaxWeight: u64 & AugmentedConst<ApiType>;
/**
* The priority of the unsigned transaction submitted in the unsigned-phase
**/
minerTxPriority: TransactionPriority & AugmentedConst<ApiType>;
minerTxPriority: u64 & AugmentedConst<ApiType>;
/**
* The repeat threshold of the offchain worker.
*
* For example, if it is 5, that means that at least 5 blocks will elapse between attempts
* to submit the worker's solution.
**/
offchainRepeat: BlockNumber & AugmentedConst<ApiType>;
offchainRepeat: u32 & AugmentedConst<ApiType>;
/**
* Base deposit for a signed solution.
**/
signedDepositBase: BalanceOf & AugmentedConst<ApiType>;
signedDepositBase: u128 & AugmentedConst<ApiType>;
/**
* Per-byte deposit for a signed solution.
**/
signedDepositByte: BalanceOf & AugmentedConst<ApiType>;
signedDepositByte: u128 & AugmentedConst<ApiType>;
/**
* Per-weight deposit for a signed solution.
**/
signedDepositWeight: BalanceOf & AugmentedConst<ApiType>;
signedDepositWeight: u128 & AugmentedConst<ApiType>;
/**
* Maximum number of signed submissions that can be queued.
*
@@ -308,15 +318,15 @@ declare module '@polkadot/api/types/consts' {
*
* This should probably be similar to [`Config::MinerMaxWeight`].
**/
signedMaxWeight: Weight & AugmentedConst<ApiType>;
signedMaxWeight: u64 & AugmentedConst<ApiType>;
/**
* Duration of the signed phase.
**/
signedPhase: BlockNumber & AugmentedConst<ApiType>;
signedPhase: u32 & AugmentedConst<ApiType>;
/**
* Base reward for a signed solution
**/
signedRewardBase: BalanceOf & AugmentedConst<ApiType>;
signedRewardBase: u128 & AugmentedConst<ApiType>;
/**
* The minimum amount of improvement to the solution score that defines a solution as
* "better" (in any phase).
@@ -325,7 +335,16 @@ declare module '@polkadot/api/types/consts' {
/**
* Duration of the unsigned phase.
**/
unsignedPhase: BlockNumber & AugmentedConst<ApiType>;
unsignedPhase: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of voters to put in the snapshot. At the moment, snapshots are only
* over a single block, but once multi-block elections are introduced they will take place
* over multiple blocks.
*
* Also, note the data type: If the voters are represented by a `u32` in `type
* CompactSolution`, the same `u32` is used here to ensure bounds are respected.
**/
voterSnapshotPerBlock: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -335,7 +354,7 @@ declare module '@polkadot/api/types/consts' {
/**
* How much should be locked up in order to submit one's candidacy.
**/
candidacyBond: BalanceOf & AugmentedConst<ApiType>;
candidacyBond: u128 & AugmentedConst<ApiType>;
/**
* Number of members to elect.
**/
@@ -347,24 +366,24 @@ declare module '@polkadot/api/types/consts' {
/**
* Identifier for the elections-phragmen pallet's lock
**/
palletId: LockIdentifier & AugmentedConst<ApiType>;
palletId: U8aFixed & AugmentedConst<ApiType>;
/**
* How long each seat is kept. This defines the next block number at which an election
* round will happen. If set to zero, no elections are ever triggered and the module will
* be in passive mode.
**/
termDuration: BlockNumber & AugmentedConst<ApiType>;
termDuration: u32 & AugmentedConst<ApiType>;
/**
* Base deposit associated with voting.
*
* This should be sensibly high to economically ensure the pallet cannot be attacked by
* creating a gigantic number of votes.
**/
votingBondBase: BalanceOf & AugmentedConst<ApiType>;
votingBondBase: u128 & AugmentedConst<ApiType>;
/**
* The amount of bond that need to be locked for each vote (32 bytes).
**/
votingBondFactor: BalanceOf & AugmentedConst<ApiType>;
votingBondFactor: u128 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -381,7 +400,7 @@ declare module '@polkadot/api/types/consts' {
* The issuance to ignore. This is subtracted from the `Currency`'s `total_issuance` to get
* the issuance by which we inflate or deflate the gilt.
**/
ignoredIssuance: BalanceOf & AugmentedConst<ApiType>;
ignoredIssuance: u128 & AugmentedConst<ApiType>;
/**
* The number of blocks between consecutive attempts to issue more gilts in an effort to
* get to the target amount to be frozen.
@@ -389,7 +408,7 @@ declare module '@polkadot/api/types/consts' {
* A larger value results in fewer storage hits each block, but a slower period to get to
* the target.
**/
intakePeriod: BlockNumber & AugmentedConst<ApiType>;
intakePeriod: u32 & AugmentedConst<ApiType>;
/**
* The maximum amount of bids that can be turned into issued gilts each block. A larger
* value here means less of the block available for transactions should there be a glut of
@@ -408,12 +427,12 @@ declare module '@polkadot/api/types/consts' {
* It should be at least big enough to ensure that there is no possible storage spam attack
* or queue-filling attack.
**/
minFreeze: BalanceOf & AugmentedConst<ApiType>;
minFreeze: u128 & AugmentedConst<ApiType>;
/**
* The base period for the duration queues. This is the common multiple across all
* supported freezing durations that can be bid upon.
**/
period: BlockNumber & AugmentedConst<ApiType>;
period: u32 & AugmentedConst<ApiType>;
/**
* Number of duration queues in total. This sets the maximum duration supported, which is
* this value multiplied by `Period`.
@@ -424,15 +443,25 @@ declare module '@polkadot/api/types/consts' {
**/
[key: string]: Codec;
};
grandpa: {
/**
* Max Authorities in use
**/
maxAuthorities: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
identity: {
/**
* The amount held on deposit for a registered identity
**/
basicDeposit: BalanceOf & AugmentedConst<ApiType>;
basicDeposit: u128 & AugmentedConst<ApiType>;
/**
* The amount held on deposit per additional field for a registered identity.
**/
fieldDeposit: BalanceOf & AugmentedConst<ApiType>;
fieldDeposit: u128 & AugmentedConst<ApiType>;
/**
* Maximum number of additional fields that may be stored in an ID. Needed to bound the I/O
* required to access an identity, but can be pretty high.
@@ -449,10 +478,10 @@ declare module '@polkadot/api/types/consts' {
maxSubAccounts: u32 & AugmentedConst<ApiType>;
/**
* The amount held on deposit for a registered subaccount. This should account for the fact
* that one storage item's value will increase by the size of an account ID, and there will be
* another trie item whose value is the size of an account ID plus 32 bytes.
* that one storage item's value will increase by the size of an account ID, and there will
* be another trie item whose value is the size of an account ID plus 32 bytes.
**/
subAccountDeposit: BalanceOf & AugmentedConst<ApiType>;
subAccountDeposit: u128 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -465,7 +494,7 @@ declare module '@polkadot/api/types/consts' {
* This is exposed so that it can be tuned for particular runtime, when
* multiple pallets send unsigned transactions.
**/
unsignedPriority: TransactionPriority & AugmentedConst<ApiType>;
unsignedPriority: u64 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -475,7 +504,7 @@ declare module '@polkadot/api/types/consts' {
/**
* The deposit needed for reserving an index.
**/
deposit: BalanceOf & AugmentedConst<ApiType>;
deposit: u128 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -495,7 +524,7 @@ declare module '@polkadot/api/types/consts' {
/**
* The Lottery's pallet id
**/
palletId: PalletId & AugmentedConst<ApiType>;
palletId: FrameSupportPalletId & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -503,20 +532,20 @@ declare module '@polkadot/api/types/consts' {
};
multisig: {
/**
* The base amount of currency needed to reserve for creating a multisig execution or to store
* a dispatch call for later.
* The base amount of currency needed to reserve for creating a multisig execution or to
* store a dispatch call for later.
*
* This is held for an additional storage item whose value size is
* `4 + sizeof((BlockNumber, Balance, AccountId))` bytes and whose key size is
* `32 + sizeof(AccountId)` bytes.
**/
depositBase: BalanceOf & AugmentedConst<ApiType>;
depositBase: u128 & AugmentedConst<ApiType>;
/**
* The amount of currency needed per unit threshold when creating a multisig execution.
*
* This is held for adding 32 bytes more into a pre-existing storage value.
**/
depositFactor: BalanceOf & AugmentedConst<ApiType>;
depositFactor: u128 & AugmentedConst<ApiType>;
/**
* The maximum amount of signatories allowed in the multisig.
**/
@@ -530,16 +559,17 @@ declare module '@polkadot/api/types/consts' {
/**
* The base amount of currency needed to reserve for creating an announcement.
*
* This is held when a new storage item holding a `Balance` is created (typically 16 bytes).
* This is held when a new storage item holding a `Balance` is created (typically 16
* bytes).
**/
announcementDepositBase: BalanceOf & AugmentedConst<ApiType>;
announcementDepositBase: u128 & AugmentedConst<ApiType>;
/**
* The amount of currency needed per announcement made.
*
* This is held for adding an `AccountId`, `Hash` and `BlockNumber` (typically 68 bytes)
* into a pre-existing storage value.
**/
announcementDepositFactor: BalanceOf & AugmentedConst<ApiType>;
announcementDepositFactor: u128 & AugmentedConst<ApiType>;
/**
* The maximum amount of time-delayed announcements that are allowed to be pending.
**/
@@ -554,15 +584,15 @@ declare module '@polkadot/api/types/consts' {
* This is held for an additional storage item whose value size is
* `sizeof(Balance)` bytes and whose key size is `sizeof(AccountId)` bytes.
**/
proxyDepositBase: BalanceOf & AugmentedConst<ApiType>;
proxyDepositBase: u128 & AugmentedConst<ApiType>;
/**
* The amount of currency needed per proxy added.
*
* This is held for adding 32 bytes plus an instance of `ProxyType` more into a pre-existing
* storage value. Thus, when configuring `ProxyDepositFactor` one should take into account
* `32 + proxy_type.encode().len()` bytes of data.
* This is held for adding 32 bytes plus an instance of `ProxyType` more into a
* pre-existing storage value. Thus, when configuring `ProxyDepositFactor` one should take
* into account `32 + proxy_type.encode().len()` bytes of data.
**/
proxyDepositFactor: BalanceOf & AugmentedConst<ApiType>;
proxyDepositFactor: u128 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -575,13 +605,15 @@ declare module '@polkadot/api/types/consts' {
* This is held for an additional storage item whose value size is
* `2 + sizeof(BlockNumber, Balance)` bytes.
**/
configDepositBase: BalanceOf & AugmentedConst<ApiType>;
configDepositBase: u128 & AugmentedConst<ApiType>;
/**
* The amount of currency needed per additional user when creating a recovery configuration.
* The amount of currency needed per additional user when creating a recovery
* configuration.
*
* This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage value.
* This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage
* value.
**/
friendDepositFactor: BalanceOf & AugmentedConst<ApiType>;
friendDepositFactor: u128 & AugmentedConst<ApiType>;
/**
* The maximum amount of friends allowed in a recovery configuration.
**/
@@ -595,7 +627,7 @@ declare module '@polkadot/api/types/consts' {
* `sizeof(BlockNumber, Balance + T * AccountId)` bytes. Where T is a configurable
* threshold.
**/
recoveryDeposit: BalanceOf & AugmentedConst<ApiType>;
recoveryDeposit: u128 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -603,10 +635,10 @@ declare module '@polkadot/api/types/consts' {
};
scheduler: {
/**
* The maximum weight that may be scheduled per block for any dispatchables of less priority
* than `schedule::HARD_DEADLINE`.
* The maximum weight that may be scheduled per block for any dispatchables of less
* priority than `schedule::HARD_DEADLINE`.
**/
maximumWeight: Weight & AugmentedConst<ApiType>;
maximumWeight: u64 & AugmentedConst<ApiType>;
/**
* The maximum number of scheduled calls in the queue for a single block.
* Not strictly enforced, but used for weight estimation.
@@ -621,37 +653,41 @@ declare module '@polkadot/api/types/consts' {
/**
* The minimum amount of a deposit required for a bid to be made.
**/
candidateDeposit: BalanceOf & AugmentedConst<ApiType>;
candidateDeposit: u128 & AugmentedConst<ApiType>;
/**
* The number of blocks between membership challenges.
**/
challengePeriod: BlockNumber & AugmentedConst<ApiType>;
challengePeriod: u32 & AugmentedConst<ApiType>;
/**
* Maximum candidate intake per round.
* The maximum number of candidates that we accept per round.
**/
maxCandidateIntake: u32 & AugmentedConst<ApiType>;
/**
* The number of times a member may vote the wrong way (or not at all, when they are a skeptic)
* before they become suspended.
* The maximum duration of the payout lock.
**/
maxLockDuration: u32 & AugmentedConst<ApiType>;
/**
* The number of times a member may vote the wrong way (or not at all, when they are a
* skeptic) before they become suspended.
**/
maxStrikes: u32 & AugmentedConst<ApiType>;
/**
* The societies's module id
* The societies's pallet id
**/
palletId: PalletId & AugmentedConst<ApiType>;
palletId: FrameSupportPalletId & AugmentedConst<ApiType>;
/**
* The amount of incentive paid within each period. Doesn't include VoterTip.
**/
periodSpend: BalanceOf & AugmentedConst<ApiType>;
periodSpend: u128 & AugmentedConst<ApiType>;
/**
* The number of blocks between candidate/membership rotation periods.
**/
rotationPeriod: BlockNumber & AugmentedConst<ApiType>;
rotationPeriod: u32 & AugmentedConst<ApiType>;
/**
* The amount of the unpaid reward that gets deducted in the case that either a skeptic
* doesn't vote or someone votes in the wrong way.
**/
wrongSideDeduction: BalanceOf & AugmentedConst<ApiType>;
wrongSideDeduction: u128 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -661,26 +697,26 @@ declare module '@polkadot/api/types/consts' {
/**
* Number of eras that staked funds must remain bonded for.
**/
bondingDuration: EraIndex & AugmentedConst<ApiType>;
bondingDuration: u32 & AugmentedConst<ApiType>;
maxNominations: u32 & AugmentedConst<ApiType>;
/**
* The maximum number of nominators rewarded for each validator.
*
* For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim
* their reward. This used to limit the i/o cost for the nominator payout.
* For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can
* claim their reward. This used to limit the i/o cost for the nominator payout.
**/
maxNominatorRewardedPerValidator: u32 & AugmentedConst<ApiType>;
/**
* Number of sessions per era.
**/
sessionsPerEra: SessionIndex & AugmentedConst<ApiType>;
sessionsPerEra: u32 & AugmentedConst<ApiType>;
/**
* Number of eras that slashes are deferred by, after computation.
*
* This should be less than the bonding duration. Set to 0 if slashes
* should be applied immediately, without opportunity for intervention.
**/
slashDeferDuration: EraIndex & AugmentedConst<ApiType>;
slashDeferDuration: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -690,19 +726,19 @@ declare module '@polkadot/api/types/consts' {
/**
* Maximum number of block number to block hash mappings to keep (oldest pruned first).
**/
blockHashCount: BlockNumber & AugmentedConst<ApiType>;
blockHashCount: u32 & AugmentedConst<ApiType>;
/**
* The maximum length of a block (in bytes).
**/
blockLength: BlockLength & AugmentedConst<ApiType>;
blockLength: FrameSystemLimitsBlockLength & AugmentedConst<ApiType>;
/**
* Block & extrinsics weights: base values and limits.
**/
blockWeights: BlockWeights & AugmentedConst<ApiType>;
blockWeights: FrameSystemLimitsBlockWeights & AugmentedConst<ApiType>;
/**
* The weight of runtime database operations the runtime can invoke.
**/
dbWeight: RuntimeDbWeight & AugmentedConst<ApiType>;
dbWeight: FrameSupportWeightsRuntimeDbWeight & AugmentedConst<ApiType>;
/**
* The designated SS85 prefix of this chain.
*
@@ -714,7 +750,7 @@ declare module '@polkadot/api/types/consts' {
/**
* Get the chain's current version.
**/
version: RuntimeVersion & AugmentedConst<ApiType>;
version: SpVersionRuntimeVersion & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -722,12 +758,12 @@ declare module '@polkadot/api/types/consts' {
};
timestamp: {
/**
* The minimum period between blocks. Beware that this is different to the *expected* period
* that the block production apparatus provides. Your chosen consensus system will generally
* work with this to determine a sensible block time. e.g. For Aura, it will be double this
* period on default settings.
* The minimum period between blocks. Beware that this is different to the *expected*
* period that the block production apparatus provides. Your chosen consensus system will
* generally work with this to determine a sensible block time. e.g. For Aura, it will be
* double this period on default settings.
**/
minimumPeriod: Moment & AugmentedConst<ApiType>;
minimumPeriod: u64 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -735,9 +771,9 @@ declare module '@polkadot/api/types/consts' {
};
tips: {
/**
* The amount held on deposit per byte within the tip report reason.
* The amount held on deposit per byte within the tip report reason or bounty description.
**/
dataDepositPerByte: BalanceOf & AugmentedConst<ApiType>;
dataDepositPerByte: u128 & AugmentedConst<ApiType>;
/**
* Maximum acceptable reason length.
**/
@@ -745,15 +781,15 @@ declare module '@polkadot/api/types/consts' {
/**
* The period for which a tip remains open after is has achieved threshold tippers.
**/
tipCountdown: BlockNumber & AugmentedConst<ApiType>;
tipCountdown: u32 & AugmentedConst<ApiType>;
/**
* The amount of the final tip which goes to the original reporter of the tip.
* The percent of the final tip which goes to the original reporter of the tip.
**/
tipFindersFee: Percent & AugmentedConst<ApiType>;
/**
* The amount held on deposit for placing a tip report.
**/
tipReportDepositBase: BalanceOf & AugmentedConst<ApiType>;
tipReportDepositBase: u128 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -763,11 +799,11 @@ declare module '@polkadot/api/types/consts' {
/**
* The fee to be paid for making a transaction; the per-byte portion.
**/
transactionByteFee: BalanceOf & AugmentedConst<ApiType>;
transactionByteFee: u128 & AugmentedConst<ApiType>;
/**
* The polynomial that is applied in order to derive fee from weight.
**/
weightToFee: Vec<WeightToFeeCoefficient> & AugmentedConst<ApiType>;
weightToFee: Vec<FrameSupportWeightsWeightToFeeCoefficient> & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -785,7 +821,7 @@ declare module '@polkadot/api/types/consts' {
/**
* The treasury's pallet id, used for deriving its sovereign account ID.
**/
palletId: PalletId & AugmentedConst<ApiType>;
palletId: FrameSupportPalletId & AugmentedConst<ApiType>;
/**
* Fraction of a proposal's value that should be bonded in order to place the proposal.
* An accepted proposal gets these back. A rejected proposal does not.
@@ -794,11 +830,11 @@ declare module '@polkadot/api/types/consts' {
/**
* Minimum amount of funds that should be placed in a deposit for making a proposal.
**/
proposalBondMinimum: BalanceOf & AugmentedConst<ApiType>;
proposalBondMinimum: u128 & AugmentedConst<ApiType>;
/**
* Period between successive spends.
**/
spendPeriod: BlockNumber & AugmentedConst<ApiType>;
spendPeriod: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
@@ -808,20 +844,20 @@ declare module '@polkadot/api/types/consts' {
/**
* The basic amount of funds that must be reserved when adding an attribute to an asset.
**/
attributeDepositBase: DepositBalanceOf & AugmentedConst<ApiType>;
attributeDepositBase: u128 & AugmentedConst<ApiType>;
/**
* The basic amount of funds that must be reserved for an asset class.
**/
classDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
classDeposit: u128 & AugmentedConst<ApiType>;
/**
* The additional funds that must be reserved for the number of bytes store in metadata,
* either "normal" metadata or attribute metadata.
**/
depositPerByte: DepositBalanceOf & AugmentedConst<ApiType>;
depositPerByte: u128 & AugmentedConst<ApiType>;
/**
* The basic amount of funds that must be reserved for an asset instance.
**/
instanceDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
instanceDeposit: u128 & AugmentedConst<ApiType>;
/**
* The maximum length of an attribute key.
**/
@@ -829,7 +865,7 @@ declare module '@polkadot/api/types/consts' {
/**
* The basic amount of funds that must be reserved when adding metadata to your asset.
**/
metadataDepositBase: DepositBalanceOf & AugmentedConst<ApiType>;
metadataDepositBase: u128 & AugmentedConst<ApiType>;
/**
* The maximum length of data stored on-chain.
**/
@@ -843,11 +879,22 @@ declare module '@polkadot/api/types/consts' {
**/
[key: string]: Codec;
};
utility: {
/**
* The limit on the number of batched calls.
**/
batchedCallsLimit: u32 & AugmentedConst<ApiType>;
/**
* Generic const
**/
[key: string]: Codec;
};
vesting: {
maxVestingSchedules: u32 & AugmentedConst<ApiType>;
/**
* The minimum amount transferred to call `vested_transfer`.
**/
minVestedTransfer: BalanceOf & AugmentedConst<ApiType>;
minVestedTransfer: u128 & AugmentedConst<ApiType>;
/**
* Generic const
**/
+34 -78
View File
@@ -39,7 +39,8 @@ declare module '@polkadot/api/types/errors' {
**/
NoPermission: AugmentedError<ApiType>;
/**
* No provider reference exists to allow a non-zero balance of a non-self-sufficient asset.
* No provider reference exists to allow a non-zero balance of a non-self-sufficient
* asset.
**/
NoProvider: AugmentedError<ApiType>;
/**
@@ -195,9 +196,8 @@ declare module '@polkadot/api/types/errors' {
contracts: {
/**
* Performing the requested transfer would have brought the contract below
* the subsistence threshold. No transfer is allowed to do this in order to allow
* for a tombstone to be created. Use `seal_terminate` to remove a contract without
* leaving a tombstone behind.
* the subsistence threshold. No transfer is allowed to do this. Use `seal_terminate`
* to recover a deposit.
**/
BelowSubsistenceThreshold: AugmentedError<ApiType>;
/**
@@ -209,20 +209,6 @@ declare module '@polkadot/api/types/errors' {
* current schedule.
**/
CodeTooLarge: AugmentedError<ApiType>;
/**
* A tombstone exist at the specified address.
*
* Tombstone cannot be called. Anyone can use `seal_restore_to` in order to revive
* the contract, though.
**/
ContractIsTombstone: AugmentedError<ApiType>;
/**
* A contract could not be evicted because it has enough balance to pay rent.
*
* This can be returned from [`Pallet::claim_surcharge`] because the target
* contract has enough balance to pay for its rent.
**/
ContractNotEvictable: AugmentedError<ApiType>;
/**
* No contract was found at the specified address.
**/
@@ -242,7 +228,7 @@ declare module '@polkadot/api/types/errors' {
/**
* Removal of a contract failed because the deletion queue is full.
*
* This can happen when either calling [`Pallet::claim_surcharge`] or `seal_terminate`.
* This can happen when calling `seal_terminate`.
* The queue is filled by deleting contracts and emptied by a fixed amount each block.
* Trying again during another block is the only way to resolve this issue.
**/
@@ -259,30 +245,10 @@ declare module '@polkadot/api/types/errors' {
* `seal_call` forwarded this contracts input. It therefore is no longer available.
**/
InputForwarded: AugmentedError<ApiType>;
/**
* An origin TrieId written in the current block.
**/
InvalidContractOrigin: AugmentedError<ApiType>;
/**
* Cannot restore to nonexisting or alive contract.
**/
InvalidDestinationContract: AugmentedError<ApiType>;
/**
* A new schedule must have a greater version than the current one.
**/
InvalidScheduleVersion: AugmentedError<ApiType>;
/**
* Cannot restore from nonexisting or tombstone contract.
**/
InvalidSourceContract: AugmentedError<ApiType>;
/**
* An origin must be signed or inherent and auxiliary sender only provided on inherent.
**/
InvalidSurchargeClaim: AugmentedError<ApiType>;
/**
* Tombstones don't match.
**/
InvalidTombstone: AugmentedError<ApiType>;
/**
* Performing a call was denied because the calling depth reached the limit
* of what is specified in the schedule.
@@ -319,15 +285,6 @@ declare module '@polkadot/api/types/errors' {
* A call tried to invoke a contract that is flagged as non-reentrant.
**/
ReentranceDenied: AugmentedError<ApiType>;
/**
* The called contract does not have enough balance to pay for its storage.
*
* The contract ran out of balance and is therefore eligible for eviction into a
* tombstone. Anyone can evict the contract by submitting a `claim_surcharge`
* extrinsic. Alternatively, a plain balance transfer can be used in order to
* increase the contracts funds so that it can be called again.
**/
RentNotPaid: AugmentedError<ApiType>;
/**
* A storage modification exhausted the 32bit type that holds the storage size.
*
@@ -338,12 +295,12 @@ declare module '@polkadot/api/types/errors' {
/**
* A contract self destructed in its constructor.
*
* This can be triggered by a call to `seal_terminate` or `seal_restore_to`.
* This can be triggered by a call to `seal_terminate`.
**/
TerminatedInConstructor: AugmentedError<ApiType>;
/**
* Termination of a contract is not allowed while the contract is already
* on the call stack. Can be triggered by `seal_terminate` or `seal_restore_to.
* on the call stack. Can be triggered by `seal_terminate`.
**/
TerminatedWhileReentrant: AugmentedError<ApiType>;
/**
@@ -424,10 +381,6 @@ declare module '@polkadot/api/types/errors' {
* Identity may not veto a proposal twice
**/
AlreadyVetoed: AugmentedError<ApiType>;
/**
* Unknown index
**/
BadIndex: AugmentedError<ApiType>;
/**
* Preimage already noted
**/
@@ -452,10 +405,6 @@ declare module '@polkadot/api/types/errors' {
* Invalid hash
**/
InvalidHash: AugmentedError<ApiType>;
/**
* The provided witness data is wrong.
**/
InvalidWitness: AugmentedError<ApiType>;
/**
* Maximum number of votes reached.
**/
@@ -476,26 +425,14 @@ declare module '@polkadot/api/types/errors' {
* No external proposal
**/
NoProposal: AugmentedError<ApiType>;
/**
* Not delegated
**/
NotDelegated: AugmentedError<ApiType>;
/**
* The account is not currently delegating.
**/
NotDelegating: AugmentedError<ApiType>;
/**
* The lock on the account to be unlocked has not yet expired.
**/
NotExpired: AugmentedError<ApiType>;
/**
* Not imminent
**/
NotImminent: AugmentedError<ApiType>;
/**
* The target account does not have a lock.
**/
NotLocked: AugmentedError<ApiType>;
/**
* Next external proposal not simple majority
**/
@@ -680,8 +617,8 @@ declare module '@polkadot/api/types/errors' {
**/
AmountTooSmall: AugmentedError<ApiType>;
/**
* The queue for the bid's duration is full and the amount bid is too low to get in through
* replacing an existing bid.
* The queue for the bid's duration is full and the amount bid is too low to get in
* through replacing an existing bid.
**/
BidTooLow: AugmentedError<ApiType>;
/**
@@ -1271,8 +1208,8 @@ declare module '@polkadot/api/types/errors' {
**/
NoUnlockChunk: AugmentedError<ApiType>;
/**
* There are too many nominators in the system. Governance needs to adjust the staking settings
* to keep things safe for the runtime.
* There are too many nominators in the system. Governance needs to adjust the staking
* settings to keep things safe for the runtime.
**/
TooManyNominators: AugmentedError<ApiType>;
/**
@@ -1280,8 +1217,8 @@ declare module '@polkadot/api/types/errors' {
**/
TooManyTargets: AugmentedError<ApiType>;
/**
* There are too many validators in the system. Governance needs to adjust the staking settings
* to keep things safe for the runtime.
* There are too many validators in the system. Governance needs to adjust the staking
* settings to keep things safe for the runtime.
**/
TooManyValidators: AugmentedError<ApiType>;
/**
@@ -1541,19 +1478,38 @@ declare module '@polkadot/api/types/errors' {
**/
[key: string]: AugmentedError<ApiType>;
};
utility: {
/**
* Too many calls batched.
**/
TooManyCalls: AugmentedError<ApiType>;
/**
* Generic error
**/
[key: string]: AugmentedError<ApiType>;
};
vesting: {
/**
* Amount being transferred is too low to create a vesting schedule.
**/
AmountLow: AugmentedError<ApiType>;
/**
* An existing vesting schedule already exists for this account that cannot be clobbered.
* The account already has `MaxVestingSchedules` count of schedules and thus
* cannot add another one. Consider merging existing schedules in order to add another.
**/
ExistingVestingSchedule: AugmentedError<ApiType>;
AtMaxVestingSchedules: AugmentedError<ApiType>;
/**
* Failed to create a new schedule because some parameter was invalid.
**/
InvalidScheduleParams: AugmentedError<ApiType>;
/**
* The account given is not vesting.
**/
NotVesting: AugmentedError<ApiType>;
/**
* An index was out of bounds of the vesting schedules.
**/
ScheduleIndexOutOfBounds: AugmentedError<ApiType>;
/**
* Generic error
**/
File diff suppressed because it is too large Load Diff
+1
View File
@@ -1,6 +1,7 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import '@polkadot/types/augment';
import './consts';
import './errors';
import './events';
File diff suppressed because it is too large Load Diff
+5 -1
View File
@@ -2,7 +2,6 @@
/* eslint-disable */
import type { Bytes, HashMap, Json, Metadata, Null, Option, StorageKey, Text, U256, U64, Vec, bool, u32, u64 } from '@polkadot/types';
import type { AnyNumber, Codec, IExtrinsic, Observable } from '@polkadot/types/types';
import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
import type { EpochAuthorship } from '@polkadot/types/interfaces/babe';
import type { BeefySignedCommitment } from '@polkadot/types/interfaces/beefy';
@@ -21,6 +20,7 @@ import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
import type { AccountId, BlockNumber, H160, H256, H64, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
import type { ReadProof, RuntimeVersion, TraceBlockResponse } from '@polkadot/types/interfaces/state';
import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system';
import type { AnyNumber, Codec, IExtrinsic, Observable } from '@polkadot/types/types';
declare module '@polkadot/rpc-core/types.jsonrpc' {
export interface RpcInterface {
@@ -113,6 +113,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
* Returns a child storage entry at a specific block state
**/
getStorage: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Option<StorageData>>>;
/**
* Returns child storage entries for multiple keys at a specific block state
**/
getStorageEntries: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: Hash | string | Uint8Array) => Observable<Vec<Option<StorageData>>>>;
/**
* Returns the hash of a child storage entry at a block state
**/
File diff suppressed because it is too large Load Diff
+76 -64
View File
@@ -7,12 +7,12 @@ import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { AnyFunction, AnyTuple, CallFunction, Codec, CodecArg as Arg, DefinitionRpc, DefinitionRpcSub, IMethod, InterfaceTypes, IStorageKey, Registry, RegistryTypes } from '@polkadot/types/types';
import type { AnyFunction, AnyTuple, CallFunction, Codec, DefinitionRpc, DefinitionRpcSub, DetectCodec, IMethod, IStorageKey, Registry, RegistryTypes } from '@polkadot/types/types';
import type { SubmittableExtrinsic } from '../submittable/types';
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableModuleStorageAt, QueryableStorage, QueryableStorageAt, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
import type { VersionedRegistry } from './types';
import { BehaviorSubject, combineLatest, map, of, switchMap, tap, toArray } from 'rxjs';
import { BehaviorSubject, combineLatest, from, map, of, switchMap, tap, toArray } from 'rxjs';
import { decorateDerive, ExactDerive } from '@polkadot/api-derive';
import { memo, RpcCore } from '@polkadot/rpc-core';
@@ -154,6 +154,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
this._rx.hasSubscriptions = this._rpcCore.provider.hasSubscriptions;
}
public abstract at (blockHash: Uint8Array | string): Promise<ApiDecoration<ApiType>>;
/**
* @description Return the current used registry
*/
@@ -164,7 +166,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
/**
* @description Creates an instance of a type as registered
*/
public createType <K extends keyof InterfaceTypes> (type: K, ...params: unknown[]): InterfaceTypes[K] {
public createType <T extends Codec = Codec, K extends string = string> (type: K, ...params: unknown[]): DetectCodec<T, K> {
return this.#registry.createType(type, ...params);
}
@@ -195,7 +197,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
consts: {},
errors: {},
events: {},
query: {}
query: {},
registry: registry.registry,
rx: {
query: {}
}
} as ApiDecoration<ApiType>;
}
@@ -211,8 +217,12 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
const storage = blockHash
? this._decorateStorageAt(registry.decoratedMeta, this._decorateMethod, blockHash)
: this._decorateStorage(registry.decoratedMeta, this._decorateMethod);
const storageRx = blockHash
? this._decorateStorageAt(registry.decoratedMeta, this._rxDecorateMethod, blockHash)
: this._decorateStorage(registry.decoratedMeta, this._rxDecorateMethod);
augmentObject('query', storage, decoratedApi.query, fromEmpty);
augmentObject('query', storageRx, decoratedApi.rx.query, fromEmpty);
return {
decoratedApi,
@@ -227,7 +237,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
consts: {},
errors: {},
events: {},
query: {}
query: {},
registry: registry.registry,
rx: {
query: {}
}
} as ApiDecoration<ApiType>;
}
@@ -237,6 +251,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
this._errors = decoratedApi.errors;
this._events = decoratedApi.events;
this._query = decoratedApi.query;
this._rx.query = decoratedApi.rx.query;
if (fromEmpty || !this._extrinsics) {
this._extrinsics = this._decorateExtrinsics(decoratedMeta, this._decorateMethod);
@@ -246,8 +261,6 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
augmentObject(null, this._decorateExtrinsics(decoratedMeta, this._rxDecorateMethod), this._rx.tx, false);
}
// rx
augmentObject(null, this._decorateStorage(decoratedMeta, this._rxDecorateMethod), this._rx.query, fromEmpty);
augmentObject(null, decoratedMeta.consts, this._rx.consts, fromEmpty);
}
@@ -358,10 +371,14 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
(this.hasSubscriptions
? this._rpcCore.state.subscribeStorage
: this._rpcCore.state.queryStorageAt)(
calls.map((arg: QueryableStorageMultiArg<ApiType>) =>
Array.isArray(arg)
? [arg[0].creator, ...arg.slice(1)]
: [arg.creator])));
calls.map((args: QueryableStorageMultiArg<ApiType>) =>
Array.isArray(args)
? args[0].creator.meta.type.isPlain
? [args[0].creator]
: args[0].creator.meta.type.asMap.hashers.length === 1
? [args[0].creator, args.slice(1)]
: [args[0].creator, ...args.slice(1)]
: [args.creator])));
}
protected _decorateExtrinsics<ApiType extends ApiTypes> ({ tx }: DecoratedMeta, decorateMethod: DecorateMethod<ApiType>): SubmittableExtrinsics<ApiType> {
@@ -379,7 +396,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
}
private _decorateExtrinsicEntry<ApiType extends ApiTypes> (method: CallFunction, creator: (value: Call | Uint8Array | string) => SubmittableExtrinsic<ApiType>): SubmittableExtrinsicFunction<ApiType> {
const decorated = (...params: Arg[]): SubmittableExtrinsic<ApiType> =>
const decorated = (...params: unknown[]): SubmittableExtrinsic<ApiType> =>
creator(method(...params));
// pass through the `.is`
@@ -402,10 +419,10 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
}, {} as QueryableStorage<ApiType>);
}
protected _decorateStorageAt<ApiType extends ApiTypes> ({ query }: DecoratedMeta, decorateMethod: DecorateMethod<ApiType>, blockHash: Uint8Array): QueryableStorageAt<ApiType> {
protected _decorateStorageAt<ApiType extends ApiTypes> ({ query, registry }: DecoratedMeta, decorateMethod: DecorateMethod<ApiType>, blockHash: Uint8Array): QueryableStorageAt<ApiType> {
return Object.entries(query).reduce((out, [name, section]): QueryableStorageAt<ApiType> => {
out[name] = Object.entries(section).reduce((out, [name, method]): QueryableModuleStorageAt<ApiType> => {
out[name] = this._decorateStorageEntryAt(method, decorateMethod, blockHash);
out[name] = this._decorateStorageEntryAt(registry, method, decorateMethod, blockHash);
return out;
}, {} as QueryableModuleStorageAt<ApiType>);
@@ -416,7 +433,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
private _decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(this.#registry, creator, args);
const getArgs = (args: unknown[]) => extractStorageArgs(this.#registry, creator, args);
// Disable this where it occurs for each field we are decorating
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
@@ -425,48 +442,45 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
decorated.creator = creator;
decorated.at = decorateMethod((hash: Hash, ...args: Arg[]): Observable<Codec> =>
this._rpcCore.state.getStorage(getArgs(args), hash));
decorated.at = decorateMethod((hash: Hash, ...args: unknown[]): Observable<Codec> =>
from(this.at(hash)).pipe(
switchMap((api): Observable<Codec> => {
assert(api.rx.query[creator.section] && api.rx.query[creator.section][creator.method], () => `query.${creator.section}.${creator.method} is not available in this version of the metadata`);
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
return api.rx.query[creator.section][creator.method](...args);
})
));
decorated.hash = decorateMethod((...args: unknown[]): Observable<Hash> =>
this._rpcCore.state.getStorageHash(getArgs(args)));
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
key.section === creator.section &&
key.method === creator.method;
decorated.key = (...args: Arg[]): string =>
u8aToHex(compactStripLength(creator(
creator.meta.type.isPlain
? undefined
: creator.meta.type.isMap
? args[0]
: creator.meta.type.isDoubleMap
? [args[0], args[1]]
: args
))[1]);
decorated.key = (...args: unknown[]): string =>
u8aToHex(compactStripLength(creator(...args))[1]);
decorated.keyPrefix = (...keys: Arg[]): string =>
u8aToHex(creator.keyPrefix(...keys));
decorated.keyPrefix = (...args: unknown[]): string =>
u8aToHex(creator.keyPrefix(...args));
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: Arg[]): Observable<[Hash, Codec][]> =>
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: unknown[]): Observable<[Hash, Codec][]> =>
this._decorateStorageRange(decorated, args, range));
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
decorated.size = decorateMethod((...args: unknown[]): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(args)));
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<u64> =>
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, ...args: unknown[]): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(args), hash));
// FIXME NMap support
// .keys() & .entries() only available on map types
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
if (creator.iterKey && creator.meta.type.isMap) {
decorated.entries = decorateMethod(
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
memo(this.#instanceId, (...args: unknown[]): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, null, args)));
decorated.entriesAt = decorateMethod(
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<[StorageKey, Codec][]> =>
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: unknown[]): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, hash, args)));
decorated.entriesPaged = decorateMethod(
@@ -474,11 +488,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
this._retrieveMapEntriesPaged(creator, opts)));
decorated.keys = decorateMethod(
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
memo(this.#instanceId, (...args: unknown[]): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, null, args)));
decorated.keysAt = decorateMethod(
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<StorageKey[]> =>
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: unknown[]): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, hash, args)));
decorated.keysPaged = decorateMethod(
@@ -486,10 +500,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
this._retrieveMapKeysPaged(creator, opts)));
}
if (this.supportMulti) {
if (this.supportMulti && creator.meta.type.isMap) {
// When using double map storage function, user need to pass double map key as an array
decorated.multi = decorateMethod((args: (Arg | Arg[])[]): Observable<Codec[]> =>
this._retrieveMulti(args.map((arg) => [creator, arg])));
decorated.multi = decorateMethod((args: unknown[]): Observable<Codec[]> =>
creator.meta.type.asMap.hashers.length === 1
? this._retrieveMulti(args.map((a) => [creator, [a]]))
: this._retrieveMulti(args.map((a) => [creator, a as unknown[]]))
);
}
/* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
@@ -497,51 +514,47 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
return this._decorateFunctionMeta(creator as any, decorated) as unknown as QueryableStorageEntry<ApiType>;
}
private _decorateStorageEntryAt<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>, blockHash: Uint8Array): QueryableStorageEntryAt<ApiType> {
private _decorateStorageEntryAt<ApiType extends ApiTypes> (registry: Registry, creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>, blockHash: Uint8Array): QueryableStorageEntryAt<ApiType> {
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(this.#registry, creator, args);
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(registry, creator, args);
// Disable this where it occurs for each field we are decorating
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
const decorated = decorateMethod((...args: Arg[]): Observable<Codec> =>
const decorated = decorateMethod((...args: unknown[]): Observable<Codec> =>
this._rpcCore.state.getStorage(getArgs(args), blockHash));
decorated.creator = creator;
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
decorated.hash = decorateMethod((...args: unknown[]): Observable<Hash> =>
this._rpcCore.state.getStorageHash(getArgs(args), blockHash));
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
key.section === creator.section &&
key.method === creator.method;
decorated.key = (...args: Arg[]): string =>
decorated.key = (...args: unknown[]): string =>
u8aToHex(compactStripLength(creator(
creator.meta.type.isPlain
? undefined
: creator.meta.type.isMap
? args[0]
: creator.meta.type.isDoubleMap
? [args[0], args[1]]
: args
: args
))[1]);
decorated.keyPrefix = (...keys: Arg[]): string =>
decorated.keyPrefix = (...keys: unknown[]): string =>
u8aToHex(creator.keyPrefix(...keys));
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
decorated.size = decorateMethod((...args: unknown[]): Observable<u64> =>
this._rpcCore.state.getStorageSize(getArgs(args), blockHash));
// FIXME NMap support
// .keys() & .entries() only available on map types
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
if (creator.iterKey && creator.meta.type.isMap) {
decorated.entries = decorateMethod(
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
memo(this.#instanceId, (...args: unknown[]): Observable<[StorageKey, Codec][]> =>
this._retrieveMapEntries(creator, blockHash, args)));
decorated.keys = decorateMethod(
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
memo(this.#instanceId, (...args: unknown[]): Observable<StorageKey[]> =>
this._retrieveMapKeys(creator, blockHash, args)));
}
@@ -553,7 +566,6 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
// Decorate the base storage call. In the case or rxjs or promise-without-callback (await)
// we make a subscription, alternatively we push this through a single-shot query
private _decorateStorageCall<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): ReturnType<DecorateMethod<ApiType>> {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return decorateMethod((...args: unknown[]): Observable<Codec> => {
return this.hasSubscriptions
? this._rpcCore.state.subscribeStorage<[Codec]>([extractStorageArgs(this.#registry, creator, args)]).pipe(
@@ -566,7 +578,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
});
}
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: Arg[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: unknown[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
const outputType = unwrapStorageType(this.#registry, decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
return this._rpcCore.state
@@ -580,7 +592,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
}
// retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
private _retrieveMulti (keys: [StorageEntry, Arg | Arg[]][]): Observable<Codec[]> {
private _retrieveMulti (keys: [StorageEntry, unknown[]][]): Observable<Codec[]> {
if (!keys.length) {
return of([]);
}
@@ -596,8 +608,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
);
}
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, args: unknown[]): Observable<StorageKey[]> {
assert(iterKey && meta.type.isMap, 'keys can only be retrieved on maps');
const headKey = iterKey(...args).toHex();
const startSubject = new BehaviorSubject<string>(headKey);
@@ -621,7 +633,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
}
private _retrieveMapKeysPaged ({ iterKey, meta, method, section }: StorageEntry, opts: PaginationOptions): Observable<StorageKey[]> {
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
assert(iterKey && meta.type.isMap, 'keys can only be retrieved on maps');
const headKey = iterKey(...opts.args).toHex();
@@ -630,7 +642,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
);
}
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<[StorageKey, Codec][]> {
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, args: unknown[]): Observable<[StorageKey, Codec][]> {
const query = at
? (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset, at)
: (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset);
+2 -2
View File
@@ -182,8 +182,8 @@ export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> im
/**
* @description The underlying Rx API interface
*/
public get rx (): Pick<ApiInterfaceRx, 'tx' | 'rpc'> {
return assertResult(this._rx as Pick<ApiInterfaceRx, 'tx' | 'rpc'>);
public get rx (): Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query'> {
return assertResult(this._rx as Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query'>);
}
/**
+13 -7
View File
@@ -332,6 +332,15 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
return true;
}
private _subscribeHealth (): void {
// Only enable the health keepalive on WS, not needed on HTTP
this.#healthTimer = this.hasSubscriptions
? setInterval((): void => {
firstValueFrom(this._rpcCore.system.health()).catch(() => undefined);
}, KEEPALIVE_INTERVAL)
: null;
}
private _unsubscribeHealth (): void {
if (this.#healthTimer) {
clearInterval(this.#healthTimer);
@@ -352,8 +361,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
}
#onProviderConnect = async (): Promise<void> => {
this.emit('connected');
this._isConnected.next(true);
this.emit('connected');
try {
const [hasMeta, cryptoReady] = await Promise.all([
@@ -363,15 +372,13 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
: cryptoWaitReady()
]);
this._subscribeHealth();
if (hasMeta && !this._isReady && cryptoReady) {
this._isReady = true;
this.emit('ready', this);
}
this.#healthTimer = setInterval((): void => {
firstValueFrom(this._rpcCore.system.health()).catch(() => undefined);
}, KEEPALIVE_INTERVAL);
} catch (_error) {
const error = new Error(`FATAL: Unable to initialize the API: ${(_error as Error).message}`);
@@ -382,10 +389,9 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
}
#onProviderDisconnect = (): void => {
this.emit('disconnected');
this._isConnected.next(false);
this._unsubscribeHealth();
this.emit('disconnected');
};
#onProviderError = (error: Error): void => {
+4 -3
View File
@@ -21,7 +21,8 @@ function consts (api: ApiPromise): void {
console.log(
api.consts.foo.bar,
api.consts.balances.existentialDeposit.toNumber(),
api.consts.balances.existentialDeposit.meta.docs.map((s): string => s.toString()).join('')
api.consts.balances.existentialDeposit.meta.docs.map((s) => s.toString()).join(''),
api.consts.system.blockWeights.maxBlock.divn(123).toNumber()
);
}
@@ -81,7 +82,7 @@ async function query (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
const oldBal = await api.query.balances.totalIssuance.at('abcd');
// It's hard to correctly type .multi. Expected: `Balance[]`, actual: Codec[].
// In the meantime, we can case with `<Balance>` (this is not available on recent chains)
const multi = await api.query.balances.freeBalance.multi<Balance>([pairs.alice.address, pairs.bob.address]);
const multi = await api.query.balances.freeBalance.multi([pairs.alice.address, pairs.bob.address]);
console.log('query types:', bar, bal, bal2, override, oldBal, multi);
@@ -190,7 +191,7 @@ function types (api: ApiPromise): void {
}
async function tx (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
// transfer, also allows for BigInt inputs here
// transfer, also allows for bigint inputs here
const transfer = api.tx.balances.transfer(pairs.bob.address, 123456789n);
console.log('transfer casted', transfer as IMethod<AnyTuple>, transfer as IExtrinsic<AnyTuple>);
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '5.3.1' };
export const packageInfo = { name: '@polkadot/api', version: '6.2.1' };
+8 -14
View File
@@ -39,7 +39,7 @@ describe('ApiPromise', (): void => {
};
const signer = new SingleAccountSigner(registry, aliceEd);
const api = await ApiPromise.create({ provider, registry, signer });
const api = await ApiPromise.create({ provider, registry, signer, throwOnConnect: true });
const transfer = api.tx.balances.transfer(keyring.getPair('0xe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e').address, 321564789876512345n);
return { api, transfer: await transfer.signAsync(aliceEd.address, {}) };
@@ -59,7 +59,7 @@ describe('ApiPromise', (): void => {
const rpcData = await provider.send<string>('state_getMetadata', []);
const genesisHash = registry.createType('Hash', await provider.send('chain_getBlockHash', [])).toHex();
const specVersion = 0;
const api = await ApiPromise.create({ metadata: { [`${genesisHash}-${specVersion}`]: rpcData }, provider, registry });
const api = await ApiPromise.create({ metadata: { [`${genesisHash}-${specVersion}`]: rpcData }, provider, registry, throwOnConnect: true });
expect(api.genesisHash).toBeDefined();
expect(api.runtimeMetadata).toBeDefined();
@@ -74,7 +74,7 @@ describe('ApiPromise', (): void => {
it('Create API instance without metadata and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
const metadata = {};
const api = await ApiPromise.create({ metadata, provider, registry });
const api = await ApiPromise.create({ metadata, provider, registry, throwOnConnect: true });
expect(api.genesisHash).toBeDefined();
expect(api.runtimeMetadata).toBeDefined();
@@ -98,17 +98,15 @@ describe('ApiPromise', (): void => {
}
}
const api = new ErrorApiPromise();
try {
await api.isReadyOrError;
const api = await ErrorApiPromise.create({ provider, throwOnConnect: true });
await api.disconnect();
fail('Expected an error but none occurred.');
} catch {
// Pass
}
await api.disconnect();
});
});
@@ -118,7 +116,7 @@ describe('ApiPromise', (): void => {
const SIG = '0x659effefbbe5ab4d7136ebb5084b959eb424e32b862307371be4721ac2c46334245af4f1476c36c5e5aff04396c2fdd2ce561ec90382821d4aa071b559b1db0f';
it('signs data using a specified keyring', async (): Promise<void> => {
const api = await ApiPromise.create({ provider, registry });
const api = await ApiPromise.create({ provider, registry, throwOnConnect: true });
const sig = await api.sign(aliceEd, TEST);
expect(sig).toEqual(SIG);
@@ -127,11 +125,7 @@ describe('ApiPromise', (): void => {
});
it('signs data using an external signer', async (): Promise<void> => {
const api = await ApiPromise.create({
provider,
registry,
signer: new SingleAccountSigner(registry, aliceEd)
});
const api = await ApiPromise.create({ provider, registry, signer: new SingleAccountSigner(registry, aliceEd), throwOnConnect: true });
const sig = await api.sign(ADDR, TEST);
expect(sig).toEqual(SIG);
+1
View File
@@ -45,6 +45,7 @@ export interface SignerOptions {
nonce: AnyNumber | Codec;
signer?: Signer;
tip?: AnyNumber;
assetId?: AnyNumber;
}
export type AddressOrPair = IKeyringPair | string | AccountId | Address;
+3 -4
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type { Observable } from 'rxjs';
import type { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
import type { AnyFunction, Callback, Codec } from '@polkadot/types/types';
export type Push<T extends readonly unknown[], V> = [...T, V]
@@ -57,9 +57,8 @@ export interface DecorateMethodOptions {
export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
// FIXME We need a solution for NMap
export interface PaginationOptions<ArgType = CodecArg> {
args: ArgType[];
export interface PaginationOptions<A = unknown> {
args: A[];
pageSize: number;
startKey?: string;
}
+2 -2
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces';
import type { PalletConstantMetadataLatest } from '@polkadot/types/interfaces';
import type { Codec } from '@polkadot/types/types';
import type { ApiTypes } from './base';
@@ -10,7 +10,7 @@ export interface AugmentedConsts<ApiType extends ApiTypes> { }
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface AugmentedConst<ApiType extends ApiTypes> {
meta: ModuleConstantMetadataLatest;
meta: PalletConstantMetadataLatest;
}
export interface QueryableModuleConsts {
+4
View File
@@ -112,4 +112,8 @@ export interface ApiDecoration<ApiType extends ApiTypes> {
errors: DecoratedErrors<ApiType>;
events: DecoratedEvents<ApiType>;
query: QueryableStorage<ApiType>;
registry: Registry;
rx: {
query: QueryableStorage<'rxjs'>;
}
}
+30 -29
View File
@@ -5,34 +5,40 @@ import type { Observable } from 'rxjs';
import type { StorageKey, u64 } from '@polkadot/types';
import type { Hash } from '@polkadot/types/interfaces';
import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { AnyFunction, AnyTuple, Callback, Codec, CodecArg, IStorageKey } from '@polkadot/types/types';
import type { AnyFunction, AnyTuple, Callback, Codec, IStorageKey } from '@polkadot/types/types';
import type { ApiTypes, DropLast, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
interface StorageEntryObservableMulti {
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Observable<T[]>;
type AsCodec<R extends Codec | any> = R extends Codec
? R
: Codec;
type ReturnCodec<F extends AnyFunction> = AsCodec<ObsInnerType<ReturnType<F>>>;
interface StorageEntryObservableMulti<R extends Codec = Codec> {
<T extends Codec = R>(args: (unknown[] | unknown)[]): Observable<T[]>;
}
interface StorageEntryPromiseMulti {
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Promise<T[]>;
<T extends Codec>(args: (CodecArg[] | CodecArg)[], callback: Callback<T[]>): UnsubscribePromise;
interface StorageEntryPromiseMulti<R extends Codec = Codec> {
<T extends Codec = R>(args: (unknown[] | unknown)[]): Promise<T[]>;
<T extends Codec = R>(args: (unknown[] | unknown)[], callback: Callback<T[]>): UnsubscribePromise;
}
export interface StorageEntryPromiseOverloads {
(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<Codec>;
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<T>;
(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
<T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
<T extends Codec>(callback: Callback<T>): UnsubscribePromise;
<T extends Codec>(arg: CodecArg, callback: Callback<T>): UnsubscribePromise;
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, callback: Callback<T>): UnsubscribePromise;
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, arg3: CodecArg, callback: Callback<T>): UnsubscribePromise;
<T extends Codec>(arg: unknown, callback: Callback<T>): UnsubscribePromise;
<T extends Codec>(arg1: unknown, arg2: unknown, callback: Callback<T>): UnsubscribePromise;
<T extends Codec>(arg1: unknown, arg2: unknown, arg3: unknown, callback: Callback<T>): UnsubscribePromise;
}
export interface StorageEntryPromiseOverloadsAt {
(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<Codec>;
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<T>;
(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
<T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
}
// This is the most generic typings we can have for a storage entry function
type GenericStorageEntryFunction = (...args: CodecArg[]) => Observable<Codec>
type GenericStorageEntryFunction = (...args: unknown[]) => Observable<Codec>
export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
ApiType extends 'rxjs'
@@ -52,28 +58,23 @@ export interface QueryableStorageAt<ApiType extends ApiTypes> extends AugmentedQ
[key: string]: QueryableModuleStorageAt<ApiType>;
}
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> extends StorageEntryBaseAt<ApiType, F, A> {
at: <T extends Codec | any = ReturnCodec<F>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
creator: StorageEntry;
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
key: (...args: Parameters<F>) => string;
keyPrefix: (...args: DropLast<Parameters<F>>) => string;
keys: <K extends AnyTuple = A> (...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
entriesAt: <T extends Codec | any = ReturnCodec<F>, K extends AnyTuple = A>(hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entriesPaged: <T extends Codec | any = ReturnCodec<F>, K extends AnyTuple = A>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
keysPaged: <K extends AnyTuple = A> (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
// @deprecated The underlying RPC this been marked unsafe and is generally not exposed
range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
range: <T extends Codec | any = ReturnCodec<F>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
sizeAt: (hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
multi: ApiType extends 'rxjs' ? StorageEntryObservableMulti : StorageEntryPromiseMulti;
multi: ApiType extends 'rxjs'
? StorageEntryObservableMulti<ReturnCodec<F>>
: StorageEntryPromiseMulti<ReturnCodec<F>>;
}
export interface StorageEntryBaseAt<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
entries: <T extends Codec | any = ReturnCodec<F>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
key: (...args: Parameters<F>) => string;
@@ -92,7 +93,7 @@ export interface QueryableModuleStorageAt<ApiType extends ApiTypes> {
export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
QueryableStorageEntry<ApiType> |
[QueryableStorageEntry<ApiType>, ...CodecArg[]];
[QueryableStorageEntry<ApiType>, ...unknown[]];
export interface QueryableStorageMultiBase<ApiType extends ApiTypes> {
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]): Observable<T>;
+16 -44
View File
@@ -1,59 +1,53 @@
// Copyright 2017-2019 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Storage } from '@polkadot/types/metadata/decorate/types';
import { decorateStorage, Metadata, TypeRegistry } from '@polkadot/types';
import metaStatic from '@polkadot/types/metadata/static-substrate';
import metaStatic from '@polkadot/types-support/metadata/static-substrate';
import { extractStorageArgs } from './validate';
describe('extractStorageArgs', (): void => {
const registry = new TypeRegistry();
let storage: Storage;
const metadata = new Metadata(registry, metaStatic);
beforeEach((): void => {
const metadata = new Metadata(registry, metaStatic);
registry.setMetadata(metadata);
storage = decorateStorage(registry, metadata.asLatest, metadata.version);
});
const storage = decorateStorage(registry, metadata.asLatest, metadata.version);
it('validates no-arg plain', (): void => {
expect(
extractStorageArgs(registry, storage.timestamp.now, [])
).toEqual([storage.timestamp.now]);
).toEqual([storage.timestamp.now, []]);
});
it('validates no-arg plain (with undefined, undefined)', (): void => {
expect(
extractStorageArgs(registry, storage.timestamp.now, [undefined, undefined])
).toEqual([storage.timestamp.now]);
).toEqual([storage.timestamp.now, []]);
});
it('validates no-arg plain (failing when there are args)', (): void => {
expect(
(): unknown => extractStorageArgs(registry, storage.timestamp.now, [123, 456])
() => extractStorageArgs(registry, storage.timestamp.now, [123, 456])
).toThrow('timestamp.now() does not take any arguments, 2 found');
});
it('validates map, 1 arg', (): void => {
expect(
extractStorageArgs(registry, storage.staking.payee, ['abc'])
).toEqual([storage.staking.payee, 'abc']);
).toEqual([storage.staking.payee, ['abc']]);
});
it('validates map, 1 arg (failing with no args)', (): void => {
expect(
(): any =>
extractStorageArgs(registry, storage.staking.payee, [])
).toThrow('staking.payee(AccountId) is a map, requiring 1 argument, 0 found');
() => extractStorageArgs(registry, storage.staking.payee, [])
).toThrow('staking.payee(AccountId32) is a map, requiring 1 arguments, 0 found');
});
it('validates map, 1 arg (failing with no args)', (): void => {
expect(
(): any =>
extractStorageArgs(registry, storage.staking.payee, ['abc', 'def'])
).toThrow('staking.payee(AccountId) is a map, requiring 1 argument, 2 found');
() => extractStorageArgs(registry, storage.staking.payee, ['abc', 'def'])
).toThrow('staking.payee(AccountId32) is a map, requiring 1 arguments, 2 found');
});
it('validates doublemap, 2 args', (): void => {
@@ -64,35 +58,13 @@ describe('extractStorageArgs', (): void => {
it('validates doublemap, 2 args (failing with no args)', (): void => {
expect(
(): any =>
extractStorageArgs(registry, storage.staking.erasStakers, [])
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 0 found');
() => extractStorageArgs(registry, storage.staking.erasStakers, [])
).toThrow('staking.erasStakers(u32, AccountId32) is a map, requiring 2 arguments, 0 found');
});
it('validates doublemap, 2 args (failing with 1 arg)', (): void => {
expect(
(): any =>
extractStorageArgs(registry, storage.staking.erasStakers, [123])
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 1 found');
});
// Linked maps have been removed
it.skip('validates linked map, no args', (): void => {
expect(
extractStorageArgs(registry, storage.staking.validators, [])
).toEqual([storage.staking.validators]);
});
it.skip('validates linked map, single arg', (): void => {
expect(
extractStorageArgs(registry, storage.staking.validators, [123])
).toEqual([storage.staking.validators, 123]);
});
it.skip('validates linked map (failing with extra args)', (): void => {
expect(
(): any[] =>
extractStorageArgs(registry, storage.staking.validators, [123, 456])
).toThrow('staking.validators(AccountId) is a linked map, requiring either 0 arguments (retrieving all) or 1 argument, 2 found');
() => extractStorageArgs(registry, storage.staking.erasStakers, [123])
).toThrow('staking.erasStakers(u32, AccountId32) is a map, requiring 2 arguments, 1 found');
});
});
+15 -43
View File
@@ -1,60 +1,32 @@
// Copyright 2017-2019 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Type } from '@polkadot/types';
import type { SiLookupTypeId } from '@polkadot/types/interfaces';
import type { StorageEntry } from '@polkadot/types/primitive/types';
import type { Registry } from '@polkadot/types/types';
import { assert, isUndefined } from '@polkadot/util';
function sig (_: Registry, { method, section }: StorageEntry, args: Type[]): string {
return `${section}.${method}(${args.join(', ')})`;
}
function doDoubleMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] {
const { key1, key2 } = creator.meta.type.asDoubleMap;
assert(args.length === 2, () => `${sig(registry, creator, [key1, key2])} is a double map, requiring 2 arguments, ${args.length} found`);
// pass as tuple
return [creator, args as [any, any]];
}
function doMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
const { key } = creator.meta.type.asMap;
assert(args.length === 1, () => `${sig(registry, creator, [key])} is a map, requiring 1 argument, ${args.length} found`);
// expand
return args.length
? [creator, args[0]]
: [creator];
}
function doNMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry, any[]] {
const { keyVec } = creator.meta.type.asNMap;
assert(args.length === keyVec.length, () => `${sig(registry, creator, keyVec)} is a multi map, requiring ${keyVec.length} arguments, ${args.length} found`);
// pass as tuple
return [creator, args];
function sig ({ lookup }: Registry, { method, section }: StorageEntry, args: SiLookupTypeId[]): string {
return `${section}.${method}(${args.map((a) => lookup.getTypeDef(a).type).join(', ')})`;
}
// sets up the arguments in the form of [creator, args] ready to be used in a storage
// call. Additionally, it verifies that the correct number of arguments have been passed
export function extractStorageArgs (registry: Registry, creator: StorageEntry, _args: unknown[]): [StorageEntry, any[]] | [StorageEntry] | [StorageEntry, any] {
export function extractStorageArgs (registry: Registry, creator: StorageEntry, _args: unknown[]): [StorageEntry, unknown[]] {
const args = _args.filter((arg) => !isUndefined(arg));
if (creator.meta.type.isDoubleMap) {
return doDoubleMap(registry, creator, args);
} else if (creator.meta.type.isMap) {
return doMap(registry, creator, args);
} else if (creator.meta.type.isNMap) {
return doNMap(registry, creator, args);
if (creator.meta.type.isPlain) {
assert(args.length === 0, () => `${sig(registry, creator, [])} does not take any arguments, ${args.length} found`);
} else {
const { hashers, key } = creator.meta.type.asMap;
const keys = hashers.length === 1
? [key]
: registry.lookup.getSiType(key).def.asTuple.map((t) => t);
assert(args.length === keys.length, () => `${sig(registry, creator, keys)} is a map, requiring ${keys.length} arguments, ${args.length} found`);
}
assert(args.length === 0, () => `${sig(registry, creator, [])} does not take any arguments, ${args.length} found`);
// no args
return [creator];
// pass as tuple
return [creator, args];
}
+5 -6
View File
@@ -22,6 +22,11 @@ describe('misc online tests', (): void => {
await api.disconnect();
});
it('expose rpc and rx definition', (): void => {
console.error(api.rpc.payment.queryFeeDetails.meta);
console.error(api.rx.rpc.chain.getBlock.meta);
});
it.skip('retrieves balances correctly', async (): Promise<void> => {
console.error(JSON.stringify(
await api.query.system.account('FPzukZw2mphWsXDqdkNzLaxnanjZEWH9i2vqwobTdtde5me')
@@ -64,10 +69,4 @@ describe('misc online tests', (): void => {
await api.query.society.defenderVotes('Dab4bfYTZRUDMWjYAUQuFbDreQ9mt7nULWu3Dw7jodbzVe9')
));
});
it('expose rpc and rx definition', (): void => {
console.error(api.rpc.payment.queryFeeDetails.meta);
console.error(api.rx.rpc.chain.getBlock.meta);
});
});
+1 -1
View File
@@ -150,7 +150,7 @@ const typesBundle = {
types: [
{
minmax: [0, undefined] as [number?, number?],
minmax: [0, undefined],
types: {
Balance: 'u64',
BalanceOf: 'Balance',
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-core",
"version": "5.3.1",
"version": "6.2.1",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
@@ -19,13 +19,13 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/rpc-provider": "5.3.1",
"@polkadot/types": "5.3.1",
"@polkadot/util": "^7.1.1",
"rxjs": "^7.2.0"
"@babel/runtime": "^7.15.4",
"@polkadot/rpc-provider": "6.2.1",
"@polkadot/types": "6.2.1",
"@polkadot/util": "^7.4.1",
"rxjs": "^7.3.0"
},
"devDependencies": {
"@polkadot/keyring": "^7.1.1"
"@polkadot/keyring": "^7.4.1"
}
}
+1 -1
View File
@@ -305,7 +305,7 @@ export class RpcCore {
subscriptionPromise = this._createSubscriber({ paramsJson, subName, subType, update }, errorHandler);
} catch (error) {
errorHandler(error);
errorHandler(error as Error);
}
// Teardown logic
+1 -1
View File
@@ -3,4 +3,4 @@
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '5.3.1' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.2.1' };
+11 -11
View File
@@ -1,6 +1,6 @@
{
"name": "@polkadot/rpc-provider",
"version": "5.3.1",
"version": "6.2.1",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
@@ -19,19 +19,19 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.14.8",
"@polkadot/types": "5.3.1",
"@polkadot/util": "^7.1.1",
"@polkadot/util-crypto": "^7.1.1",
"@polkadot/x-fetch": "^7.1.1",
"@polkadot/x-global": "^7.1.1",
"@polkadot/x-ws": "^7.1.1",
"@babel/runtime": "^7.15.4",
"@polkadot/types": "6.2.1",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"@polkadot/x-fetch": "^7.4.1",
"@polkadot/x-global": "^7.4.1",
"@polkadot/x-ws": "^7.4.1",
"eventemitter3": "^4.0.7"
},
"devDependencies": {
"@polkadot/keyring": "^7.1.1",
"@polkadot/types": "5.3.1",
"@polkadot/keyring": "^7.4.1",
"@polkadot/types": "6.2.1",
"mock-socket": "^9.0.3",
"nock": "^13.1.1"
"nock": "^13.1.3"
}
}
@@ -29,6 +29,14 @@ describe('Http', (): void => {
).not.toThrow();
});
it('allow clone', (): void => {
const clone = http.clone();
/* eslint-disable */
expect((clone as any)['#endpoint']).toEqual((http as any)['#endpoint']);
expect((clone as any)['#headers']).toEqual((http as any)['#headers']);
/* eslint-enable */
});
it('always returns isConnected true', (): void => {
expect(http.isConnected).toEqual(true);
});

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