Compare commits

..
973 Commits
Author SHA1 Message Date
Github Actions e9d24c3213 [CI Skip] 1.5.1
skip-checks: true
2020-03-06 07:13:38 +00:00
Jaco Greeff 71b33e2e42 1.5 (#2001)
* 1.5

* Util bumps

* Install after bump
2020-03-06 08:03:12 +01:00
Github Actions 023bc5aaa6 [CI Skip] 1.5.0-beta.33
skip-checks: true
2020-03-05 18:47:51 +00:00
Jaco Greeff 30d4d8c3a5 Bump metadata (#2000)
* Bump metadata

* Fix lint & docs
2020-03-05 19:36:48 +01:00
Github Actions 6963e40074 [CI Skip] 1.5.0-beta.32
skip-checks: true
2020-03-05 15:46:12 +00:00
Jaco Greeff 2b6aa7972d Update metadata for current Polkadot/Substrate (#1999)
* Remove old Polkadot metadata (current only, Substrate tests cover)

* Substrate & Polkadot metadata

* VotesTo230
2020-03-05 16:37:27 +01:00
Github Actions 4908c1c82a [CI Skip] 1.5.0-beta.31
skip-checks: true
2020-03-05 14:48:00 +00:00
Jaco Greeff aaf1273794 Additional derives for new staking points & rewards (#1994)
* Additional derives for new staking points & rewards

* Fix method name

* StakingLedger update

* Expand derives

* Cleanups

* Cleanup Compact decode

* Cleanup derives

* Update CHANGELOG

* Split types
2020-03-05 15:37:34 +01:00
Jaco Greeff 62ef032594 Cleanup generic description (#1993) 2020-03-05 15:36:58 +01:00
Github Actions 3652436125 [CI Skip] 1.5.0-beta.30
skip-checks: true
2020-03-05 06:11:38 +00:00
Jaco Greeff e947c638ff Fix remove deprecated api 'Observable.create' (#1998) 2020-03-05 07:00:59 +01:00
Github Actions 6926a30760 [CI Skip] 1.5.0-beta.29
skip-checks: true
2020-03-03 15:24:21 +00:00
Jaco Greeff 4feed1db5d Bump metadata (incl. lazy payouts) (#1995)
* Bump metadata (inl. lazy payouts)

* Fix currentElected via generic

* Update tests for latest metadata
2020-03-03 16:13:28 +01:00
Github Actions d462a1d6c0 [CI Skip] 1.5.0-beta.28
skip-checks: true
2020-03-03 07:59:02 +00:00
Jaco Greeff 0e297c6779 Add rpc.raw interface, convert RPC to Augmented wrappers (#1990)
* Add rpc.raw interface, convert RPC to Augmented

* Augmentaton attempt...

* Failing test

* Fix augmentation

* Cleanup linting

* Expose .raw on decorated RPCs

* .raw into CHANGELOG

* Stray eslint overrides
2020-03-03 08:49:24 +01:00
Github Actions e07636675f [CI Skip] 1.5.0-beta.27
skip-checks: true
2020-03-02 21:44:40 +00:00
Jaco Greeff 69020faaab typos 2020-03-02 22:32:38 +01:00
Github Actions 4059682ec2 [CI Skip] 1.5.0-beta.26
skip-checks: true
2020-03-02 21:06:08 +00:00
Jaco Greeff eaf5216d49 Extrinsic customization cleanups (#1991) 2020-03-02 21:55:29 +01:00
Github Actions 47142448d7 [CI Skip] 1.5.0-beta.25
skip-checks: true
2020-03-02 15:02:40 +00:00
Jaco Greeff 586c90208c Add typeAlias to API construction options (#1989) 2020-03-02 15:52:14 +01:00
Github Actions 7e0283d7c0 [CI Skip] 1.5.0-beta.24
skip-checks: true
2020-03-02 08:22:17 +00:00
Jaco Greeff d9ee39f367 Warn on type override (#1985) 2020-03-02 09:12:25 +01:00
Jaco Greeff af1a3385cc Raise error on parsing errors (#1987) 2020-03-02 09:09:27 +01:00
Github Actions 0d58c77de0 [CI Skip] 1.5.0-beta.23
skip-checks: true
2020-03-01 23:17:36 +00:00
Jaco Greeff b588238836 Handle import module name conflicts (#1983) 2020-03-02 00:07:34 +01:00
Github Actions 3e702b8629 [CI Skip] 1.5.0-beta.22
skip-checks: true
2020-03-01 08:51:46 +00:00
Jaco Greeff 62f46359e2 Update enums with tuple members, regen (#1982) 2020-03-01 09:41:03 +01:00
Github Actions fef349880a [CI Skip] 1.5.0-beta.21
skip-checks: true
2020-03-01 08:22:48 +00:00
Jaco Greeff f59cb12ec7 Add .range([from, to?], ...args) on storage queries (#1979)
* Add .between(from, to) ot storage queries

* between -> range

* CHANGELOG

* checkTypes.manual

* Tested as working
2020-03-01 09:12:17 +01:00
Github Actions 96700eef5d [CI Skip] 1.5.0-beta.20
skip-checks: true
2020-03-01 07:21:45 +00:00
Jeremías Díaz 7316f68cdf Support tuples in enums (#1981)
* fix: support tuples as enum members in typegen

* fix: add tuple case
2020-03-01 08:11:36 +01:00
Github Actions 0078062d33 [CI Skip] 1.5.0-beta.19
skip-checks: true
2020-02-29 13:12:23 +00:00
Jaco Greeff e8cd8c9448 Minify yarn plugins (#1978)
* Minify yarn plugins

* Bump dev
2020-02-29 14:01:23 +01:00
Github Actions 58fa1062eb [CI Skip] 1.5.0-beta.18
skip-checks: true
2020-02-29 09:40:10 +00:00
Jaco Greeff bc2b0d513c Doc links, typos, publish (#1977) 2020-02-29 10:28:47 +01:00
Github Actions 8af58fcea3 [CI Skip] 1.5.0-beta.17
skip-checks: true
2020-02-29 08:48:21 +00:00
Jaco Greeff 180738306b Remove deprecated extrinsic extend docs (confusing) (#1976)
* Remove extrinsic extend

* Example for Address overrides
2020-02-29 09:38:11 +01:00
Github Actions efbe9060de [CI Skip] 1.5.0-beta.16
skip-checks: true
2020-02-28 16:17:19 +00:00
Jaco Greeff 5b9b5586d3 Update signature for Promise queryMulti (#1975) 2020-02-28 17:05:38 +01:00
Github Actions 6c174e6634 [CI Skip] 1.5.0-beta.15
skip-checks: true
2020-02-28 13:03:18 +00:00
Jaco Greeff 1c2c86126c Swap to yarn 2 (#1973)
* Swap to yarn 2

* Bump dev

* "@polkadot/typegen": "workspace:packages/typegen"
2020-02-28 13:52:44 +01:00
Github Actions 01f32f2706 [CI Skip] 1.5.0-beta.14
skip-checks: true
2020-02-28 12:48:06 +00:00
Axel Chalon 94608b0c3f Make Enum/Tuple constructor use value directly if instance (#1954)
* Make Enum/Tuple constructor use value directly if instance

* Lint

* Lint
2020-02-28 13:39:11 +01:00
Github Actions 6f581d6122 [CI Skip] 1.5.0-beta.13
skip-checks: true
2020-02-28 10:48:50 +00:00
Jaco Greeff 9fcb5fe348 FAQ entry for "Could not convert" (#1972)
* FAQ entry for "Could not convert"

* Bump dev

* Extend description, bump dev
2020-02-28 11:39:37 +01:00
Github Actions 43e641f6a1 [CI Skip] 1.5.0-beta.12
skip-checks: true
2020-02-27 20:39:17 +00:00
Luke Schoen b182fd2428 fix: Fixes TypeError: Cannot read property 'vesting' of undefined (#1970)
We're converting our chain from PoA to PoS in this PR https://github.com/DataHighway-DHX/node/pull/52/commits/7c8c96939ab6a2b77dd3a2f4bef427e831dafbda

But when I run the chain with those latest changes I got error `TypeError: Cannot read property 'vesting' of undefined` when I tried to go to the "Accounts", "Transfer", or "Extrinsics" app using polkadot.js.org/apps, as explained here https://matrix.to/#/!XOxcnpiHXHhAjJfRFP:matrix.parity.io/$0oidO-aZvsjMRdskB2nig6P_Y4CjH4Gc6TMrl4V7ZB8?via=matrix.parity.io&via=matrix.org&via=matrix.dapp.org.uk

After cloning https://github.com/polkadot-js/apps and debugging the error, I found that this change resolved the error and the error no longer appears when I access those apps
2020-02-27 21:28:41 +01:00
Github Actions af7c17e4bb [CI Skip] 1.5.0-beta.11
skip-checks: true
2020-02-27 17:17:38 +00:00
Jaco Greeff edff4231ff Dec-clutter UInt & Int (#1969) 2020-02-27 18:08:41 +01:00
Github Actions a66b98fece [CI Skip] 1.5.0-beta.10
skip-checks: true
2020-02-27 17:06:47 +00:00
Keith IngramandJaco Greeff 4e2fb23bdf Nullable api.derive.parachains.info (#1968)
* api.derive.registrar.parachains

* remove api parse

* suggestions

* some

* parachains: overview/info

* rm all

* rm all

* refine

* null parachain info

* isNone

* isNone

* isNone

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-02-27 17:57:26 +01:00
Github Actions 2900ad303c [CI Skip] 1.5.0-beta.9
skip-checks: true
2020-02-27 14:11:02 +00:00
Jaco Greeff 4e756704ea Some minor cleanups (#1966)
* Some minor cleanups

* Small additions

* Cleanup ExtrinsicEra decoding

* Minor adjustments

* Remove support for metadata v0 parsing

* Adjust refCountDelay

* refCountDelay comments

* Adjust Metadata tests

* Metadata default creation

* Funky lines

* Cleanup as AccountIdAndIndex

* Some derive returns

* Try and cleanup info extraction
2020-02-27 15:01:20 +01:00
Github Actions efd6c5331d [CI Skip] 1.5.0-beta.8
skip-checks: true
2020-02-27 13:39:24 +00:00
Jaco Greeff 619ef6f8eb Align Bool isEmpty, true when false is wrapped (#1967) 2020-02-27 14:28:27 +01:00
Github Actions 2823504156 [CI Skip] 1.5.0-beta.7
skip-checks: true
2020-02-27 12:45:56 +00:00
Amaury Martiny 370dc86817 Fix ProviderInterfaceCallback type (#1965) 2020-02-27 13:36:26 +01:00
Github Actions ee5628f856 [CI Skip] 1.5.0-beta.6
skip-checks: true
2020-02-27 12:30:12 +00:00
Jaco Greeff a8f2ba8c30 Restore 1.5.0-beta.5 (#1964)
* Restore 1.5.0-beta.5

* Bump dev
2020-02-27 13:20:25 +01:00
Github Actions 24bd513002 [CI Skip] 1.4.2
skip-checks: true
2020-02-27 10:38:28 +00:00
Jaco Greeff f73609103a Real 1.4.2 (root) 2020-02-27 11:28:43 +01:00
Github Actions 206d399258 [CI Skip] 1.5.0-beta.5
skip-checks: true
2020-02-27 10:26:13 +00:00
Jaco Greeff d531dd374f 1.4.2 (#1963)
* 1.4.2

* Actual version bump

* Rework api.tx decoratation (with tests)
2020-02-27 11:16:23 +01:00
Github Actions e199a9b11a [CI Skip] 1.5.0-beta.5
skip-checks: true
2020-02-26 21:22:25 +00:00
Jaco Greeff 0ad8be71f9 Doc around field rename (#1958) 2020-02-26 22:13:39 +01:00
Github Actions 9be9f59b6a [CI Skip] 1.5.0-beta.4
skip-checks: true
2020-02-26 21:10:44 +00:00
Jaco Greeff 5165ce7caf Rework sanitize aliasing (#1957)
* Rework sanitize aliasing

* Allow special alias override (InherentOfflineReport)
2020-02-26 22:02:19 +01:00
Github Actions b00b84e314 [CI Skip] 1.5.0-beta.3
skip-checks: true
2020-02-26 20:38:03 +00:00
Jaco Greeff 85ae6f949b Allow construction of HashMap (#1955)
* Allow construction of HashMap

* WIP... add Map to codec, extend BTreeMap & HashMap from it

* Rework various map tests

* registry.createClass

* createClass in tests
2020-02-26 21:30:38 +01:00
Github Actions e31966496b [CI Skip] 1.5.0-beta.2
skip-checks: true
2020-02-26 15:26:55 +00:00
Jaco Greeff db2ae1324f Update system.networkState types (#1951) 2020-02-26 16:19:33 +01:00
Github Actions b152a67150 [CI Skip] 1.5.0-beta.1
skip-checks: true
2020-02-26 12:38:14 +00:00
Jaco Greeff bdfc582ba5 Fix link to GH source 2020-02-26 13:30:19 +01:00
Github Actions 7a2754109f [CI Skip] 1.5.0-beta.0
skip-checks: true
2020-02-26 11:44:12 +00:00
Jaco Greeff ca76dc170c Add typegen sample (#1950)
* Add typegen sample

* Link to example from types getting started

* cc skip
2020-02-26 12:38:19 +01:00
Github Actions dbfc15ba88 [CI Skip] 1.4.1
skip-checks: true
2020-02-26 11:00:07 +00:00
Jaco Greeff 2d40d370f9 1.4 (#1949) 2020-02-26 11:52:37 +01:00
Github Actions 0728e40bfb [CI Skip] 1.4.0-beta.52
skip-checks: true
2020-02-26 10:32:30 +00:00
Keith Ingram 1a50298ffe Split parachains.derive calls (#1948)
* api.derive.registrar.parachains

* remove api parse

* suggestions

* some

* parachains: overview/info

* rm all

* rm all

* refine
2020-02-26 11:26:04 +01:00
Github Actions 68f2cb5bb2 [CI Skip] 1.4.0-beta.51
skip-checks: true
2020-02-26 10:23:37 +00:00
Jaco Greeff 8598002801 Swap to registry.createType (#1947) 2020-02-26 11:17:11 +01:00
Github Actions 333ff8528b [CI Skip] 1.4.0-beta.50
skip-checks: true
2020-02-25 16:08:21 +00:00
Jaco Greeff c17f93a3ec Update docs for system.account (#1944) 2020-02-25 17:01:41 +01:00
Github Actions 67841a9212 [CI Skip] 1.4.0-beta.49
skip-checks: true
2020-02-25 15:59:45 +00:00
Jaco Greeff 6be6b027cb More private field -> #field adjustments (#1945)
* More private field -> #field adjustments

* Work-around for set.add failures

* Remove FIXME, it is done
2020-02-25 16:53:04 +01:00
Github Actions 6943c9b36d [CI Skip] 1.4.0-beta.48
skip-checks: true
2020-02-25 14:17:45 +00:00
Jaco Greeff 253e48f7bb Return all additional identity fields (#1943) 2020-02-25 15:10:47 +01:00
Github Actions eeaf6118a5 [CI Skip] 1.4.0-beta.47
skip-checks: true
2020-02-25 13:22:44 +00:00
Jaco Greeff c3c77ffe43 Add Option.unwrapOrDefault (#1942)
* Add Option.unwrapOrDefault

* linting

* metadata createType(registry, ...) -> registry.createType(...)

* Linting

* Cleanup tests
2020-02-25 14:15:25 +01:00
Github Actions 71e82aece8 [CI Skip] 1.4.0-beta.46
skip-checks: true
2020-02-25 09:14:49 +00:00
Jaco Greeff a7132b4e9c Fix HEADER(...) in fromChain typegen (#1941) 2020-02-25 10:08:31 +01:00
Github Actions 8acb65931e [CI Skip] 1.4.0-beta.45
skip-checks: true
2020-02-25 08:50:07 +00:00
Jaco Greeff dcf053633b CHANGELOG & small strict adjustments (#1940) 2020-02-25 09:44:13 +01:00
Github Actions 015ade79e6 [CI Skip] 1.4.0-beta.44
skip-checks: true
2020-02-25 08:29:18 +00:00
Jaco Greeff a4f56d3d38 Remove deprecated types (up to metadata V5) (#1939) 2020-02-25 09:22:38 +01:00
Github Actions 73d10a55f1 [CI Skip] 1.4.0-beta.43
skip-checks: true
2020-02-25 07:47:12 +00:00
Jeremías Díaz 2d0ce2ddff Make Strict Mode Strict Again (#1938)
* fix: don't format "unorthodox" query input types

Also add support for tuples in `getSimilarTypes`

* fix: refactor type ignore logic into `formatType`

Had to use a regexp solution because types like `([AccountId | string | Uint8Array, Data | { none: any } | { raw: any } | { blakeTwo256: any } | { sha256: any } | { keccak256: any } | { shaThree256: any } | string | Uint8Array])[]` were not being ignored with the current logic, so they were passed to `getTypeDef` and causing delimiter errors.

* refactor: remove superfluous "FirstKeyType" param

* fix: ignore tuples with structs when formatting

* feat: eliminate all index signatures with --strict

* docs: fix doc generation
2020-02-25 08:40:07 +01:00
Github Actions 775697f51e [CI Skip] 1.4.0-beta.42
skip-checks: true
2020-02-24 21:48:03 +00:00
Jaco Greeff 9690777acb Update .123trigger 2020-02-24 22:41:22 +01:00
Jaco Greeff e7d38a5e59 Update CHANGELOG (#1936) 2020-02-24 22:34:54 +01:00
Jeremías Díaz c6355fb147 fix: don't format "unorthodox" query input types (#1934)
* fix: don't format "unorthodox" query input types

Also add support for tuples in `getSimilarTypes`

* fix: refactor type ignore logic into `formatType`

Had to use a regexp solution because types like `([AccountId | string | Uint8Array, Data | { none: any } | { raw: any } | { blakeTwo256: any } | { sha256: any } | { keccak256: any } | { shaThree256: any } | string | Uint8Array])[]` were not being ignored with the current logic, so they were passed to `getTypeDef` and causing delimiter errors.

* refactor: remove superfluous "FirstKeyType" param
2020-02-24 22:31:18 +01:00
Github Actions d85d9ca930 [CI Skip] 1.4.0-beta.41
skip-checks: true
2020-02-24 19:10:00 +00:00
Jaco Greeff af643401b8 Remove metadata index hack... and add another one (#1935)
* Remove metadata index hack

* Parse v9 and V10 upon failure
2020-02-24 20:03:35 +01:00
Github Actions fcea797c8a [CI Skip] 1.4.0-beta.40
skip-checks: true
2020-02-24 15:59:31 +00:00
Jaco Greeff cbc14cc291 Add new staking types, support derives (#1828)
* Add new staking types

* StakingLedgerTo213 - StakingLedgerTo223

* StakingLedgerTo223 in polkadot (dev)

* Add derive activeEra

* Map Ponts -> RewardPoints

* StakingLedger override CHANGELOG

* Cleanups

* Apparent CC dupes (don't see it, but cleanup useul)

* Cleanup result formatting for indexes

* Map nextElected -> validators

* Fix StakingLedger to current

* Merge CHANGELOG

* Mention derive staking updates

* Mark derive changes as breaking
2020-02-24 16:52:48 +01:00
Jaco Greeff 64aa4dcc1c More metadata clarifications (#1933) 2020-02-24 16:52:00 +01:00
Github Actions 429ea4ca99 [CI Skip] 1.4.0-beta.39
skip-checks: true
2020-02-24 14:08:24 +00:00
Jaco Greeff 86ce696808 Update CHANGELOG (#1932)
* Update CHANGELOG

* typos
2020-02-24 15:01:47 +01:00
Github Actions 57ca9a9c32 [CI Skip] 1.4.0-beta.38
skip-checks: true
2020-02-24 12:35:08 +00:00
Jaco Greeff 70a26e33a7 Docs for createType (#1931) 2020-02-24 13:28:08 +01:00
Github Actions c487094aa7 [CI Skip] 1.4.0-beta.37
skip-checks: true
2020-02-24 08:37:14 +00:00
Jaco Greeff bab79b6473 CHANGELOG 3.8 breaking change (#1930) 2020-02-24 09:30:56 +01:00
Github Actions 586e838788 [CI Skip] 1.4.0-beta.36
skip-checks: true
2020-02-23 14:02:59 +00:00
Jaco Greeff 51cb64ade7 Cleanup api.createType d.ts, add createType to registry (#1929)
* Cleanup api.createType d.ts, add createType to registry

* CHANGELOG
2020-02-23 14:57:30 +01:00
Github Actions d09dcb8282 [CI Skip] 1.4.0-beta.35
skip-checks: true
2020-02-23 12:50:23 +00:00
Jaco Greeff 869f9b7af9 InterfaceTypes -> keyof InterfaceRegistry (#1928)
* InterfaceTypes -> keyof InterfaceRegistry

* Renames
2020-02-23 13:43:37 +01:00
Github Actions a938cb545a [CI Skip] 1.4.0-beta.34
skip-checks: true
2020-02-23 11:54:54 +00:00
Jaco Greeff 553b3df0b2 Augment naming 2020-02-23 12:48:01 +01:00
Jaco Greeff 1fd157364b Use allDefs in augment-types 2020-02-23 12:42:05 +01:00
Github Actions fa7ae72c59 [CI Skip] 1.4.0-beta.33
skip-checks: true
2020-02-23 11:33:12 +00:00
Jaco Greeff 443706a6e0 Extract full interfaceRegistry (#1927)
* Extract full interfaceRegistry

* Move augment to top-level in api & types

* Type augment output

* Update with new augmented paths

* Update RPC path
2020-02-23 12:26:10 +01:00
Github Actions ba462aae8b [CI Skip] 1.4.0-beta.32
skip-checks: true
2020-02-23 10:55:21 +00:00
Jaco Greeff a35da085d6 Augment user type registry (#1926)
* Augment user type registry

* Augment InterfaceRegistry

* Addition api.createType test

* Import '@polkadot/types/interfaceAugment'

* Skip CC on generated

* Move augmentation to full path imports

* Output to augment-*
2020-02-23 11:48:40 +01:00
Github Actions 3d8d2e4988 [CI Skip] 1.4.0-beta.31
skip-checks: true
2020-02-23 09:29:30 +00:00
Jaco Greeff 6c5ef6ecd6 Generation scripts register user types (#1925)
* Generation scripts register user types

* Create augment.ts output

* Remove stray package
2020-02-23 10:22:55 +01:00
Github Actions 3bae45a331 [CI Skip] 1.4.0-beta.30
skip-checks: true
2020-02-22 16:08:46 +00:00
Jaco Greeff 196a0891b8 Use isChildClass & isBigInt from @polkadot/util (#1924)
* Use isChildClass & isBigInt from @polkadot/util

* Allow never

* Bumps

* Common 2.5.1

* Fix overrides

* Remove gh-pages script (in dev)
2020-02-22 17:02:03 +01:00
Github Actions 2a16b04420 [CI Skip] 1.4.0-beta.29
skip-checks: true
2020-02-22 14:00:27 +00:00
Jaco Greeff 790deca695 Update docs for isInBlock (rather late than never) (#1923)
* Update docs for isInBlock (rather late than never)

* Only warn on isInBlock filtering
2020-02-22 14:53:46 +01:00
Github Actions 4ec87dc51c [CI Skip] 1.4.0-beta.28
skip-checks: true
2020-02-22 13:03:37 +00:00
Jaco Greeff 51686f0cd4 Don't clobber global space in WS provider (#1922)
* Don't clbber global space in WS provider

* Re-use getWSClass
2020-02-22 13:56:37 +01:00
Github Actions deddc6dc79 [CI Skip] 1.4.0-beta.27
skip-checks: true
2020-02-22 10:37:34 +00:00
Jaco Greeff 3bf4c3fac5 Adjust class privates via #, where applicable (#1921)
* Adjust class priates via #, where applicable

* Remove stray log

* Cleanup rpc-provider

* Small adjustments

* No private access in tests

* Submittable privates

* Use derive for nonce derivation

* Tweak observers

* Alphabetical privates
2020-02-22 11:29:50 +01:00
Github Actions ccf32a6289 [CI Skip] 1.4.0-beta.26
skip-checks: true
2020-02-21 16:32:43 +00:00
Jaco Greeff 4540495a44 BigInt support (& some TS typing cleanups) (#1919)
* Some TS typing cleanups

* docs building again

* yarn.lock rewrite

* tweaks

* BigInt support

* Checktypes with BigInt

* AccountIndex support for BigInt

* Fix ApiPromise signAsync
2020-02-21 17:26:05 +01:00
Github Actions 429b797b23 [CI Skip] 1.4.0-beta.25
skip-checks: true
2020-02-21 13:20:47 +00:00
Jaco Greeff a3d5ef790c Move StorageData to interface (#1918)
* Move StorageDate to interface

* Move extrinsics interfaces

* Update interface imports
2020-02-21 14:13:23 +01:00
Github Actions b548277c05 [CI Skip] 1.4.0-beta.24
skip-checks: true
2020-02-21 12:40:24 +00:00
Jaco Greeff 2de9317b30 Cleanup CompactAssignments (alignment) (#1917)
* Cleanup CompactAssignments (alignment)

* Remove CompactAssignment

* Add CompactScore
2020-02-21 13:33:21 +01:00
Github Actions 877aa33efa [CI Skip] 1.4.0-beta.23
skip-checks: true
2020-02-21 12:24:23 +00:00
Jaco Greeff 8a9e523b84 Small type usage updates (#1916) 2020-02-21 13:17:40 +01:00
Github Actions 19743d6634 [CI Skip] 1.4.0-beta.22
skip-checks: true
2020-02-21 11:44:20 +00:00
Jaco Greeff 85ec141b56 Lazy reaping types & updates (#1914)
* Lazy reaping types & updates

* system.account queries

* AccountInfo -> ContractAccountInfo tests
2020-02-21 12:37:17 +01:00
Github Actions cb175b4bde [CI Skip] 1.4.0-beta.21
skip-checks: true
2020-02-21 11:19:43 +00:00
Jaco Greeff 8672a2e30e Move length to TypeDef (regularly used), IdentityFields to interface (#1913)
* Move length to TypeDef (regularly used), IdentityFields to interface

* Update api-contracts tests
2020-02-21 12:12:18 +01:00
Github Actions 17936f849b [CI Skip] 1.4.0-beta.20
skip-checks: true
2020-02-21 09:02:17 +00:00
Jaco Greeff 3b9f348223 Cleanup IdentityFields (re-use Set) (#1912)
* Cleanup IdentityFields

* Small cleanups

* Re-add commented IdentityFields
2020-02-21 09:55:18 +01:00
Github Actions b5ff0434d9 [CI Skip] 1.4.0-beta.19
skip-checks: true
2020-02-21 08:40:26 +00:00
Jaco Greeff 877a339353 Extrinsic toHuman aligns with .method (#1911) 2020-02-21 09:33:34 +01:00
Github Actions 716f473887 [CI Skip] 1.4.0-beta.18
skip-checks: true
2020-02-20 20:42:44 +00:00
Jaco Greeff 1c1bfb295d VecFixed now take sub, align ext with UInt (#1909)
* Allow nested definitions for fixed arrays

* Comment nested test

* Don't import U8aFixed + u8
2020-02-20 21:36:12 +01:00
Github Actions dd0a31803f [CI Skip] 1.4.0-beta.17
skip-checks: true
2020-02-20 15:35:25 +00:00
Jaco Greeff e04e5577ed Types for offchain phragmen (#1908) 2020-02-20 16:27:48 +01:00
Github Actions 09617aad2e [CI Skip] 1.4.0-beta.16
skip-checks: true
2020-02-20 12:33:42 +00:00
Jaco Greeff 3d8a57a7d5 Bump dev (#1907) 2020-02-20 13:27:22 +01:00
Github Actions feff458cbf [CI Skip] 1.4.0-beta.15
skip-checks: true
2020-02-20 12:10:28 +00:00
Jaco Greeff 543b4846f9 Fixed64 to an interface (#1906)
* Fixed64 to an interface

* Cleanups, re-use creation

* Fix Int export from codec

* Fix Int export
2020-02-20 13:03:29 +01:00
Github Actions 09ab373b54 [CI Skip] 1.4.0-beta.14
skip-checks: true
2020-02-20 11:58:08 +00:00
Jaco Greeff bec6dba14a Move primitive/Extrinsic -> extrinsic (#1905)
* Move primitive/Extrinsic -> extrinsic

* mv primitive/Generic -> generic

* Update registry with BitVec

* ove BitVec back to primitive

* Remove unused import

* Rebuild interfaces
2020-02-20 12:51:06 +01:00
Github Actions e80bea6680 [CI Skip] 1.4.0-beta.13
skip-checks: true
2020-02-20 09:20:54 +00:00
Jaco Greeff 9119e791d1 Add V4 extrinsic test (#1904)
* Add V4 extinsic test

* Update test with toHuman

* Remove unused import
2020-02-20 10:14:21 +01:00
Github Actions 46b99ae83d [CI Skip] 1.4.0-beta.12
skip-checks: true
2020-02-20 07:28:44 +00:00
Jaco Greeff 92129746dc Move inter-package deps to fixed (as per release) (#1903) 2020-02-20 08:21:17 +01:00
Github Actions 4a8a36d284 [CI Skip] 1.4.0-beta.11
skip-checks: true
2020-02-20 07:07:16 +00:00
Jaco Greeff 2b8ce1b3b7 Check AbstractInt bitLength on construction (#1902)
* Check AbstractInt bitLength on construction

* Language cleanups
2020-02-20 08:00:41 +01:00
Github Actions 0e1e0c0d37 [CI Skip] 1.4.0-beta.10
skip-checks: true
2020-02-19 19:05:23 +00:00
Jaco Greeff 427f821430 Fix 11 Jan 2019 issue (#1900)
* Fix 11 Jan 2019 issue

* Update SignedBlock tests
2020-02-19 19:57:59 +01:00
Github Actions 07307f8374 [CI Skip] 1.4.0-beta.9
skip-checks: true
2020-02-19 14:52:02 +00:00
Jaco Greeff cc5b5c81c9 Subscribe to runtime updates (#1896)
* Subscribe to runtime updates

* console.log -> l.log

* Add l.warn to api augment

* Expand logs with added & removed

* Re-do everything when genesis has changed

* augmentObject complexity

* Dedup [string[], strings[]]

* Update CHANGELOG
2020-02-19 15:45:03 +01:00
Jakub Pánik efbc017940 All heads subscription (#1899)
* [CI Skip]  1.4.0-beta.8

skip-checks: true

* Added support for all heads subscription
2020-02-19 15:30:24 +01:00
Github Actions 849972f7b0 [CI Skip] 1.4.0-beta.8
skip-checks: true
2020-02-19 05:54:02 +00:00
Axel Chalon 01758229eb Add manual seal RPCs (#1894)
* Add manual seal RPCs

* yarn build:interfaces
2020-02-19 06:48:00 +01:00
Github Actions add9b59402 [CI Skip] 1.4.0-beta.7
skip-checks: true
2020-02-18 20:36:58 +00:00
Jaco Greeff c8af75088a Add injectMetadata to api (with decoration) (#1892)
* Add injectMetadata to api (with decoration)

* warn function

* OCD

* OCD #2

* toHuman entry expansion

* CHANGELOG for injectMetadata
2020-02-18 21:30:43 +01:00
Github Actions d4b45921fd [CI Skip] 1.4.0-beta.6
skip-checks: true
2020-02-18 20:14:31 +00:00
Jaco Greeff 30f5baa906 ExtrinsicEra & Vote toHuman (#1893) 2020-02-18 21:08:18 +01:00
Github Actions 7150bdcbea [CI Skip] 1.4.0-beta.5
skip-checks: true
2020-02-18 15:46:08 +00:00
Jaco Greeff d041c0abb2 Support arbitrary UInt<bitLength> definitions (#1891)
* Support arbitrar UInt

* CHANGELOG

* Fix generation

* Move UInt
2020-02-18 16:39:18 +01:00
Github Actions 524e694b90 [CI Skip] 1.4.0-beta.4
skip-checks: true
2020-02-18 15:04:32 +00:00
Jaco Greeff bdd1e4c917 Move H160, H256 & H512 to interfaces (#1890)
* Move H160, H256 & H512 to interfaces

* Test for Hash -> H256

* Replace IHash & Codec.hash with H256

* [u8; n] extends U8aFixed

* Update formatting.ts
2020-02-18 15:56:50 +01:00
Github Actions 7233d7c754 [CI Skip] 1.4.0-beta.3
skip-checks: true
2020-02-18 14:00:33 +00:00
Jaco Greeff aee09c48b9 Use static with for derived H*, U* & I* primitives (#1889)
* Usestatic with for derived H*, U* & I* primitives

* Add with override tests

* Fix linting
2020-02-18 14:53:43 +01:00
Github Actions 7edbc58129 [CI Skip] 1.4.0-beta.2
skip-checks: true
2020-02-18 12:41:52 +00:00
Jaco Greeff ad2939cc4f Rework Unconstructable type (#1888)
* Rework Unconstructable type

* hasType updates

* Unknown -> Unconstructable (as it was)

* Remove commented test

* class name

* getOrThrow tests

* typo.

* getOrUnknown
2020-02-18 13:35:42 +01:00
Github Actions e984c74ca6 [CI Skip] 1.4.0-beta.1
skip-checks: true
2020-02-18 12:26:54 +00:00
Jaco Greeff a5c8e3c4e1 Convert DigestItem to definition (#1886)
* Convert DigestItem to definition

* Remove GenericDigestItem export

* Update CHANGELOG.md
2020-02-18 13:20:29 +01:00
Github Actions 1e5191d695 [CI Skip] 1.4.0-beta.0
skip-checks: true
2020-02-18 09:12:00 +00:00
Jaco Greeff b46093e5d3 Add .toHuman on SubmittableResult (#1885) 2020-02-18 10:05:48 +01:00
Github Actions 64f0d7b2a6 [CI Skip] 1.3.1
skip-checks: true
2020-02-18 08:40:23 +00:00
Jaco Greeff 4a1e504ca2 1.3 (#1883)
* 1.3

* Pair create update

* CHANGELOG update
2020-02-18 09:34:35 +01:00
Github Actions ebf3f4491e [CI Skip] 1.3.0-beta.11
skip-checks: true
2020-02-17 14:23:11 +00:00
Jaco Greeff 849f519efe Add GH actions yarn cache (#1881) 2020-02-17 15:16:09 +01:00
Github Actions accc2b4f7d [CI Skip] 1.3.0-beta.10
skip-checks: true
2020-02-17 13:15:05 +00:00
Jaco Greeff 01abc030f9 Cleanup stray accountNonce reference (#1880)
* Cleanup stray accountNonce reference

* Comment for system.account upgrades
2020-02-17 14:08:13 +01:00
Github Actions e041946de5 [CI Skip] 1.3.0-beta.9
skip-checks: true
2020-02-17 11:50:02 +00:00
Jaco Greeff 502e54ce5c Bump common (#1879)
* Bump common

* Add documentation to extended call

* TODO for toHuman event

* CHANGELOG
2020-02-17 12:43:03 +01:00
Github Actions 12986f0cda [CI Skip] 1.3.0-beta.8
skip-checks: true
2020-02-17 10:50:00 +00:00
Jaco Greeff 83d780220c Add toHuman with base formatting (#1878)
* Add toHuman with base formatting

* Balance formatting

* Externalize Enum decode
2020-02-17 11:43:08 +01:00
Github Actions ec7848ae92 [CI Skip] 1.3.0-beta.7
skip-checks: true
2020-02-17 07:53:42 +00:00
Jaco Greeff 2b5be7eaab Remove unexported staking.infostash derive (duplicated as .query) (#1877) 2020-02-17 08:46:59 +01:00
Github Actions 21f4e3107a [CI Skip] 1.3.0-beta.6
skip-checks: true
2020-02-17 07:16:52 +00:00
Jaco Greeff 8a152ea4c0 Split generation scripts into @polkadot/typegen (#1875)
* Split generation scripts into @polkadot/typegen

* Remove moved files

* CC overrides

* interfaces typo

* Cleanup imports

* Some import combinations

* Updates

* Generation updates

* Cleanups, split js wrapper & ts logic

* Rename jiggle 1

* Rename jiggle 2

* Style cleanups

* Expose enry function for scripts

* Typo

* Update script copy & include locations

* CC exclude location

* Minor adjustments

* argv parsing into main
2020-02-17 08:09:59 +01:00
Github Actions fd7b38e781 [CI Skip] 1.3.0-beta.5
skip-checks: true
2020-02-17 06:16:35 +00:00
Jeremías Díaz 5df22835f6 fix: make bn.js into a regular dependency (#1876)
Since `AbstractInt` is exposing `toBn(): BN` which uses `bn.js` types,
projects using polkadot are forced to install `@types/bn.js` on their own,
otherwise they get compilation errors
2020-02-17 07:09:30 +01:00
Github Actions 6a828eb11a [CI Skip] 1.3.0-beta.4
skip-checks: true
2020-02-16 16:48:32 +00:00
Jaco Greeff ad2b1abdc9 Move @polakdot/jsonrpc -> packages/jsonrpc (#1874)
* Move @polakdot/jsonrpc -> packages/jsonrpc

* Update links
2020-02-16 17:41:45 +01:00
Github Actions d3dc2cb00a [CI Skip] 1.3.0-beta.3
skip-checks: true
2020-02-16 12:58:16 +00:00
Jaco Greeff 921e55a82e Move types/codec/create -> types/create (#1871)
* Move types/codec/create -> types/create

* Update imports after move

* Cleanups

* Cleanup code circular deps

* Re-add dropped interfaces

* Drop duplicated code

* Fix imports

* Remove whacky comment
2020-02-16 13:51:37 +01:00
Github Actions fde076152a [CI Skip] 1.3.0-beta.2
skip-checks: true
2020-02-16 12:20:24 +00:00
Jaco Greeff 6e535b0502 Don't make types depend on api (dev deps) (#1869)
* Don't make types depend on api (dev deps)

* Naming cleanups

* Remove skipped tests

* Splt types/types into chunks

* Re-add setChainProperties (properties?: ChainProperties): void;
2020-02-16 13:13:56 +01:00
Github Actions 1ddad84d7e [CI Skip] 1.3.0-beta.1
skip-checks: true
2020-02-16 10:16:34 +00:00
Jaco Greeff 1e975c68ee Make chain properties available on registry (#1868)
* Make chain properties available on registry

* Use registry chainSS58 to format address

* CHANGELOG

* CHANGELOG typo

* Fix tests vis setChainProperties

* Cleanup tests via chain property set

* Remove global ss58 format set
2020-02-16 11:09:48 +01:00
Github Actions 5c962cf093 [CI Skip] 1.3.0-beta.0
skip-checks: true
2020-02-16 09:27:50 +00:00
Jaco Greeff 07f55af202 Documentation of ready rejections (#1870) 2020-02-16 10:21:19 +01:00
Github Actions 6c8dd4be3b [CI Skip] 1.2.1
skip-checks: true
2020-02-16 07:28:13 +00:00
Jaco Greeff a339491d07 1.2 (#1867) 2020-02-16 08:21:50 +01:00
Github Actions ea87472354 [CI Skip] 1.2.0-beta.30
skip-checks: true
2020-02-16 07:01:44 +00:00
Jaco Greeff 0ed156e5d9 FAQ entry for system.account (#1866) 2020-02-16 07:54:46 +01:00
Github Actions 59590540d8 [CI Skip] 1.2.0-beta.29
skip-checks: true
2020-02-16 06:41:42 +00:00
Jaco Greeff c465252e69 Make Metadata <-> hex encoding work (#1862)
* Make Metadata <-> hex encoding work

* Cleanup encoded, only toString exposes santized

* toHex is actual original toHex, remove override

* Update CHANGELOG

* CHANGELOG for .entries argument typing

* Update CHANGELOG.md

* Manual check type for DoubleMap

* Comment around super.toString usage

* Runtime version
2020-02-16 07:34:45 +01:00
Github Actions 0822d4d8c6 [CI Skip] 1.2.0-beta.28
skip-checks: true
2020-02-15 16:58:04 +00:00
Jeremías Díaz 2c3eee4c67 fix: make entries accept args for double maps (#1864) 2020-02-15 17:51:01 +01:00
Github Actions b069710008 [CI Skip] 1.2.0-beta.27
skip-checks: true
2020-02-15 12:10:44 +00:00
Jaco Greeff 9a7e0bf82d Bump deps (#1861)
* Bump deps

* Bump common
2020-02-15 13:03:34 +01:00
Github Actions 4f520f5de6 [CI Skip] 1.2.0-beta.26
skip-checks: true
2020-02-15 08:56:55 +00:00
Jaco Greeff 79ee2ede3d Cleanup date test with locale offset (#1860)
* Cleanup date test with locale offset

* CHANGELOG

* Add dates to CHANGELOG
2020-02-15 09:49:39 +01:00
Github Actions f6b02e1de1 [CI Skip] 1.2.0-beta.25
skip-checks: true
2020-02-15 08:23:22 +00:00
Jaco Greeff c11b0dffc5 Adjust CHANGELOG with all latest changes (#1859) 2020-02-15 09:17:07 +01:00
Github Actions 0935c39906 [CI Skip] 1.2.0-beta.24
skip-checks: true
2020-02-15 07:59:29 +00:00
Keith IngramandJaco Greeff ee622f3d2b Add api.derive.registrar.parachains (#1856)
* api.derive.registrar.parachains

* remove api parse

* suggestions

* some

* Update packages/api-derive/src/parachains/all.ts

* Update packages/api-derive/src/index.ts

* Update packages/api-derive/src/index.ts

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-02-15 08:52:40 +01:00
Github Actions ae350aae6f [CI Skip] 1.2.0-beta.23
skip-checks: true
2020-02-15 07:41:46 +00:00
Axel Chalon 26c59f6d6e Format documentation strings properly & refactor MetadataMd (#1858)
* Format docs strings properly

* Refactor MetadataMd
2020-02-15 08:35:15 +01:00
Github Actions 51c6262327 [CI Skip] 1.2.0-beta.22
skip-checks: true
2020-02-14 15:21:11 +00:00
Jaco Greeff 07ed405610 Bump common (& add @types/bn.js) (#1855) 2020-02-14 16:14:18 +01:00
Github Actions cd5d7b10c3 [CI Skip] 1.2.0-beta.21
skip-checks: true
2020-02-14 14:47:36 +00:00
Jaco Greeff 8e5b43bf62 Add isInBlock, isRetracted (...) to status enum (#1852) 2020-02-14 15:40:56 +01:00
Github Actions 49f3e36c46 [CI Skip] 1.2.0-beta.20
skip-checks: true
2020-02-14 13:54:07 +00:00
Jaco Greeff 7e25145fbf Format known storage (align with others) (#1851) 2020-02-14 14:46:42 +01:00
Github Actions b5bc2ccfaf [CI Skip] 1.2.0-beta.19
skip-checks: true
2020-02-14 13:28:31 +00:00
Jaco Greeff 0e7c508d7f Split private statics from Call (#1849) 2020-02-14 14:21:38 +01:00
Github Actions 4e1c377ceb [CI Skip] 1.2.0-beta.18
skip-checks: true
2020-02-14 12:59:42 +00:00
Jaco Greeff 5c4920db6f Remove balances.freeBalance & system.accountNonce refs (#1847)
* Remove freeBalance references

* Cleanup placeholders

* Add substrate templates to .gitignore

* Swap all use of system.accountNonce

* typo
2020-02-14 13:52:45 +01:00
Github Actions 679e31668e [CI Skip] 1.2.0-beta.17
skip-checks: true
2020-02-14 09:21:48 +00:00
Jaco Greeff 00e567b662 Bump metadata (#1844)
* Bump metadata

* Copy error

* Bump dev

* Fix linting

* Adjust some tests

* FIXME for formatting
2020-02-14 10:15:11 +01:00
Github Actions 503193d6c2 [CI Skip] 1.2.0-beta.16
skip-checks: true
2020-02-14 07:18:45 +00:00
Jaco Greeff 5e82c97c8a Bump dev (#1843)
* Bump dev

* Bumps
2020-02-14 08:12:57 +01:00
Github Actions 8c12c227b4 [CI Skip] 1.2.0-beta.15
skip-checks: true
2020-02-13 23:11:05 +00:00
Jaco Greeff d72456fb26 Bump dev (#1842) 2020-02-14 00:04:43 +01:00
Github Actions ca6d78e7ec [CI Skip] 1.2.0-beta.14
skip-checks: true
2020-02-13 22:08:12 +00:00
Axel Chalon 8210c708ac Add errors to documentation (#1841)
* Add errors to docs

* Fix broken anchor links (camel-case links but lowercase anchors)
2020-02-13 23:01:05 +01:00
Github Actions 41764562e1 [CI Skip] 1.2.0-beta.13
skip-checks: true
2020-02-13 21:32:08 +00:00
Axel Chalon 66c8e5b4e8 Add author_{hasKey, hasSessionKeys} RPCs (#1837)
* Add author_{hasKey, hasSessionKeys} RPCs

* yarn docs

* Revert "yarn docs"

This reverts commit c23624e1d844fcd8821ccf4bd73f0175a3a10526.
2020-02-13 22:24:11 +01:00
Github Actions ca7fe86089 [CI Skip] 1.2.0-beta.12
skip-checks: true
2020-02-13 14:47:22 +00:00
Jaco Greeff cf2fbfce26 Bump dev (#1839) 2020-02-13 15:39:40 +01:00
Github Actions d69113ca5a [CI Skip] 1.2.0-beta.11
skip-checks: true
2020-02-12 17:07:57 +00:00
Jaco Greeff d7eb40caf5 Additional explicit packages (#1836)
* Additional explicit packages

* Package name
2020-02-12 17:59:54 +01:00
Github Actions 2eda438eac [CI Skip] 1.2.0-beta.10
skip-checks: true
2020-02-12 15:41:07 +00:00
Jaco Greeff beddc3e0a5 Explicit deps & bumps (#1835)
* Explicit deps & bumps

* Update CHANGELOG.md
2020-02-12 16:33:57 +01:00
Github Actions ac1ae34e37 [CI Skip] 1.2.0-beta.9
skip-checks: true
2020-02-11 20:35:54 +00:00
Jaco Greeff 52953f248b Adjust composite version (#1833) 2020-02-11 21:28:29 +01:00
Github Actions e027f865aa [CI Skip] 1.2.0-beta.8
skip-checks: true
2020-02-11 13:23:21 +00:00
Jaco Greeff d4e3e546dc Cleanup sanitize with groupings (#1832)
* Cleanup sanitize with groupings

* Small additional cleanups
2020-02-11 14:16:01 +01:00
Github Actions 6cb5476c80 [CI Skip] 1.2.0-beta.7
skip-checks: true
2020-02-11 09:43:56 +00:00
Jaco Greeff 52ffa175a9 Versioned polkadot overrides (#1831) 2020-02-11 10:36:01 +01:00
Github Actions ba2cd0cff5 [CI Skip] 1.2.0-beta.6
skip-checks: true
2020-02-10 20:33:01 +00:00
Keith Ingram fefcc2e0dc update parachains types (#1830) 2020-02-10 15:25:14 -05:00
Github Actions c8fbed2a12 [CI Skip] 1.2.0-beta.5
skip-checks: true
2020-02-10 17:52:41 +00:00
Jaco Greeff 6581d779c7 Alias Address -> AccountId for polkadot/kusama (#1825)
* Swap Address -> LookupSource (correct aliasses)

* Adjust overrides with explicit LookupSource

* Map Lookup{Source,Target}

* Adjust overrides

* Comment Address -> AccountId (for now)

* Fix typo in comments

* Map Address -> AccountId

* CHANGELOG
2020-02-10 18:44:12 +01:00
Github Actions cab5b8bff7 [CI Skip] 1.2.0-beta.4
skip-checks: true
2020-02-08 14:03:31 +00:00
Jaco Greeff 480c0abda8 Add BitVec type (#1822)
* Add BitVec type

* Update comments

* Fixup decoding check

* Fix linting
2020-02-08 14:56:08 +01:00
Github Actions 866c5769bb [CI Skip] 1.2.0-beta.3
skip-checks: true
2020-02-08 13:53:08 +00:00
Jaco Greeff d8141198e1 Provide mapping for LookupSource & LookupTarget (#1823)
* Provide mapping for LookupSource & LookupTarget

* Type overrides for Kusama-next

* Fix LookupSource for Kusama-next

* Fixup tests with lookup
2020-02-08 14:46:08 +01:00
Github Actions a6a1a52d61 [CI Skip] 1.2.0-beta.2
skip-checks: true
2020-02-08 12:19:01 +00:00
Jaco Greeff b6534d2958 Polkadot V11 metadata (#1821) 2020-02-08 13:11:33 +01:00
Github Actions 3645cde156 [CI Skip] 1.2.0-beta.1
skip-checks: true
2020-02-07 14:50:37 +00:00
Jaco Greeff 2ac3640900 Update AccountIndex derive (#1820) 2020-02-07 15:43:21 +01:00
Github Actions e379e7fabd [CI Skip] 1.2.0-beta.0
skip-checks: true
2020-02-07 13:42:08 +00:00
Jaco Greeff 69dae84a42 Update .123trigger (#1819) 2020-02-07 14:34:57 +01:00
Jaco Greeff fe52484547 Query nonce/data from system.account (as available) (#1814)
* Query nonce/data from sustem.account (as available)

* Detect new nonce query, retrieve

* Call system.account for nonce & balance

* Update CHANGELOG
2020-02-07 14:20:34 +01:00
Jaco Greeff faa12a68f7 Move internal decoding to top-level-functions (#1818)
* Move internal decoding to top-level-functions

* Cleanup imports
2020-02-07 14:12:30 +01:00
Github Actions f6490217ec [CI Skip] 1.1.1
skip-checks: true
2020-02-06 15:12:35 +00:00
Jaco Greeff 601cc62d70 1.1 (#1815) 2020-02-06 16:05:04 +01:00
Github Actions 201480be56 [CI Skip] 1.1.0-beta.22
skip-checks: true
2020-02-06 14:17:09 +00:00
Jaco Greeff 519823bc0e Add resolver for jest (#1813) 2020-02-06 15:09:36 +01:00
Github Actions 0b134c1eb8 [CI Skip] 1.1.0-beta.21
skip-checks: true
2020-02-06 13:16:34 +00:00
Jaco Greeff e6e96aa9c9 Make indices module optional (#1812)
* Make indices optional

* Updtae contracts with optional creation

* Flatten contract fees
2020-02-06 14:09:29 +01:00
Github Actions 84d0d8594e [CI Skip] 1.1.0-beta.20
skip-checks: true
2020-02-06 09:54:57 +00:00
Jaco Greeff 6be25966d8 Enum .toJSON() to return type name as specified (#1811)
* Enum `.toJSON()` to return type name as specified

* Fix text compares
2020-02-06 10:48:33 +01:00
Github Actions a5eb11e5f3 [CI Skip] 1.1.0-beta.19
skip-checks: true
2020-02-05 15:22:43 +00:00
Jaco Greeff 19f87aac4d Council memebrs with no election info (#1810) 2020-02-05 16:15:36 +01:00
Github Actions b217a59310 [CI Skip] 1.1.0-beta.18
skip-checks: true
2020-02-05 14:23:56 +00:00
Jaco Greeff 2de7a3c130 Add .keyPrefix for storage keys (#1809)
* Add .keyPrefix for storage keys

* Fix hex length
2020-02-05 15:15:49 +01:00
Github Actions deecf4853e [CI Skip] 1.1.0-beta.17
skip-checks: true
2020-02-04 15:19:57 +00:00
Jaco Greeff 8889e69341 Bump common (#1807)
* Bump common

* yarn.lock
2020-02-04 16:12:18 +01:00
Github Actions 14194a363e [CI Skip] 1.1.0-beta.16
skip-checks: true
2020-02-04 11:23:05 +00:00
Jaco Greeff 9c50e81ab9 Cleanup sanitize boxes (#1805)
* Cleanup sanitize boxes

* yarn.lock

* Add space before box as allowed
2020-02-04 12:16:18 +01:00
Jaco Greeff 6505e73355 Adjust submittable augmentation (#1806)
* Adjust submittable augmentation

* Add missing extends
2020-02-04 12:15:42 +01:00
Github Actions cefeb37ae6 [CI Skip] 1.1.0-beta.15
skip-checks: true
2020-02-03 16:32:53 +00:00
Jaco Greeff 9e29e89baf Update known extensions (with Polkadot) (#1800)
* Update known extensions (with Polkadot)

* Split definitions for signed extensions
2020-02-03 17:25:33 +01:00
Github Actions b82c90679d [CI Skip] 1.1.0-beta.14
skip-checks: true
2020-02-03 12:49:36 +00:00
Jaco Greeff eeb8d20e58 Bump common (detection) (#1799) 2020-02-03 13:42:49 +01:00
Github Actions b891edbd37 [CI Skip] 1.1.0-beta.13
skip-checks: true
2020-02-03 11:03:16 +00:00
Jaco Greeff 2ee3afcd61 Expand enum & struct defnitions, generator strict mode (#1798) 2020-02-03 11:56:06 +01:00
Github Actions 328630fb17 [CI Skip] 1.1.0-beta.12
skip-checks: true
2020-02-03 09:27:36 +00:00
Jaco Greeff 325080cf71 Cleanup some generation duplication (#1797)
* Cleanup some generation duplicaton

* Override for Metadata import

* Import order in generators
2020-02-03 10:20:33 +01:00
Github Actions 549a536328 [CI Skip] 1.1.0-beta.11
skip-checks: true
2020-02-02 19:26:52 +00:00
Jaco Greeff 23f41a0bab Exclude all augment from cc 2020-02-02 20:19:41 +01:00
Jaco Greeff 5e0c0ba91a Align jsonrpc augmentation with others (#1796) 2020-02-02 20:16:41 +01:00
Github Actions 812a077e63 [CI Skip] 1.1.0-beta.10
skip-checks: true
2020-02-02 18:54:18 +00:00
Jaco Greeff 6ba28c8ad2 Expand simple enums in type generation (#1795) 2020-02-02 19:47:19 +01:00
Github Actions 6cd0074ce4 [CI Skip] 1.1.0-beta.9
skip-checks: true
2020-02-02 18:24:56 +00:00
Jaco Greeff b3d592357f Override for Vote type (not a struct, not caught) (#1794)
* Override for Vote type (not a struct, not caught)

* Generate simple Vote object (first, Struct to be done)

* Comment for hex type (string)

* Expand conviction (like we should on enum)

* Cool, use conviction def for input

* aye is required

* Remove FIXMEs
2020-02-02 19:17:33 +01:00
Github Actions f499946f1f [CI Skip] 1.1.0-beta.8
skip-checks: true
2020-02-02 08:19:04 +00:00
Jaco Greeff 56e28bed7f Rename frozenFee (#1792) 2020-02-02 09:11:49 +01:00
Github Actions c76fb20a83 [CI Skip] 1.1.0-beta.7
skip-checks: true
2020-02-02 07:57:22 +00:00
Jaco Greeff 9d4b0ea56a Update Substrate with vesting (#1790)
* Update Substrate with vesting

* Update balances & vesting queries with compat)

* Split base account queries

* Linting, simpler referendum voters

* Fix (some) tests
2020-02-02 08:50:37 +01:00
Github Actions f9d569ddd1 [CI Skip] 1.1.0-beta.6
skip-checks: true
2020-02-01 20:27:44 +00:00
Jaco Greeff 7221a3637c Add UInt .isMax() (#1791)
* Add UInt .isMax()

* Filter lockedBlance by max
2020-02-01 21:20:48 +01:00
Github Actions 438c830366 [CI Skip] 1.1.0-beta.5
skip-checks: true
2020-02-01 17:47:00 +00:00
Jaco Greeff 3d0fd5a6a8 Warn on unknown extensions (once per registry) (#1788) 2020-02-01 18:40:45 +01:00
Github Actions de57876c7f [CI Skip] 1.1.0-beta.4
skip-checks: true
2020-02-01 13:24:47 +00:00
Jaco Greeff b24a1ff350 SignedExtension injection into payload (#1778)
* Make a start ... V11 definitions

* V11 conversion

* Fix ErrorMetadataV11

* Extension point for signed extensions

* Add V11 to mapped

* Expand toLatest comments

* Make a start at signer extension defs

* exports

* Extract extension definitions

* Add extension registration

* Remove old override

* Get definition on extrinsic creation

* Add missing V4 base

* Optional extrinsic

* Pull extrinsic version from metadata (if available)

* asLatest.extrinsic should now be available

* Don't export non-types for Extrinsic

* Setup registry with default extensions

* Async test really runs async

* Trace test failures (V1 orig, V4 now)

* CHANGELOG

* Add extension data to actual signature

* Cleanups

* Return cleanups

* Mark all type deocde static internal

* Apply extensions fully to payload

* Cleanup duplication

* ExtrinsicSignature* via createType
2020-02-01 14:17:17 +01:00
Github Actions 5f8c623179 [CI Skip] 1.1.0-beta.3
skip-checks: true
2020-02-01 11:07:19 +00:00
Jaco Greeff 00026a173f Keep original doc-line formats (#1787) 2020-02-01 11:59:47 +01:00
Github Actions 8da895efd4 [CI Skip] 1.1.0-beta.2
skip-checks: true
2020-02-01 10:23:48 +00:00
Jaco Greeff 89d029eca3 Expand bool & Enum generation (#1785)
* Expand bool & Enum generation

* Swap consts to Augmented (align with others)
2020-02-01 11:16:27 +01:00
Github Actions ac2a7eea67 [CI Skip] 1.1.0-beta.1
skip-checks: true
2020-01-31 21:42:23 +00:00
Jaco Greeff 4f0e573adf Cleanup to tx generation (#1784) 2020-01-31 22:34:24 +01:00
Github Actions 8417eff2b3 [CI Skip] 1.1.0-beta.0
skip-checks: true
2020-01-31 14:41:36 +00:00
Jaco Greeff 4aa5693906 Extend type generation (#1783)
* Cleanup type overrides

* Generate (with catch-all removal)

* Progress

* Re-gen tx types

* Remove unneeded option check

* Linting updates

* Update CHANGELOG (cleanups as per comments)
2020-01-31 15:34:06 +01:00
Jaco Greeff 982665c337 Update CHANGELOG with missing change (#1782) 2020-01-30 17:22:56 +01:00
Github Actions 6dce57b394 [CI Skip] 1.0.1
skip-checks: true
2020-01-30 16:06:14 +00:00
Jaco Greeff ca7edf1593 1.0 (#1781)
* 1.0

* signAsync typing

* Merge master
2020-01-30 16:59:04 +01:00
Jakub Pánik 59e069f091 Added unsubscribe return function to wsProvider.on() (#1780)
* Added unsubscribe return function to wsProvider.on()

* Updated mocks, added noop to http provider
2020-01-30 16:48:11 +01:00
Github Actions 65ff5c8f30 [CI Skip] 1.0.0-beta.44
skip-checks: true
2020-01-30 14:58:02 +00:00
Jaco Greeff 1c327c60d9 Metadata V11 (#1774)
* Make a start ... V11 definitions

* V11 conversion

* Fix ErrorMetadataV11

* Extension point for signed extensions

* Add V11 to mapped

* Expand toLatest comments
2020-01-30 15:49:37 +01:00
Github Actions de9f033d99 [CI Skip] 1.0.0-beta.43
skip-checks: true
2020-01-30 11:16:33 +00:00
Jaco Greeff 9c913fb482 Cleanup generated doc (only top-level docs) (#1777)
* Cleanup generated doc (only top-level docs)

* Single-line name
2020-01-30 12:09:16 +01:00
Github Actions e19e530c1c [CI Skip] 1.0.0-beta.42
skip-checks: true
2020-01-29 21:28:15 +00:00
Jaco Greeff aa91e0b8b5 Small gen doc updates (#1773) 2020-01-29 22:20:54 +01:00
Github Actions 9a6ba2fe0f [CI Skip] 1.0.0-beta.41
skip-checks: true
2020-01-29 17:33:29 +00:00
Jaco Greeff de853d9cc0 Add EVM types (#1771)
* Add EVM types

* Add findError for metadata
2020-01-29 18:26:06 +01:00
Github Actions 07063134b8 [CI Skip] 1.0.0-beta.40
skip-checks: true
2020-01-29 16:56:40 +00:00
Jaco Greeff 20b8cd762d Add sidebar doc link to TS user gen (#1770) 2020-01-29 17:49:40 +01:00
Github Actions bd3338c3df [CI Skip] 1.0.0-beta.39
skip-checks: true
2020-01-29 16:44:42 +00:00
Jaco Greeff 4c328964d5 Allow chain to use user-defined types (#1769)
* Allow chain to use user-defined types

* --package docs on chain extract
2020-01-29 17:37:19 +01:00
Github Actions 70e5e2b60a [CI Skip] 1.0.0-beta.38
skip-checks: true
2020-01-29 14:59:20 +00:00
Jaco Greeff 4329c0a411 Add polkadot-types-from-{chain,defs} (#1766)
* Add polkadot-types-from-{chain,defs}

* Generate scripts working

* User types generation docs

* Rebuild with new comment line
2020-01-29 15:51:23 +01:00
Github Actions 0713afa0e0 [CI Skip] 1.0.0-beta.37
skip-checks: true
2020-01-29 09:43:41 +00:00
Jaco Greeff 8b518a909b Bump deps (#1765) 2020-01-29 10:36:04 +01:00
Github Actions 794f1fe398 [CI Skip] 1.0.0-beta.36
skip-checks: true
2020-01-28 22:07:54 +00:00
Lae 51423e20b5 Make sure awaiting on an api object won't stuck forever on error (#1763)
* Make sure awaiting on an api object won't stuck forever when error occurs.

* Fix lint issues.
2020-01-28 23:01:07 +01:00
Github Actions d4b27ba670 [CI Skip] 1.0.0-beta.35
skip-checks: true
2020-01-28 21:52:49 +00:00
Jaco Greeff 8ca194a3d2 Cleanup society types (#1764)
* Cleanup society types

* Update types
2020-01-28 22:47:07 +01:00
Github Actions 5fd2c70924 [CI Skip] 1.0.0-beta.34
skip-checks: true
2020-01-28 21:03:11 +00:00
Jaco Greeff d36ee7de2f Add society hasDefender (#1762) 2020-01-28 21:55:55 +01:00
Github Actions 3683f9e5ff [CI Skip] 1.0.0-beta.33
skip-checks: true
2020-01-28 18:22:37 +00:00
Jaco Greeff 18c302d2cf Allow author extract from empty (#1761) 2020-01-28 19:16:08 +01:00
Github Actions 1686f8b357 [CI Skip] 1.0.0-beta.32
skip-checks: true
2020-01-28 17:58:51 +00:00
Jaco Greeff 15158b763c Bump common (#1760) 2020-01-28 18:51:17 +01:00
Github Actions f5f338a9ae [CI Skip] 1.0.0-beta.31
skip-checks: true
2020-01-28 17:17:15 +00:00
Jaco Greeff 458dec53dc Session validators availability detection (#1759) 2020-01-28 18:10:06 +01:00
Github Actions ab05045686 [CI Skip] 1.0.0-beta.30
skip-checks: true
2020-01-28 16:47:39 +00:00
Jaco Greeff b2c84eb461 Bump deps (#1758)
* Bump deps

* api detect
2020-01-28 17:40:57 +01:00
Github Actions 1ee1d70d55 [CI Skip] 1.0.0-beta.29
skip-checks: true
2020-01-28 15:25:22 +00:00
Jaco Greeff 7de647ec0b Cleanup module-specific type-overrides (#1756) 2020-01-28 16:18:40 +01:00
Github Actions cedbd8fa06 [CI Skip] 1.0.0-beta.28
skip-checks: true
2020-01-28 14:40:38 +00:00
Jaco Greeff cba34b4b65 Fill signAsync with expanded chain options (#1753)
* Fill signAsync with expanded chain options

* Use mapTo

* Fill test with defined storage value

* Remove .only
2020-01-28 15:33:44 +01:00
Github Actions 1a99d67c77 [CI Skip] 1.0.0-beta.27
skip-checks: true
2020-01-28 10:13:45 +00:00
Jaco Greeff 2a5c5ce3fe Only include derives with parent query (#1755)
* Only include derives with parent query

* Update CHANGELOG
2020-01-28 11:07:02 +01:00
Github Actions e4ca0a1c64 [CI Skip] 1.0.0-beta.26
skip-checks: true
2020-01-28 08:59:33 +00:00
Jaco Greeff e6018f2f75 Add society-specific Vote type (#1754)
* Add society-specific Vote type

* Cnvert storage types via toLatest
2020-01-28 09:52:40 +01:00
Github Actions a9b4f8d841 [CI Skip] 1.0.0-beta.25
skip-checks: true
2020-01-27 18:42:41 +00:00
Amaury Martiny 7fe68857a0 Init api when provider is already connected (#1752)
* Init api when provider is already connected

* Spacing
2020-01-27 19:35:38 +01:00
Github Actions 4f63fc77a3 [CI Skip] 1.0.0-beta.24
skip-checks: true
2020-01-27 16:20:13 +00:00
Jaco Greeff 6e2ad7789e Expose .entries() for DoubleMaps (#1750)
* Expose .entries() for DoubleMaps

* DoubleMap vs Map test

* Fix decoration

* Remove prefixed map

* Allow SoubleMap entries() with arguments

* DoubleMap with & without params

* Remove debug log

* Update CHANGELOG

* ... and working... finally.

* Cleanup debug logs
2020-01-27 17:13:53 +01:00
Github Actions edb856c94f [CI Skip] 1.0.0-beta.23
skip-checks: true
2020-01-27 14:12:40 +00:00
Jaco Greeff 2f215fe2de Cleanup entries() (#1751) 2020-01-27 15:07:00 +01:00
Github Actions ffa1279c64 [CI Skip] 1.0.0-beta.22
skip-checks: true
2020-01-27 11:56:57 +00:00
Jaco Greeff 83aca87dac Skip types.ts for typedoc (#1749) 2020-01-27 12:50:36 +01:00
Github Actions bf782f6f65 [CI Skip] 1.0.0-beta.21
skip-checks: true
2020-01-27 11:43:36 +00:00
Jaco Greeff 7adad82786 Remove v11 metadata (#1748)
* Remove v11 metadata

* Linting
2020-01-27 12:37:01 +01:00
Github Actions 693cf855f0 [CI Skip] 1.0.0-beta.20
skip-checks: true
2020-01-27 08:45:51 +00:00
Jaco Greeff 854a520517 Mark some function @internal (no doc extraction) (#1746) 2020-01-27 09:38:02 +01:00
Github Actions 6e6fc98cd1 [CI Skip] 1.0.0-beta.19
skip-checks: true
2020-01-26 09:36:27 +00:00
Jaco Greeff 3db15e73a5 Bump deps (#1745)
* Bump deps

* Fix test expectation

* Mark doc internal
2020-01-26 10:27:44 +01:00
Github Actions 215b659a9a [CI Skip] 1.0.0-beta.18
skip-checks: true
2020-01-23 17:12:43 +00:00
Jaco Greeff 7ef945d15b Make invalid V9 metadata parse (won't work, but parses) (#1743)
* Make invalid V9 metadata parse (won't work, but parses)

* Add invalid to V4 (simpler, no code)
2020-01-23 18:06:25 +01:00
Github Actions 73ec345fcc [CI Skip] 1.0.0-beta.17
skip-checks: true
2020-01-22 14:59:54 +00:00
Jaco Greeff c1c537a3b5 Type aliases on a per-module basis (#1740)
* Type aliasses on a per-module basis

* Remove test interface

* Update wrapper

* Move known types to types
2020-01-22 15:51:23 +01:00
Github Actions dc64076c79 [CI Skip] 1.0.0-beta.16
skip-checks: true
2020-01-22 14:22:49 +00:00
Jaco Greeff da8ff51615 Remove unmaintained & outdated E2E (#1739) 2020-01-22 15:14:57 +01:00
Github Actions 60b1bc87a4 [CI Skip] 1.0.0-beta.15
skip-checks: true
2020-01-22 09:41:19 +00:00
Jaco Greeff 7ed1857589 Update SlashingSpans (#1738)
* Update SlashingSpans

* Digest 0toX -> ToX
2020-01-22 10:33:05 +01:00
Github Actions 4c0e60f3d6 [CI Skip] 1.0.0-beta.14
skip-checks: true
2020-01-21 13:52:44 +00:00
Jaco Greeff 20ed3bb5fe Allow passing of signer via sign options (#1734)
* Allow passing of signer via sign options

* Pass signer via api.sign
2020-01-21 14:45:53 +01:00
Jaco Greeff be3f9c8fe8 Remove outdated derive + combineLatest comment (#1733)
As per https://github.com/polkadot-js/api/pull/1732/files#r368599021
2020-01-21 14:45:07 +01:00
Github Actions e850955e55 [CI Skip] 1.0.0-beta.13
skip-checks: true
2020-01-20 13:05:49 +00:00
Jaco Greeff eb5ee9860b Multi query adjustments (#1732) 2020-01-20 13:58:07 +01:00
Github Actions f31bbdde02 [CI Skip] 1.0.0-beta.12
skip-checks: true
2020-01-19 21:55:43 +00:00
Jaco Greeff f67c435378 Trigger build 2020-01-19 22:49:09 +01:00
Jaco Greeff bf9a60a202 Update .123trigger 2020-01-19 22:46:50 +01:00
Jaco Greeff 9c3c07fa9b Derives for society (#1727)
* Deries for society

* Candidates

* Add overview

* Candidate types

* WIP, stash before merge

* Linting

* Readability

* Typo

* Split option maps
2020-01-19 21:56:39 +01:00
Github Actions 11786ca102 [CI Skip] 1.0.0-beta.11
skip-checks: true
2020-01-19 20:14:25 +00:00
Nikolay Volf ffaea83e3e Fix typo (#1730) 2020-01-19 21:05:58 +01:00
Github Actions 954540b944 [CI Skip] 1.0.0-beta.10
skip-checks: true
2020-01-19 10:29:05 +00:00
Jaco Greeff 204cf6769d Bump mtadata (latest Substrate) (#1728) 2020-01-19 11:20:33 +01:00
Github Actions f319bc4c50 [CI Skip] 1.0.0-beta.9
skip-checks: true
2020-01-19 09:24:49 +00:00
Jaco Greeff 7b9a11ac25 Don't map empty tuples to Null (#1725)
* Don't map empty tuples to Null

* Remove unused var

* Regen with tuple Result

* Generated types lint fixes
2020-01-19 10:17:20 +01:00
Github Actions 5d2feca2d4 [CI Skip] 1.0.0-beta.8
skip-checks: true
2020-01-16 13:54:01 +00:00
Jaco Greeff dd97e9daee Add registry error lookup (#1723) 2020-01-16 14:46:21 +01:00
Github Actions be258a1f7c [CI Skip] 1.0.0-beta.7
skip-checks: true
2020-01-15 09:05:23 +00:00
Jaco Greeff 72e9474f6f imOnline Heartbeat struct (#1721) 2020-01-15 09:56:58 +01:00
Github Actions d1f63a7864 [CI Skip] 1.0.0-beta.6
skip-checks: true
2020-01-14 18:15:57 +00:00
Jaco Greeff 07ca18502b Society/Recovery types (#1719)
* Society/Recovery types

* camelCase (linting)
2020-01-14 19:08:40 +01:00
Github Actions cddbe411f7 [CI Skip] 1.0.0-beta.5
skip-checks: true
2020-01-14 15:03:44 +00:00
Jaco Greeff ffa60d1cfa Drop V1 support in derive (#1718)
* Drop V1 support in derive

* Re-do staking with multi

* Re-bump deps

* Adjusts tests (no alice_session)

* CC
2020-01-14 15:55:25 +01:00
Github Actions 88193b6a75 [CI Skip] 1.0.0-beta.4
skip-checks: true
2020-01-14 13:15:58 +00:00
Stefanie Doll cc4a4607f1 Updated child storage parameters (#1709)
* Added child_definition and child_type to chicl dtorage RPC methods

* reset comments in test file

* reverse docs re-built

* Fix linting on child storage tests
2020-01-14 14:07:41 +01:00
Github Actions 6c25d0ab0d [CI Skip] 1.0.0-beta.3
skip-checks: true
2020-01-13 21:26:52 +00:00
Amaury Martiny fbbbcd2612 Enum toJSON returns toString for a basic enum (#1697)
* Update kusama static from 1032 to 1033

* Test 1032 and 1033

* Got exact metadata from kusama

* First pass: enum TOJSON and fix some tests

* Build interfaces

* Fix import

* Use camelCase for enum toJSON

* Build interface

* Fix lint

* Fix tests

* Generate static json
2020-01-13 22:18:51 +01:00
Github Actions dd57b1a007 [CI Skip] 1.0.0-beta.2
skip-checks: true
2020-01-13 17:03:58 +00:00
Jaco Greeff 47d0e68f7d Remove old known keys (#1715)
* Remove old known keys

* Don't import removed

* Update storage keys
2020-01-13 17:55:21 +01:00
Github Actions 7b6397215d [CI Skip] 1.0.0-beta.1
skip-checks: true
2020-01-13 16:39:56 +00:00
Jaco Greeff 5739b69757 Bump to 1.0 beta (#1717)
* Bump to 1.0 beta bump

* Bump common to 2.0 beta
2020-01-13 17:31:33 +01:00
Github Actions 2ca79f2f70 [CI Skip] 0.100.1
skip-checks: true
2020-01-13 15:19:07 +00:00
Jaco Greeff 8fb64f77cd 0.100 (#1716) 2020-01-13 16:11:56 +01:00
Github Actions d1f86ce78e [CI Skip] 0.100.0-beta.30
skip-checks: true
2020-01-13 14:24:03 +00:00
Keith IngramandJaco Greeff 64ff226535 Fix api.derive.collective (#1711)
* fix api.derive.collective

* imports

* Update proposals.ts

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2020-01-13 15:17:04 +01:00
Github Actions e762746ff0 [CI Skip] 0.100.0-beta.29
skip-checks: true
2020-01-13 11:03:54 +00:00
Xiliang Chen ce5c8f7443 fix AssetOptions def (#1714) 2020-01-13 11:55:51 +01:00
Github Actions fc4cbb608c [CI Skip] 0.100.0-beta.28
skip-checks: true
2020-01-12 13:50:01 +00:00
Jaco Greeff 7ac3043f83 Extract sub identities (via accounts derive) (#1713)
* Extract sub identities

* Cleanups
2020-01-12 14:42:42 +01:00
Github Actions 44b56fb0cb [CI Skip] 0.100.0-beta.27
skip-checks: true
2020-01-10 15:06:03 +00:00
Jaco Greeff 758ce567e5 Failsafe on proposal decode (fallback ro preimage only) (#1710) 2020-01-10 15:58:56 +01:00
Github Actions cb5308b476 [CI Skip] 0.100.0-beta.26
skip-checks: true
2020-01-10 13:55:10 +00:00
Amaury Martiny a9211690be Remove v9->v10 hack (#1694)
* Remove v9->v10 hack

* Update static

* Update JSON
2020-01-10 14:47:06 +01:00
Github Actions a7db14a261 [CI Skip] 0.100.0-beta.25
skip-checks: true
2020-01-10 13:03:45 +00:00
Jaco Greeff 3a1f284fa8 Treasury OpenTip (#1708) 2020-01-10 13:56:05 +01:00
Github Actions a0b6c42629 [CI Skip] 0.100.0-beta.24
skip-checks: true
2020-01-10 11:10:20 +00:00
Jaco Greeff f77ae4d99f Add percent type (#1707) 2020-01-10 12:02:35 +01:00
Github Actions 5fa9af8fd3 [CI Skip] 0.100.0-beta.23
skip-checks: true
2020-01-10 10:32:55 +00:00
Jaco Greeff 1ff029dc11 Update IdentityInfo with twitter field (#1706)
* Update IdentityInfo with twitter field

* Rebuild

* Update test with twitter
2020-01-10 11:25:10 +01:00
Github Actions 4c8c9fbb07 [CI Skip] 0.100.0-beta.22
skip-checks: true
2020-01-09 13:47:13 +00:00
Jaco Greeff 7057cf365b Add paymentInfo to submittables (#1582)
* Add paymentInfo to submittables

* Cleanup paymentInfo call

* Use 0x42...42 dummy sigs

* Re-add paymentInfo to submittable

* Add correct signFake interfaces

* CHANGELOG
2020-01-09 14:40:25 +01:00
Github Actions d1bc48e936 [CI Skip] 0.100.0-beta.21
skip-checks: true
2020-01-09 11:07:18 +00:00
Jaco Greeff 2dee50f019 Bump deps (#1704) 2020-01-09 11:59:21 +01:00
Github Actions fa76378702 [CI Skip] 0.100.0-beta.20
skip-checks: true
2020-01-08 08:29:06 +00:00
Jaco Greeff e855da1f13 Make a start at the Polkadot launch types (#1700)
* Make a start at the Polkadot launch types

* Add missing old DispatchInfo
2020-01-08 09:21:23 +01:00
Github Actions adffde368c [CI Skip] 0.100.0-beta.19
skip-checks: true
2020-01-07 09:01:45 +00:00
Jaco Greeff 5278138cc3 Make submittable signAsync Observable-aware (#1698)
* Make submittable signAsync Observable-aware

* rxjs test for signAsync

* Cleanup tests, pass signer in .create

* Simplify Observable creation
2020-01-07 09:54:04 +01:00
Github Actions 98249a282e [CI Skip] 0.100.0-beta.18
skip-checks: true
2020-01-06 13:20:39 +00:00
Jaco Greeff b7eeb992cd Bump deps (#1699) 2020-01-06 14:12:49 +01:00
Github Actions 01daf32646 [CI Skip] 0.100.0-beta.17
skip-checks: true
2020-01-03 16:45:58 +00:00
Amaury Martiny 51a866fd35 Update kusama static from 1032 to 1033 (#1696)
* Update kusama static from 1032 to 1033

* Update comment

* Rename variables

* Test 1032 and 1033

* Got exact metadata from kusama
2020-01-03 17:38:32 +01:00
Github Actions 53401e29ea [CI Skip] 0.100.0-beta.16
skip-checks: true
2020-01-03 11:13:30 +00:00
Amaury Martiny 774f41e6db Only apply hack if exactly metadata from kusama 1032 (#1695) 2020-01-03 12:05:27 +01:00
Github Actions 1ca3b295a4 [CI Skip] 0.100.0-beta.15
skip-checks: true
2020-01-02 17:11:51 +00:00
Keith IngramandAmaury Martiny 82828d8e09 Add metadata v10/11, blake2_128concat hasher (#1691)
* v11, blake2_128concat

* MetadataAll

* Add storage hasher v4 and v10

* Make lint pass

* Add correct interfaces

* Fix lint

* Update metadata definitions

* Update v10 metadata

* Update packages/types/src/interfaces/utility/definitions.ts

* Update v11

* Add HACK

* Skip v9 tests (part of HACK)

* Correct function names

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
2020-01-02 18:04:42 +01:00
Github Actions 131055c1d5 [CI Skip] 0.100.0-beta.14
skip-checks: true
2019-12-20 10:04:22 +00:00
Jaco Greeff bd2e690261 Update DispatchError for Kusama (#1686) 2019-12-20 10:57:37 +01:00
Github Actions 1a2ca8ea38 [CI Skip] 0.100.0-beta.13
skip-checks: true
2019-12-19 14:44:19 +00:00
Jaco Greeff 0c98593aee Update DispatchError as enum (#1682)
* Update DispatchError as enum

* Add DispatchResult

* Update tests for DispatchResult

* Rebuild
2019-12-19 15:37:36 +01:00
Github Actions 416e2fbc96 [CI Skip] 0.100.0-beta.12
skip-checks: true
2019-12-19 13:14:08 +00:00
Jaco Greeff c04fb9073e Don't query proposal via multi (#1683) 2019-12-19 14:07:23 +01:00
Github Actions 4f85ceb2c3 [CI Skip] 0.100.0-beta.11
skip-checks: true
2019-12-19 10:09:06 +00:00
Jaco Greeff 9196ce85a0 Expand identity derive fields (incl. all) (#1680) 2019-12-19 11:00:47 +01:00
Github Actions 26734bf8bf [CI Skip] 0.100.0-beta.10
skip-checks: true
2019-12-18 15:30:04 +00:00
satellitex 53959d482d Add BTreeSet<V> Codec (#1639)
* add BTreeSet Codec

* Add following BTreeMap

* fix linting

* fix linting

* add validate Types and encode Types

* type def info is incremented.

* fix compareSet
2019-12-18 16:22:54 +01:00
Github Actions 0a0f110c42 [CI Skip] 0.100.0-beta.9
skip-checks: true
2019-12-17 16:28:01 +00:00
Keith Ingram 47f1350652 Additional rpcContractCall guard (#1677)
* additional rpc guard

* isFunction

* isFunction
2019-12-17 17:21:19 +01:00
Github Actions 3c3b7290c2 [CI Skip] 0.100.0-beta.8
skip-checks: true
2019-12-17 14:40:40 +00:00
Jaco Greeff 006c686c18 Fix linked maps with optional entries (#1676)
* Fix linked maps with optional entries

* Revert entries() change for linked maps
2019-12-17 15:33:45 +01:00
Github Actions 44d4a07005 [CI Skip] 0.100.0-beta.7
skip-checks: true
2019-12-16 11:41:13 +00:00
Github Actions 6e61be960c [CI Skip] 0.100.0-beta.6
skip-checks: true
2019-12-16 11:02:37 +00:00
Jaco Greeff bd57359dc5 Cleanuop preimage check (#1674) 2019-12-16 11:56:42 +01:00
Github Actions 10bc6b4060 [CI Skip] 0.100.0-beta.5
skip-checks: true
2019-12-16 09:49:08 +00:00
Jaco Greeff 9e681c0666 Update .123trigger 2019-12-16 10:42:04 +01:00
Github Actions e969382fd0 [CI Skip] 0.100.0-beta.4
skip-checks: true
2019-12-16 09:36:41 +00:00
Jaco Greeff 1949a13810 Update .123trigger 2019-12-16 10:30:18 +01:00
Github Actions 362262c4e1 [CI Skip] 0.100.0-beta.3
skip-checks: true
2019-12-15 20:44:20 +00:00
Keith Ingram ddd5eab7f5 collective proposals (#1671) 2019-12-15 15:37:27 -05:00
Github Actions 1da6193f34 [CI Skip] 0.100.0-beta.2
skip-checks: true
2019-12-15 11:22:45 +00:00
Jaco Greeff c4e553ad80 Add identity names to derive.accounts.info (#1673) 2019-12-15 12:16:17 +01:00
Github Actions 0b83a61600 [CI Skip] 0.100.0-beta.1
skip-checks: true
2019-12-15 09:04:04 +00:00
Jaco Greeff 382f7d75c8 Data has custom encodedLength 2019-12-15 09:56:30 +01:00
Github Actions 88e4518f64 [CI Skip] 0.100.0-beta.0
skip-checks: true
2019-12-15 07:50:37 +00:00
Jaco Greeff b1a657d68a Custom encoding for identity Data (#1672)
* Custom encoding for identity Data

* Custom encoding for IdentityFields

* Allow empty U8a input to Data

* IdentityField tests
2019-12-15 08:43:22 +01:00
Jaco Greeff 067f17b28b Enum with single-entry encoding (#1670)
* Enum with single-entry encoding

* Expand test with breakdown
2019-12-13 11:19:38 +01:00
Github Actions 99073e2a88 [CI Skip] 0.99.1
skip-checks: true
2019-12-13 09:33:27 +00:00
Jaco Greeff f9a42e47e7 0.99 (#1669)
* 0.99

* Rewrite yarn.lock
2019-12-13 10:26:41 +01:00
Github Actions b80d72edbd [CI Skip] 0.99.0-beta.16
skip-checks: true
2019-12-12 06:51:19 +00:00
Jaco Greeff 1f7b9f7f3a democracy.lowestUnbaked (#1665) 2019-12-12 07:43:56 +01:00
Github Actions 843efb2146 [CI Skip] 0.99.0-beta.15
skip-checks: true
2019-12-11 17:24:47 +00:00
Jaco Greeff 3619fabe5f Update .123trigger 2019-12-11 18:17:29 +01:00
Github Actions bf598e392e [CI Skip] 0.99.0-beta.14
skip-checks: true
2019-12-11 16:43:19 +00:00
Jaco Greeff f026137545 Chace down more phantoms (#1664) 2019-12-11 17:35:57 +01:00
Github Actions 2264f53a43 [CI Skip] 0.99.0-beta.13
skip-checks: true
2019-12-09 22:09:01 +00:00
Jaco Greeff 8ba4029633 Fix elections typo 2019-12-09 23:01:46 +01:00
Github Actions 05cb2cef5a [CI Skip] 0.99.0-beta.12
skip-checks: true
2019-12-09 21:12:47 +00:00
Keith Ingram 3a70594594 Combine elections.info derive (#1659)
* Combine elections.info derive

* remove tests
2019-12-09 22:05:56 +01:00
Github Actions 019cb58dd1 [CI Skip] 0.99.0-beta.11
skip-checks: true
2019-12-09 19:43:53 +00:00
Jaco Greeff d487490ca0 Identity types (#1658)
* Identity types

* Refine findMeta* error outputs

* Cleanups, don't return crappy info, fail

* Revert callIndex with size alloc
2019-12-09 20:36:52 +01:00
Github Actions b9fad61da0 [CI Skip] 0.99.0-beta.10
skip-checks: true
2019-12-09 17:24:49 +00:00
Jaco Greeff 77bf33b4e4 Derive with optional democracy (#1657)
* Derive with optional democracy

* Cleanup optionals

* Multi for preimage retrievals

* Convert indexes to hex before lookup
2019-12-09 18:17:41 +01:00
Github Actions 7ed7c9d3a8 [CI Skip] 0.99.0-beta.9
skip-checks: true
2019-12-09 14:44:41 +00:00
Jaco Greeff 0d2896630d Replace Data/U8a with un-aliassed Raw (#1656)
* Replace Data with un-aliassed U8a

* Export U8a

* Explicitly add U8a to the registry

* U8a -> Raw
2019-12-09 15:38:07 +01:00
Github Actions 74dbff32df [CI Skip] 0.99.0-beta.8
skip-checks: true
2019-12-09 13:24:56 +00:00
Jaco Greeff 4653cc0d84 Add council & treasury derives (#1654) 2019-12-09 14:18:13 +01:00
Github Actions 50e115f6a1 [CI Skip] 0.99.0-beta.7
skip-checks: true
2019-12-09 09:22:19 +00:00
Jaco Greeff 8a5a86e8b3 Better performant per-account staking queries (#1652)
* Better performant per-account staking queries

* Rename retrieval (no confusion)

* staking.info -> staking.account

* Update .info test
2019-12-09 10:14:51 +01:00
Jaco Greeff 48ef5af93f Add missing BTreeMap is metadata checking (#1653) 2019-12-09 10:14:12 +01:00
Github Actions e5c20be666 [CI Skip] 0.99.0-beta.6
skip-checks: true
2019-12-09 07:44:00 +00:00
Jaco Greeff 6bf0d5eea9 DoubleMap hashing over full value (#1650)
* DoubleMap hashing over full value

* Expand Bytes tests

* Expand

* Hashing test with soublemaps

* Small extra test comments
2019-12-09 08:37:47 +01:00
Github Actions 21c57b60a1 [CI Skip] 0.99.0-beta.5
skip-checks: true
2019-12-07 22:07:10 +00:00
Keith Ingram b1dff22954 Fix encodeWithParams for only valid types (#1644)
* fix param display

* space
2019-12-07 23:00:02 +01:00
Github Actions a3d0cb0999 [CI Skip] 0.99.0-beta.4
skip-checks: true
2019-12-07 13:18:44 +00:00
Jaco Greeff bf946c20db Latest metadata (#1647)
* Latest metadata

* Updte static version (v9)

* Update tests for new storage keys

* Bump deps

* Bump extra

* Case, V8 -> v8
2019-12-07 14:13:20 +01:00
Github Actions 664d2c8ab6 [CI Skip] 0.99.0-beta.3
skip-checks: true
2019-12-05 18:56:23 +00:00
Jaco Greeff 01a4d6b4a9 Remove RPC data toU8a (#1643) 2019-12-05 19:49:50 +01:00
Github Actions 18454083db [CI Skip] 0.99.0-beta.2
skip-checks: true
2019-12-05 12:01:09 +00:00
Jaco Greeff 191abe4e08 Cleanup Text from U8a (wrapper class) (#1642)
* Cleanup Text from U8a (wrapper class)

* U8a test
2019-12-05 12:54:52 +01:00
Github Actions 97fbb4732d [CI Skip] 0.99.0-beta.1
skip-checks: true
2019-12-05 10:16:01 +00:00
Jaco Greeff 01f3666cc7 Bump deps (#1641)
* Bump deps

* Linting
2019-12-05 11:09:27 +01:00
Github Actions 468fcdccaa [CI Skip] 0.99.0-beta.0
skip-checks: true
2019-12-04 14:53:39 +00:00
Jaco Greeff c8dd26b0da Remove debug logs (#1637) 2019-12-04 15:46:56 +01:00
Github Actions 61d5dec63a [CI Skip] 0.98.1
skip-checks: true
2019-12-04 11:33:12 +00:00
Jaco Greeff 64a4bb2e17 0.98 (#1635) 2019-12-04 12:27:02 +01:00
Amaury Martiny f78bf9dde1 Remove as unknown (#1636)
* Remove some as unknowns

* Rename sanitize

* Remove file
2019-12-04 12:19:37 +01:00
Github Actions b7ba654e48 [CI Skip] 0.98.0-beta.10
skip-checks: true
2019-12-04 08:12:28 +00:00
Jaco Greeff 532a252fe0 Add missing metadata dep from types (#1634) 2019-12-04 09:06:03 +01:00
Github Actions 614cf4e484 [CI Skip] 0.98.0-beta.9
skip-checks: true
2019-12-03 22:39:25 +00:00
Amaury Martiny c576c689d0 Add correct typings when modifier is optional (#1632) 2019-12-03 23:32:31 +01:00
Github Actions d86cd94fe2 [CI Skip] 0.98.0-beta.8
skip-checks: true
2019-12-03 21:12:43 +00:00
Xiliang Chen 762b16ea13 make ts generate script more reusable (#1610)
* make ts generate script more reusable

* avoid use global definitions

* fix error

* fix formatting

* seems working
2019-12-03 22:04:41 +01:00
Github Actions 09a72c0f31 [CI Skip] 0.98.0-beta.7
skip-checks: true
2019-12-03 19:37:40 +00:00
Jaco Greeff eded5fede2 Add .entries() for map types (#1629) 2019-12-03 20:29:31 +01:00
Github Actions 704df82b1d [CI Skip] 0.98.0-beta.6
skip-checks: true
2019-12-03 14:05:52 +00:00
Caio 46efc10939 Add signAsync to SubmittableExtrinsic (#1626) 2019-12-03 14:58:18 +01:00
Github Actions 74cf8aa30c [CI Skip] 0.98.0-beta.5
skip-checks: true
2019-12-03 13:57:32 +00:00
Jaco Greeff 7a60ab81f8 Drop decorated export (#1628)
* Drop decorated export

* Fixup imports
2019-12-03 14:49:30 +01:00
Github Actions c1d7ca67d5 [CI Skip] 0.98.0-beta.4
skip-checks: true
2019-12-03 13:13:39 +00:00
Jaco Greeff 7e1eb0fab0 Drop circular Linkage deps (#1627)
* Drop circular Linkage deps

* Cleanup more circular deps

* IU8a interface
2019-12-03 14:05:50 +01:00
Github Actions af76d7fb04 [CI Skip] 0.98.0-beta.3
skip-checks: true
2019-12-03 12:10:16 +00:00
Jaco Greeff afbe072ad5 Optional preImage & Proposal for democracy 2019-12-03 13:01:13 +01:00
Github Actions d86c5be413 [CI Skip] 0.98.0-beta.2
skip-checks: true
2019-12-02 14:38:24 +00:00
Jaco Greeff a695d2a5b5 Sort members by backing (#1625) 2019-12-02 15:30:30 +01:00
Github Actions 1c087967d3 [CI Skip] 0.98.0-beta.1
skip-checks: true
2019-12-02 09:39:55 +00:00
Jaco Greeff 906732bcdc Add 6x to conviction (#1623)
* Add 6x to conviction

* Add derive.democracy.proposals

* Proposal decoding

* Don't return empty proposals

* Rework referendumInfo

* Update referendumInfo extraction
2019-12-02 10:32:20 +01:00
Github Actions c9352af81c [CI Skip] 0.98.0-beta.0
skip-checks: true
2019-11-29 15:10:54 +00:00
Jaco Greeff e2e8e3fedd Add received to vested total for available (#1621) 2019-11-29 16:03:17 +01:00
Github Actions 3ca07a5bc8 [CI Skip] 0.97.1
skip-checks: true
2019-11-29 09:03:39 +00:00
Jaco Greeff 89700f98c5 0.97 (#1614)
* 0.97

* Bump version, add Keys & ValidatorPrefs to CHANGELOG

* V9, V10
2019-11-29 09:55:42 +01:00
Github Actions 0cae3cf0fa [CI Skip] 0.97.0-beta.40
skip-checks: true
2019-11-28 16:31:17 +00:00
Jaco Greeff eade586044 ValidatorPrefs with commission: Perbill (#1618)
* ValidatorPrefs with commission: Perbill

* Update naming for old interfaces

* Compact commission
2019-11-28 17:24:00 +01:00
Github Actions c227c6625c [CI Skip] 0.97.0-beta.39
skip-checks: true
2019-11-28 11:50:41 +00:00
Jaco Greeff 4cb8462d50 Cleanup ABI encodeType, fix test compare (#1616) 2019-11-28 12:42:49 +01:00
Satyam Agrawal 1d671d531c update as per the 0.97.0-beta.38 release (#1617) 2019-11-28 12:41:47 +01:00
Github Actions a49cd799dd [CI Skip] 0.97.0-beta.38
skip-checks: true
2019-11-27 21:08:57 +00:00
Jaco Greeff 8ed2bda3a8 Add Polkadot AuthorityDiscovery session keys (#1573)
* Add Polkadot AuthorityDiscovery session keys

* SessionKey5 based on CC3 specVersion
2019-11-27 22:00:52 +01:00
Github Actions 2aabbe3cce [CI Skip] 0.97.0-beta.37
skip-checks: true
2019-11-27 20:38:18 +00:00
Jaco Greeff 7b37cc79a3 Add versioned chain & spec types (#1510)
* Add versioned chain & spec types

* getTypes, getVersionedTypes

* Add min/max range

* Extract specName & specVersion

* Linting

* Comment around helpers

* Split types into seperate file

* MIN, MAX comment

* version -> minmax

* Less code is always good

* Remove unused import

* Comment cleanup

* Record<string, string> -> RegistryTypes

* Cleanup linting, failing tests

* Comments
2019-11-27 21:30:57 +01:00
Github Actions 34a719e443 [CI Skip] 0.97.0-beta.36
skip-checks: true
2019-11-27 19:42:45 +00:00
Jaco Greeff b440c9b0ea Bump common (#1613) 2019-11-27 20:35:26 +01:00
Jaco Greeff 03e9a9676f Allow struct isBare with only some fields (#1611)
* Allow struct isBare with only some fields

* Add payload serialization tests
2019-11-27 20:18:10 +01:00
Github Actions 094d6f7a1c [CI Skip] 0.97.0-beta.35
skip-checks: true
2019-11-27 18:31:37 +00:00
Jaco Greeff 33fd1b1c78 Support Metadata V9 (#1600)
* Metadata v9 definitions

* Update stay V5 in V9

* WIP...

* Small adjustments

* toV9 looks sane ... may work

* v9 tests passes

* v8 tests pass... will get to overall... not checked

* Cleanup type

* Spread storage

* Missing semi

* Cleanup testUtil

* Cater for prefix map key generation

* Remove DoubleMap<T> wrapper

* Remove DoubleMap<T> wrapper

* WIP result types not yet operational

* Output formatting

* Add missing name prop

* Move v9 -> v10, v9 only as storage changes (next up)

* Support v9 & v10

* Fixup linked maps
2019-11-27 19:24:44 +01:00
Github Actions 9968aa4606 [CI Skip] 0.97.0-beta.34
skip-checks: true
2019-11-27 13:54:36 +00:00
Jaco Greeff 9c337422a5 Add derive.staking.electedInfo (#1612) 2019-11-27 14:48:00 +01:00
Github Actions cc432e2291 [CI Skip] 0.97.0-beta.33
skip-checks: true
2019-11-26 11:30:08 +00:00
Jaco Greeff aaff64404a Bump deps (#1609) 2019-11-26 12:23:12 +01:00
Github Actions bfe788cd31 [CI Skip] 0.97.0-beta.32
skip-checks: true
2019-11-26 08:11:11 +00:00
Jaco Greeff 883b191ae7 Try and detect v2 for node-template-like chains (#1607) 2019-11-26 09:04:23 +01:00
Github Actions fa46debb90 [CI Skip] 0.97.0-beta.31
skip-checks: true
2019-11-26 07:06:29 +00:00
Jaco Greeff ed4af1d04b Remove v1 era/session length changes (#1606) 2019-11-26 07:59:17 +01:00
Github Actions 4cea617b13 [CI Skip] 0.97.0-beta.30
skip-checks: true
2019-11-25 11:37:57 +00:00
Github Actions 26b6a59725 [CI Skip] 0.97.0-beta.29
skip-checks: true
2019-11-25 11:00:26 +00:00
Jaco Greeff 35c63a52c8 Add paysFee to DispatchInfo (#1604)
* Add pasyFee to DispatchInfo

* Bool -> bool
2019-11-25 11:53:22 +01:00
Github Actions 61bc20aa7b [CI Skip] 0.97.0-beta.28
skip-checks: true
2019-11-23 21:36:16 +00:00
Jaco Greeff db59fbff25 Acc contracts_getStorage (#1603) 2019-11-23 22:29:33 +01:00
Github Actions 49b3104d04 [CI Skip] 0.97.0-beta.27
skip-checks: true
2019-11-23 11:59:09 +00:00
Jaco Greeff 2338ecc2d7 Update .123trigger 2019-11-23 12:52:22 +01:00
Github Actions bab8c852a4 [CI Skip] 0.97.0-beta.26
skip-checks: true
2019-11-23 11:48:50 +00:00
Jaco Greeff cba17aeb55 Update .123trigger 2019-11-23 12:41:59 +01:00
Github Actions deca8ad216 [CI Skip] 0.97.0-beta.25
skip-checks: true
2019-11-23 11:34:26 +00:00
Jaco Greeff fb4c840549 Trigger 2019-11-23 12:27:43 +01:00
Github Actions 610234c1a1 [CI Skip] 0.97.0-beta.24
skip-checks: true
2019-11-23 11:22:27 +00:00
Jaco Greeff 7f39c573ce Add DispatchInfo (#1601)
* Add DispatchInfo

* Cleanup metadata decoration

* Assert for injection

* Appropriate metadata injection

* Fix tests
2019-11-23 12:15:36 +01:00
Github Actions 114c437671 [CI Skip] 0.97.0-beta.23
skip-checks: true
2019-11-22 20:33:37 +00:00
Jaco Greeff e12f2f67c6 trigger build 2019-11-22 21:27:03 +01:00
Github Actions 0c61850ad6 [CI Skip] 0.97.0-beta.22
skip-checks: true
2019-11-22 12:45:18 +00:00
Jaco Greeff 8b1a7a8584 Move Metadata to interfaces (#1598)
* Move Metadata to interfaces

* Align imports

* Suppress errors

* Remove TS overrides, createTypeUnsafe returns Codec

* Add type unwrap

* Fixup doc generation

* Remove V8 references
2019-11-22 13:38:20 +01:00
Github Actions 4b6b0305e6 [CI Skip] 0.97.0-beta.21
skip-checks: true
2019-11-22 09:54:10 +00:00
Jaco Greeff 3b758a0d64 Remove custom toString() from metadata storage (#1597)
* Convert asType -> asPlain, isPlainType -> isPlain

* Make tests pass

* Move unwrapStorageType to StorageKey
2019-11-22 10:47:21 +01:00
Github Actions ea2c320f33 [CI Skip] 0.97.0-beta.20
skip-checks: true
2019-11-21 20:12:56 +00:00
Jaco Greeff 306857ae07 Remove contracts v1 fees (#1596)
* Remove contracts v1 fees

* Fix linting
2019-11-21 21:06:21 +01:00
Github Actions 448ecd13bb [CI Skip] 0.97.0-beta.19
skip-checks: true
2019-11-21 15:39:22 +00:00
Jaco GreeffandAmaury Martiny 011e24bd49 Pass registry to all codec types (#1592)
* Pass registry to all codec types

* Pass through registry inside API (where the rubber meets the road)

* Small additions

* Derive w/ registry

* Types are more-or-less covered

* Some test adjustments (guided by linting)

* Rid the world of some ../injector

* Additional cleanups, merge injector into registry

* Cleanup extrinsics (always passing registry)

* Remove injector imports (not all replaced)

* Typ spec cleanups

* Phase 1 - types seem lint-free

* rpc-{core,provider} lint free

* Start working through metadata

* Small metadata additions

* Some e2e tests (out-of-order)

* Down to a handful

* Fixup tests for packages/types/src/codec/*.spec.ts

* packages/types/src/codec passes all tests

* packages/types ok (Convert storage with registry fn)

* progress (sort out injection, dreaded find-before msg)

* Down to 1 lint issue...

* Linting done... along with on-demand import

* Exposed ordering

* Remove global injects

* Cleanup comments

* Add CHANGELOG & UPGRADING

* Apply suggestions from code review

Co-Authored-By: Amaury Martiny <amaury.martiny@protonmail.com>

* Update Metadata description
2019-11-21 16:32:39 +01:00
Github Actions 099992627b [CI Skip] 0.97.0-beta.18
skip-checks: true
2019-11-20 13:05:47 +00:00
扩散性百万甜面包 74e20864a6 Typo, deocrateMethod -> decorateMethod (#1594) 2019-11-20 13:59:18 +01:00
Github Actions d006f051a3 [CI Skip] 0.97.0-beta.17
skip-checks: true
2019-11-20 12:20:36 +00:00
Mario Pino f1fe498801 Add PolkaStats to API users (#1593) 2019-11-20 13:14:03 +01:00
Github Actions 1f2cd5a6f7 [CI Skip] 0.97.0-beta.16
skip-checks: true
2019-11-19 20:48:41 +00:00
Jaco Greeff d6239cbe56 Bump metadata (#1590)
* Bump metadata

* Cleanup linting

* Build interfaces

* ... some much for "no mess, no fuss"...
2019-11-19 21:41:53 +01:00
Keith Ingram d82bb63acb Fix vec<u8> issue (#1591)
* fix vec u8 issue

* lint
2019-11-19 21:41:15 +01:00
Github Actions a3ae4cf5d2 [CI Skip] 0.97.0-beta.15
skip-checks: true
2019-11-19 15:42:05 +00:00
Jaco Greeff 6b74ea39c2 Adjust available calc (only vested, when free - reserved > vested) (#1588) 2019-11-19 16:35:28 +01:00
Github Actions 87aab2eca5 [CI Skip] 0.97.0-beta.14
skip-checks: true
2019-11-19 15:08:14 +00:00
Jaco Greeff 1c6a2582f3 Controllers on Alex (#1587) 2019-11-19 16:01:31 +01:00
Github Actions ea49095334 [CI Skip] 0.97.0-beta.13
skip-checks: true
2019-11-19 13:05:56 +00:00
Jaco Greeff b2daf7482f Types for new slashing (#1585)
* Types for new slashing

* Unwrap new nominations structures

* Small cleanups
2019-11-19 13:59:27 +01:00
Github Actions b0165e41e7 [CI Skip] 0.97.0-beta.12
skip-checks: true
2019-11-18 16:28:39 +00:00
Amaury Martiny 0a27f63423 Make api.const.*.* typed (#1584)
* Make api.const.*.* typed

* Fix tsc errors

* Remove ConstantCodec

* as any as

* Remove as any
2019-11-18 17:21:54 +01:00
Github Actions 20d8a31258 [CI Skip] 0.97.0-beta.11
skip-checks: true
2019-11-18 13:05:38 +00:00
Amaury Martiny ca186a4b2c Fix api.query.*.* typings (#1583) 2019-11-18 13:59:02 +01:00
Github Actions 7bd593c8f7 [CI Skip] 0.97.0-beta.10
skip-checks: true
2019-11-18 11:32:13 +00:00
Jaco Greeff 75220eb54f Add payment queryInfo RPC (#1580) 2019-11-18 12:26:09 +01:00
Github Actions dde7d49598 [CI Skip] 0.97.0-beta.9
skip-checks: true
2019-11-15 17:48:24 +00:00
Jaco Greeff a31921b88e Fix era countdown block indicator (#1578) 2019-11-15 18:41:51 +01:00
Github Actions a4c5ca45b2 [CI Skip] 0.97.0-beta.8
skip-checks: true
2019-11-14 17:33:44 +00:00
Jaco Greeff c44cb1858e Fix unlocking/redeemable calc with currentEra (#1572)
* Fix unlocking/redeemable calc with currentEra

* typo

* >= 0 for era check

* Reverse >= 0, it is only 0

* Pass isVesting flag via balances.all
2019-11-14 18:27:25 +01:00
Github Actions f89867a9ae [CI Skip] 0.97.0-beta.7
skip-checks: true
2019-11-14 14:37:49 +00:00
Jaco Greeff be4b9a4133 Update session keys (with AuthorityDiscovery) (#1570)
* Update session keys (with AuthorityDiscovery)

* typo
2019-11-14 15:31:22 +01:00
Github Actions 46b1429da9 [CI Skip] 0.97.0-beta.6
skip-checks: true
2019-11-14 13:58:53 +00:00
Jaco Greeff a70af20eba Derive fallbacks for election w/o electionsPhragmen (#1569) 2019-11-14 14:52:31 +01:00
Github Actions 09dc78d6b1 [CI Skip] 0.97.0-beta.5
skip-checks: true
2019-11-13 21:24:55 +00:00
Jaco Greeff 921e329d18 Cleanup decode errors (#1567)
* Cleanup decode errors

* Expand RPC error message

* Extract RPC createSignature method

* Flatten formatError

* Formatting

* Update test string match
2019-11-13 22:18:07 +01:00
Github Actions f86aebf7e1 [CI Skip] 0.97.0-beta.4
skip-checks: true
2019-11-13 10:35:10 +00:00
Jaco Greeff eef1c5327b Bump deps (#1566)
* Bump deps

* Trigger
2019-11-13 11:28:22 +01:00
Jaco Greeff 2c25936e2c Display elections runnersUp in reverse order (#1565) 2019-11-13 10:52:24 +01:00
Github Actions 734213a2f9 [CI Skip] 0.97.0-beta.3 2019-11-12 11:12:10 +00:00
Amaury Martiny 16e0ea9315 Add a Decorated class, which will be offline decorated Metadata (#1463)
* Move Metadata to api-metadata

* Make tests in api-metadata pass

* Make tests in api-metadata pass

* Refactor fromMetadata into decorated

* Fix some linting

* Replace headers

* Fix all tests

* Small lint

* Fix tests

* Fix metadata docs scripts

* Fix import ordering

* Add line breaks

* Grumbles

* Fix forgotten import

* rpcMetadata everywhere

* Fixlint

* s/api-metadata/metadata

* Fix latest tests

* Fix lint

* Fix tests
2019-11-12 12:06:18 +01:00
Github Actions c87ba33893 [CI Skip] 0.97.0-beta.2 2019-11-11 13:31:37 +00:00
Jaco Greeff 2875fdf2cf Wrap all derives in memo (like rpc-core) (#1564) 2019-11-11 14:25:07 +01:00
Github Actions e73c147275 [CI Skip] 0.97.0-beta.1 2019-11-11 10:40:15 +00:00
Jaco Greeff f080d6ed1c Bump common (#1563) 2019-11-11 11:34:08 +01:00
Github Actions 8ea07727ba [CI Skip] 0.97.0-beta.0 2019-11-10 11:31:39 +00:00
Jaco Greeff 3c47c3fdc3 Detect session.validators for derive extraction (#1562)
* Detect session.validators for derive extraction

* Add comment

* Indexed extraction without session
2019-11-10 12:25:34 +01:00
Github Actions 06418913e5 [CI Skip] 0.96.1 2019-11-09 13:30:30 +00:00
Jaco Greeff 188363d407 0.96 (#1561) 2019-11-09 14:24:27 +01:00
Github Actions ec79087bab [CI Skip] 0.96.0-beta.40 2019-11-09 11:53:53 +00:00
Jaco Greeff 155fd0f8b1 CHANGELOG for 0.96 series (#1560) 2019-11-09 12:47:06 +01:00
Github Actions 05b7def1a0 [CI Skip] 0.96.0-beta.39 2019-11-09 10:52:37 +00:00
Keith Ingram 5671af8db7 Allow most recent Result.findRecord (#1559)
* combine values

* findRecord newest

* constructor

* Add filterRecords

* Update interface
2019-11-09 11:46:09 +01:00
Github Actions 6aebeec028 [CI Skip] 0.96.0-beta.38 2019-11-08 13:53:46 +00:00
Amaury Martiny 5b5d0a3fb8 Add AuthorityList types (#1557) 2019-11-08 14:45:48 +01:00
Github Actions d405ed1005 [CI Skip] 0.96.0-beta.37 2019-11-07 20:58:26 +00:00
Jaco Greeff 2be97310d3 Add runnersup to elections (#1555) 2019-11-07 21:51:54 +01:00
Github Actions 1f44e4473f [CI Skip] 0.96.0-beta.36 2019-11-07 16:41:38 +00:00
Jaco Greeff 022c7ea645 Swap internal derives to use api.derive.* (#1553)
* Swap internal derives to use api.derive.*

* Rx vs normal decorate

* Small cleanups

* Res-use sessions

* Cleanup types

* Fix refCount lost subs

* Small cleanups
2019-11-07 17:34:53 +01:00
Github Actions fe078ca67c [CI Skip] 0.96.0-beta.35 2019-11-07 09:54:24 +00:00
Keith Ingram 479c742471 Error in ABI message assertion (#1552)
* combine values

* undefined name
2019-11-07 10:47:56 +01:00
Github Actions a52c629ecf [CI Skip] 0.96.0-beta.34 2019-11-06 22:03:58 +00:00
Jaco Greeff c077d0f2e7 Bump deps (#1550)
* Bump deps

* Updates
2019-11-06 22:56:52 +01:00
Github Actions 679994a6fb [CI Skip] 0.96.0-beta.33 2019-11-06 16:25:35 +00:00
Jaco Greeff 8cc256fdcf Derive drr doesn't have delay (#1548) 2019-11-06 17:19:12 +01:00
Github Actions b6b2f2beec [CI Skip] 0.96.0-beta.32 2019-11-05 19:04:14 +00:00
Keith Ingram 6075a21efb Handle AccountId contract params (#1547)
* combine values

* handle accountids

* cleanup

* cleanup

* force ci
2019-11-05 19:58:30 +01:00
Github Actions fa98f8f06d [CI Skip] 0.96.0-beta.31 2019-11-05 14:29:22 +00:00
Github Actions ad570cac5a [CI Skip] 0.96.0-beta.30 2019-11-05 14:20:57 +00:00
Jaco Greeff cb32acc409 Update .123trigger 2019-11-05 14:42:35 +01:00
Jaco Greeff 3998b1bcbd Whack derive memo (#1546)
* Whack derive memo

* Bump common
2019-11-05 14:36:53 +01:00
Github Actions 3fd03b2498 [CI Skip] 0.96.0-beta.29 2019-11-05 12:27:24 +00:00
Keith Ingram cba5710fec Return Codec from contracts.call (#1545)
* combine values

* Contracts with Data return

* Data toU8a()

* return data from contracts.call

* create Data

* cleanup
2019-11-05 12:56:49 +01:00
Github Actions 1ffdba03b3 [CI Skip] 0.96.0-beta.28 2019-11-05 09:33:26 +00:00
Xat_MassacrE fcf89d1501 Fix packages/types/src/codec/utils/encodeTypes.ts encodeSubTypes bug (#1544) 2019-11-05 10:27:00 +01:00
Github Actions 56dc116d92 [CI Skip] 0.96.0-beta.27 2019-11-03 22:54:20 +00:00
Jaco Greeff 2371d6a29c Remove double-up-drr (memo vs rpc) (#1541)
* Remove inner memo (no double-up on stringify)

* Validators-specific query
2019-11-03 23:47:55 +01:00
Github Actions d39878c875 [CI Skip] 0.96.0-beta.26 2019-11-03 16:21:18 +00:00
Jaco Greeff 287ceb2ded Contracts with Data return (#1540)
* Contracts with Data return

* Data toU8a()
2019-11-03 17:15:21 +01:00
Github Actions 7c04be6abc [CI Skip] 0.96.0-beta.25 2019-11-03 12:34:59 +00:00
Jaco Greeff e601ae27a1 Re-add derive memo (def. has an impact) (#1539) 2019-11-03 13:28:42 +01:00
Github Actions 487ad475c7 [CI Skip] 0.96.0-beta.24 2019-11-03 10:45:00 +00:00
Jaco Greeff 506b042f8c Remove derive memos (#1538)
* Remove derive memos

* Remove outer memo

* Over-eager replace
2019-11-03 11:38:36 +01:00
Github Actions 0e037de1b1 [CI Skip] 0.96.0-beta.23 2019-11-02 23:18:33 +00:00
Jaco Greeff 8d3cb72189 currentEraPointsEarned not on V1 2019-11-03 00:12:15 +01:00
Github Actions f8b9615e6b [CI Skip] 0.96.0-beta.22 2019-11-02 22:16:32 +00:00
Jaco Greeff 7cc961f789 Staking overview derive (#1537)
* Staking overview derive

* Expand derives

* Extract currentIndex/currentEra

* WIP

* Controllers opt

* Add memo

* Memomize the whole lot

* Doc building fixes

* Doc fixes #2
2019-11-02 23:10:10 +01:00
Github Actions 1d92b7bead [CI Skip] 0.96.0-beta.21 2019-11-01 16:22:40 +00:00
Jaco Greeff 2c44b5ca8a Add isVesting & vestingTotal to balances derive (#1536) 2019-11-01 17:16:26 +01:00
Github Actions 8d9b50a004 [CI Skip] 0.96.0-beta.20 2019-11-01 15:48:36 +00:00
Jaco Greeff d41f6ec3ef Don't re-create locks empty type, return breakdown (#1524)
* Don't re-create locks empty type

* Return the actual inv. lock information
2019-11-01 16:42:19 +01:00
Github Actions 6aff7db89a [CI Skip] 0.96.0-beta.19 2019-11-01 13:24:29 +00:00
Jaco Greeff dc105e6b31 Sub/unsub cleanups (#1535)
* Sub/unsub cleanups

* drr full idAndIndex

* Memo on nick call

* refCountDelay

* Remove scheduler param, always asap

* Flatten

* Test cleanups

* Make tests pass

* Remove logs

* Drop nick memo

* sourceConnection.unsubscribe

* Small cleanups
2019-11-01 14:17:47 +01:00
Github Actions f41ad2eee7 [CI Skip] 0.96.0-beta.18 2019-10-31 18:39:41 +00:00
Jaco Greeff 276da86dbe Expand heartbeats with num blocks (#1534) 2019-10-31 19:32:53 +01:00
Github Actions 5aa64dddf3 [CI Skip] 0.96.0-beta.17 2019-10-31 17:53:26 +00:00
Keith Ingram cf01c41b33 Contract API for Rx/promises (#1520)
* wip with rxjs/promise

* add outcome process

* contract call decoding solved

* restore messages as dict, cleanup

* linting

* linting

* type fixes
2019-10-31 19:47:14 +02:00
Github Actions 64bc3fbffa [CI Skip] 0.96.0-beta.16 2019-10-31 09:54:54 +00:00
Jaco Greeff 453aacb669 derive.accounts.info returns accountId/Index (#1533)
* derive.accounts.info returns accountId/Index

* Swap all idAndIndex to account.info
2019-10-31 10:48:29 +01:00
Github Actions 2f350e3bc2 [CI Skip] 0.96.0-beta.15 2019-10-30 13:23:24 +00:00
Jaco Greeff 8379689eaa Cleanup staking info (#1532)
* Cleanup staking info

* Cache calls

* V1, V2 (Aura & Babe) tested & working

* Hopefully pacify docs build

* Second time lucky?

* Third time lucky?

* Fouth time
2019-10-30 14:15:20 +01:00
Github Actions 2676909cd0 [CI Skip] 0.96.0-beta.14 2019-10-29 23:34:22 +00:00
Jaco Greeff a53c924248 Council -> consts (#1531)
* Council -> consts

* Additional info, expose Balance

* Types
2019-10-30 00:28:40 +01:00
Github Actions a044a959b6 [CI Skip] 0.96.0-beta.13 2019-10-29 22:32:02 +00:00
Jaco Greeff 7555a3a7ce Use currentEraStartSessionIndex for babe (#1530)
* Use currentEraStartSessionIndex for babe

* Update WithdrawReasons
2019-10-29 23:25:45 +01:00
Github Actions 0fac973645 [CI Skip] 0.96.0-beta.12 2019-10-29 21:57:20 +00:00
Jaco Greeff f533f51003 Update for latest 2.x ForceAlways (#1529) 2019-10-29 22:50:46 +01:00
Github Actions b4c0875ebf [CI Skip] 0.96.0-beta.11 2019-10-29 19:10:54 +00:00
Jaco Greeff 8cab499a83 Update .123trigger 2019-10-29 20:04:09 +01:00
Github Actions f2daae3986 [CI Skip] 0.96.0-beta.10 2019-10-29 16:56:41 +00:00
Jaco Greeff 41cf32c808 Flatten more combineLatest into queryMulti (#1528) 2019-10-29 17:49:42 +01:00
Github Actions b0e970a815 [CI Skip] 0.96.0-beta.9 2019-10-29 11:28:14 +00:00
Jaco Greeff fed9e8f7de Retrieve heartbeats for all validators (#1527)
* Retrieve heartbeats for all validators

* Tested, confirmed working
2019-10-29 12:21:49 +01:00
Github Actions d2e2d3be76 [CI Skip] 0.96.0-beta.8 2019-10-28 16:22:49 +00:00
Jaco Greeff 07b9cb1a16 Use GH_PAT is checkout action 2019-10-28 17:15:52 +01:00
Github Actions 4f24af6d8a [CI Skip] 0.96.0-beta.7 2019-10-28 13:32:14 +00:00
Jaco Greeff a30d467618 Split candidates to separate query (#1526)
* Split candidates to seperate query

* Split only candidates
2019-10-28 14:25:34 +01:00
Github Actions 3daf44bac2 [CI Skip] 0.96.0-beta.6 2019-10-28 10:20:45 +00:00
Jaco Greeff b69d8ec789 Account info derive (#1523) 2019-10-28 11:14:21 +01:00
Github Actions d1b2664071 [CI Skip] 0.96.0-beta.5 2019-10-27 12:01:45 +00:00
Jaco Greeff 8d0f20c2a7 Remove Parity Signer signature hack (#1522) 2019-10-27 12:55:01 +01:00
Github Actions f200a348de [CI Skip] 0.96.0-beta.4 2019-10-26 20:36:49 +00:00
Jaco Greeff fae67e72ee Parity Signer v4 work-around (#1521) 2019-10-26 22:30:40 +02:00
Github Actions a23e71bfb0 [CI Skip] 0.96.0-beta.3 2019-10-26 10:23:58 +00:00
Jaco Greeff 6e96fd6a55 ABI selector updates (#1517) 2019-10-26 13:17:36 +03:00
Github Actions 3ba2bbd581 [CI Skip] 0.96.0-beta.2 2019-10-26 08:38:49 +00:00
Jaco Greeff f8084c2d12 Derive for electionsPhragmen (#1519) 2019-10-26 10:32:11 +02:00
Github Actions 1ad552f03d [CI Skip] 0.96.0-beta.1 2019-10-25 15:11:30 +00:00
Jaco Greeff 6b8d0207a6 Swap to normal publish 2019-10-25 17:04:56 +02:00
Github Actions 27871135a0 [CI Skip] 0.95.2 2019-10-25 15:01:08 +00:00
Jaco Greeff 26be5e0cc5 0.95 nextIndex patch 2019-10-25 16:54:54 +02:00
Github Actions 66142c0137 [CI Skip] 0.96.0-beta.0 2019-10-25 14:28:45 +00:00
Jaco Greeff de395c7053 Skip nextIndex (#1513)
* Skip nextIndex

* Remove from derive
2019-10-25 16:22:06 +02:00
Github Actions ab78245576 [CI Skip] 0.95.1 2019-10-25 10:46:56 +00:00
Jaco Greeff 6ff0efca25 0.95 (#1512) 2019-10-25 12:40:21 +02:00
Github Actions fa0fd7140c [CI Skip] 0.95.0-beta.36 2019-10-25 06:57:58 +00:00
Jaco Greeff 0b71291cf1 Update latest extrinsic version (#1511)
* Update latest extrinsic version

* Don't export const with types
2019-10-25 08:51:03 +02:00
Github Actions 44d0ced5af [CI Skip] 0.95.0-beta.35 2019-10-24 14:34:28 +00:00
Jaco Greeff a8bfa90b87 Update signing comment (#1509)
* Update signing comment

* Extrinsic V4 CHANGELOG
2019-10-24 16:20:40 +02:00
Github Actions 835361d3c5 [CI Skip] 0.95.0-beta.34 2019-10-24 13:19:53 +00:00
Jaco Greeff 3bb719fcfc Extrinsic v4 (#1498)
* Extrinsic v4

* Comments

* V4 with MultiSignature

* Bump keyring with signature type indicator

* Return actual Signature type

* Update with MultiSignature enum

* Bump to stable common

* De-dup definitions somewhat
2019-10-24 15:13:03 +02:00
Github Actions 00a3001df9 [CI Skip] 0.95.0-beta.33 2019-10-23 15:49:30 +00:00
Jaco Greeff cac0056fc4 Allow user-define RPC interfaces (#1504)
* Allow user-define RPC interfaces

* Add user-decorated tests

* Pacify CC

* Typos

* Just push.
2019-10-23 17:36:27 +02:00
Github Actions a9e55e66d6 [CI Skip] 0.95.0-beta.32 2019-10-23 11:29:09 +00:00
Jaco Greeff c10f0e47b2 FAQ entry for tuple call (#1505)
* FAQ entry for tuple call

* Add default moral length
2019-10-23 13:22:13 +02:00
Github Actions 0b45bc6ab9 [CI Skip] 0.95.0-beta.31 2019-10-22 13:30:24 +00:00
Jaco Greeff 30f62f4024 Exclude build folders (#1503) 2019-10-22 15:23:47 +02:00
Github Actions 262f01b54e [CI Skip] 0.95.0-beta.30 2019-10-22 09:41:41 +00:00
Jaco Greeff 26c2774992 Bump dev deps (#1502) 2019-10-22 11:35:09 +02:00
Github Actions 58ff26cc78 [CI Skip] 0.95.0-beta.29 2019-10-21 15:36:21 +00:00
Jaco Greeff 62eab2d661 Fix returned accountId for derived staking.info (#1501) 2019-10-21 17:26:34 +02:00
Github Actions d4ab4f8293 [CI Skip] 0.95.0-beta.28 2019-10-21 14:25:19 +00:00
Jaco Greeff aed4b3ee6a Cleanup contracts type registry (#1497)
* Cleanup contracts type registry

* Remove some ! compiler overrides

* More mappy lookups

* Empty check
2019-10-21 16:18:41 +02:00
Github Actions 4c90c6158f [CI Skip] 0.95.0-beta.27 2019-10-20 10:04:04 +00:00
kwingram25 b911bdbd2d Add dynamic Vec ABI support (#1499) 2019-10-20 11:57:19 +02:00
Github Actions b5edcb8529 [CI Skip] 0.95.0-beta.26 2019-10-19 14:46:26 +00:00
Jaco Greeff 9086592252 Flatten encodeTypes, add missing BTreeMap (#1495)
* Flatten encodeTypes, add missing BTreeMap

* Fix param encoding
2019-10-19 16:39:53 +02:00
Github Actions c0b428dfbc [CI Skip] 0.95.0-beta.25 2019-10-18 12:51:38 +00:00
Jaco Greeff e49427ac61 Retrieve account.nextIndex via derive.balances.all (#1487)
* Retrieva account.nextIndex via derive.balances.all

* Remove unneeded cast

* Cast system.accountNonce

* Option -> null

* No undefined nonce
2019-10-18 14:45:25 +02:00
Github Actions 64149de2d4 [CI Skip] 0.95.0-beta.24 2019-10-17 13:29:23 +00:00
Jaco Greeff fe3de4379f Support TransactionPayment.{TransactionBaseFee, TransactionByteFee} (#1493)
* Support TransactionPayment.{TransactionBaseFee, TransactionByteFee}

* Dedup

* Ordering
2019-10-17 15:22:39 +02:00
Github Actions 5532daf640 [CI Skip] 0.95.0-beta.23 2019-10-16 13:11:35 +00:00
Jaco Greeff e197c6f114 Update shared-vec WASM (#1492) 2019-10-16 15:04:53 +02:00
Github Actions f3b71b21b5 [CI Skip] 0.95.0-beta.22 2019-10-16 08:20:10 +00:00
Jaco Greeff db3cb47d05 Firm up on derive typings & results (#1489)
* Firm up on derive typings & results

* Move assertion (eslint vs ts, round 1, fight!)
2019-10-16 10:13:13 +02:00
Github Actions 3f135f2da2 [CI Skip] 0.95.0-beta.21 2019-10-15 10:13:51 +00:00
Jaco Greeff 4ec6a0f9b8 Align doc headers & links (incl. api interface) (#1486) 2019-10-15 12:07:43 +02:00
Github Actions eca0d8d81a [CI Skip] 0.95.0-beta.20 2019-10-15 08:42:24 +00:00
Jaco Greeff e056675b3a Add raw RPC endpoints (#1485) 2019-10-15 10:36:15 +02:00
Github Actions 71a4b39698 [CI Skip] 0.95.0-beta.19 2019-10-14 11:23:40 +00:00
Jaco Greeff d194a6e4c9 Allow BTreeMap.with('u32', 'Text') (not only classes) (#1483) 2019-10-14 13:17:45 +02:00
Github Actions 4a7d8677a3 [CI Skip] 0.95.0-beta.18 2019-10-14 09:48:07 +00:00
Jaco Greeff 21ac0ac2fb Add TypeDefInfo handling for BTreeMap (#1481)
* Add TypeDefInfo handling for BTreeMap

* Update getTypeClass.ts

* Fixup BTreeMap result (will be active once class support is merged)

* Merge master, update with BTreeMap classes
2019-10-14 11:42:31 +02:00
Paul M FoxandJaco Greeff acfd856b25 Basic BTreeMaps codec support (#1474)
* BTreeMap codec type

* used proper, relative path

* Register class types by default

* reduced cognitive complexity

* Update packages/types/src/codec/BTreeMap.ts

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

* Update packages/types/src/codec/BTreeMap.ts

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

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

Co-Authored-By: Jaco Greeff <jacogr@gmail.com>

* added copyright; logic fixes

* added BTreeMap in alphabetical order

* better unit tests

multiple value examples taken from scale codec repo

* lint fix
2019-10-14 11:10:04 +02:00
Github Actions d5d8b59f8b [CI Skip] 0.95.0-beta.17 2019-10-12 14:06:12 +00:00
Jaco Greeff b24fe30a40 Split merge docs gen into sep process (#1482)
* Split merge docs gen into sep process

* Update doc refs
2019-10-12 16:00:22 +02:00
Github Actions 207e2982d7 [CI Skip] 0.95.0-beta.16 2019-10-12 09:34:53 +00:00
Jaco Greeff 6fab577e23 Expose hasSubscriptions on api rx interface (#1479) 2019-10-12 11:16:57 +02:00
扩散性百万甜面包 f7ca638a1a Minor class Events (#1478)
* Fix the return value as boolean on Event

* Minor class Events
2019-10-12 11:16:27 +02:00
Github Actions 0c96ba7a02 [CI Skip] 0.95.0-beta.15 2019-10-11 14:43:06 +00:00
Jaco Greeff 7143f5e643 Add new parathreads types (#1477)
* Add new parathreads types

* Fix dangling comma
2019-10-11 16:25:44 +02:00
Github Actions 910fa20b78 [CI Skip] 0.95.0-beta.14 2019-10-11 11:03:11 +00:00
Jaco Greeff 4855e631b5 Remove secret token from test step (#1475) 2019-10-11 12:44:52 +02:00
Jaco Greeff 698f2725c9 [CI Skip] 0.95.0-beta.13 2019-10-11 08:15:30 +00:00
Jaco Greeff 492fce1af7 Bump deps (#1472) 2019-10-11 09:58:00 +02:00
Jaco Greeff 397e9494eb [CI Skip] 0.95.0-beta.12 2019-10-11 07:50:34 +00:00
Jaco Greeff b8d7f4803b CHANGELOG (#1471) 2019-10-11 09:30:30 +02:00
Jaco Greeff 89f0d452f4 [CI Skip] 0.95.0-beta.11 2019-10-10 18:58:12 +00:00
Jaco Greeff bf8bed36ef Update drr equality (#1469)
* Update drr equality

* null === null

* Array length compare

* isFunction(next.eq)

* Just JSON.stringify on compare

* Add distinctUntilChanged in  rpc-core

* prev/next -> a/b
2019-10-10 20:41:57 +02:00
Jaco Greeff 38529ad13c [CI Skip] 0.95.0-beta.10 2019-10-10 16:49:38 +00:00
Jaco Greeff 8a6d23d461 Allow limited (non-sub operation) with Http provider (#1465)
* Allow limited (non-sub operation) with Http provider

* Throw-away typo
2019-10-10 18:28:15 +02:00
Jaco Greeff d80cc717e2 [CI Skip] 0.95.0-beta.9 2019-10-10 15:57:14 +00:00
Jaco Greeff a207348c13 Remove generated types from docs (#1468) 2019-10-10 17:35:21 +02:00
Jaco Greeff 4a795b4c50 [CI Skip] 0.95.0-beta.8 2019-10-10 15:22:27 +00:00
Jaco Greeff e54cee1fad Cleanup codec .skip tests (#1467) 2019-10-10 17:01:31 +02:00
Jaco Greeff 4e4108abfa [CI Skip] 0.95.0-beta.7 2019-10-10 14:52:30 +00:00
Jaco Greeff 3196e66efb Remove depcrecated addSignature (#1466) 2019-10-10 16:34:20 +02:00
Jaco Greeff 7e0f20908c [CI Skip] 0.95.0-beta.6 2019-10-10 11:18:34 +00:00
Jaco Greeff 985749ade1 Small typos (#1464) 2019-10-10 13:01:05 +02:00
Jaco Greeff ec8deb8be3 [CI Skip] 0.95.0-beta.5 2019-10-10 09:22:18 +00:00
Jaco Greeff b8d4bc5c6a Call.injectMetadata (align with Events) (#1462)
* Call.injectMetadata (align with Events)

* Fix interface builds

* Fix md builds

* Fixup tests with injection
2019-10-10 11:05:01 +02:00
Jaco Greeff 2870513453 [CI Skip] 0.95.0-beta.4 2019-10-09 13:38:10 +00:00
Jaco Greeff e27b35cd9f Merge branch 'master' of github.com:polkadot-js/api 2019-10-09 15:17:09 +02:00
Jaco Greeff bc86dbb31e Bump dev, gh-pages deploy 2019-10-09 15:17:06 +02:00
Jaco Greeff d1b047f675 [CI Skip] 0.95.0-beta.3 2019-10-09 12:49:13 +00:00
Jaco Greeff 8b43ee6ca1 Alias GH_TOKEN 2019-10-09 14:28:21 +02:00
Jaco Greeff f6e5068dae Swap CI to GH actions (#1460) 2019-10-09 14:22:00 +02:00
Jaco Greeff fe40e2378a Skip CI in actions (#1459) 2019-10-09 14:07:27 +02:00
Travis CI 2e9192ca02 [CI Skip] 0.95.0-beta.2 2019-10-08 14:51:58 +00:00
kwingram25 05ec4964fe Generate types from new contract ABI JSON (#1320)
* generate types from registry

* cleanup

* merge, rearrange

* lint

* built out

* abi v2 creation

* throw on unions

* linting

* version handling

* split functions

* cleanup

* drop v1 support

* special types

* changes

* requested changes

* formatTYpe

* rv outdated test

* rv union test

* codeclimate

* codeclimate

* codeclimate

* codeclimate

* codeclimate

* review

* cleanup encodeTypes

* fix option sub

* TypeDefInfo.Result
2019-10-08 16:31:48 +02:00
Travis CI 64f8444d47 [CI Skip] 0.95.0-beta.1 2019-10-08 13:24:45 +00:00
Jaco Greeff c0f9b45dca Bump deps (#1458) 2019-10-08 15:05:25 +02:00
Travis CI ffadc335d5 [CI Skip] 0.95.0-beta.0 2019-10-08 09:51:15 +00:00
Jaco Greeff 9c09386600 Support Metadata V8 (#1441)
* Support Metadata V8

* Update V7 references, introduce *Latest (as applicable)

* Add v8 static metadata

* Bump to latest metadata
2019-10-08 11:30:54 +02:00
Travis CI 7cc541c45f [CI Skip] 0.94.1 2019-10-07 15:09:27 +00:00
Jaco Greeff 2accd13bb6 0.94 (#1456) 2019-10-07 16:52:30 +02:00
Jaco Greeff 647e605c9f Rename push.yml to pr.yml 2019-10-07 16:14:15 +02:00
Travis CI eaa9dd00c7 [CI Skip] 0.94.0-beta.19 2019-10-07 14:02:41 +00:00
Jaco Greeff fb7e067737 Update Enum .eq to be more exhaustive (#1455)
* Update Enum .eq to be more exhaustive

* Add basic compare test
2019-10-07 15:31:05 +02:00
Jaco Greeff eaa71e0097 Action only on PR 2019-10-07 15:26:00 +02:00
Travis CI cd7767d39a [CI Skip] 0.94.0-beta.18 2019-10-07 11:58:10 +00:00
Jaco Greeff cf07d4f743 Add Result type (#1451)
* Add Result class

* Allow createType to operate on Result

* Formatting of Result type in interfaces (incl. use)

* Tests for Result

* Linting & createType seems to work, any final round of gaps?

* Bump metadata containing Result<Null,DispatchError>

* extractTypes handles Result (validation)

* Remove any from creation params

* Ok, give up trying to make `with` sane... it stays enum-like :(

* Move Enum protected decode member to file-level
2019-10-07 13:41:26 +02:00
Travis CI 525b6bf4ad [CI Skip] 0.94.0-beta.17 2019-10-07 11:29:30 +00:00
Jaco Greeff f73c01889f Run action on PR 2019-10-07 13:06:45 +02:00
Travis CI 56d20ceb41 [CI Skip] 0.94.0-beta.16 2019-10-06 12:08:32 +00:00
Jaco Greeff 25d1a1195e Expose api.createType (#1450) 2019-10-06 13:51:19 +02:00
Travis CI db593d2303 [CI Skip] 0.94.0-beta.15 2019-10-05 08:00:48 +00:00
Jaco Greeff e17572d845 Latest metadata (srml/utility) (#1448)
* Latest metadata (srml/utility)

* Move types to utility

* Add sample Kusama test

* Wrap in describeE2E

* Linting

* DispatchResult only in utility srml

* Fixup some tests (types at least)

* api-metadata tests
2019-10-05 09:42:45 +02:00
Travis CI 73704b68ab [CI Skip] 0.94.0-beta.14 2019-10-04 12:30:15 +00:00
Jaco Greeff d594149ed1 Fix derive heartbeats to query via index (#1446) 2019-10-04 14:13:06 +02:00
Travis CI 6b0e2fe919 [CI Skip] 0.94.0-beta.13 2019-10-04 10:04:33 +00:00
Jaco Greeff b36660a0cc Split actions (docs in own job) (#1445)
* Split actions (docs in own job)

* Update job names

* Rename action
2019-10-04 11:40:38 +02:00
Travis CI 29922c2bef [CI Skip] 0.94.0-beta.12 2019-10-04 07:52:35 +00:00
Jaco Greeff 1e67aeed9a Add GH actions (#1444) 2019-10-04 09:21:28 +02:00
Travis CI c28df79c3b [CI Skip] 0.94.0-beta.11 2019-10-03 21:03:46 +00:00
Jaco Greeff f145fe7c8b Fix isGenesisSlot (only on Babe) (#1443) 2019-10-03 22:46:31 +02:00
Travis CI a03a303b8f [CI Skip] 0.94.0-beta.10 2019-10-02 21:19:17 +00:00
Jaco Greeff eda93d25f6 Align CHANGELOG with current (#1438) 2019-10-02 23:00:56 +02:00
Travis CI 44d89ed204 [CI Skip] 0.94.0-beta.9 2019-10-02 19:40:33 +00:00
Jaco Greeff d632f25a9b Cloned API should filter RPCs (#1437) 2019-10-02 21:22:50 +02:00
Travis CI 2f6a397484 [CI Skip] 0.94.0-beta.8 2019-10-02 11:49:28 +00:00
Jaco Greeff a54286c98b Allow string (ss58) address input for approvalsOfAt (#1435)
* Allos string (ss58) address input for approvalsOfAt

* Rework deps
2019-10-02 13:31:04 +02:00
Travis CI ddd21c691f [CI Skip] 0.94.0-beta.7 2019-10-02 10:59:03 +00:00
Jaco Greeff d0f9114fda Don't decode and re-encode storage queries, single pass (#1433)
* Don't decode and re-encode storage queries, single pass

* Remove old SorageData <-> Bytes HACK tests

* Add non-empty check to isPendantic
2019-10-02 12:38:16 +02:00
Travis CI 275593b6fb [CI Skip] 0.94.0-beta.6 2019-10-02 10:32:50 +00:00
Jaco Greeff 17a10fbffe Allow approvalsOf to take string as "who" input (#1434)
* Allow approvalsOf to take string as "who" input

* Re-add <SetIndex> (build fails)
2019-10-02 12:15:50 +02:00
Travis CI afff880c20 [CI Skip] 0.94.0-beta.5 2019-10-01 20:39:36 +00:00
Joshy Orndorff 739625c171 Minor typo and grammar fixes. (#1431) 2019-10-01 22:21:59 +02:00
Travis CI 5fc8e3975b [CI Skip] 0.94.0-beta.4 2019-10-01 12:48:33 +00:00
Amaury Martiny fadb1ffdd8 Make derive types work, and a bit more readable (#1430)
* Fix typings for derive

* Fix typings

* Spacing
2019-10-01 14:30:53 +02:00
Travis CI bddb48f452 [CI Skip] 0.94.0-beta.3 2019-09-30 13:05:11 +00:00
Jaco Greeff af682bc23b Custom extrinsic formats (docs) (#1429)
* Custom extrinsic formats (docs)

* Typos

* Typos (other docs)
2019-09-30 14:42:06 +02:00
Travis CI 7b2cf6dcb0 [CI Skip] 0.94.0-beta.2 2019-09-30 12:41:49 +00:00
Amaury Martiny 9807ff70fa Fix api.derive missing typings (#1428)
* Use @polkadot/types imports everywhere

* use t for all interfaces

* Add comment
2019-09-30 14:24:01 +02:00
Travis CI d30bd0dd86 [CI Skip] 0.94.0-beta.1 2019-09-28 08:00:59 +00:00
Jaco Greeff 25f78a7354 Stringify error data structs (#1426) 2019-09-28 09:44:35 +02:00
Travis CI 0bc0ef6110 [CI Skip] 0.94.0-beta.0 2019-09-27 14:48:55 +00:00
Stefanie Doll b231b7b8cb Rename types in docs to match exports (#1424) 2019-09-27 16:32:11 +02:00
Travis CI 8b0ef159c0 [CI Skip] 0.93.1 2019-09-26 10:13:03 +00:00
Jaco Greeff 96937666d1 0.93 (#1423) 2019-09-26 11:55:41 +02:00
Travis CI da6cd98e6a [CI Skip] 0.93.0-beta.20 2019-09-25 15:37:21 +00:00
Jaco Greeff ad4a6e63ce Use rpc.account.nextIndex in submittables (#1422) 2019-09-25 17:20:46 +02:00
Travis CI c0a804332b [CI Skip] 0.93.0-beta.19 2019-09-25 11:48:04 +00:00
Jaco Greeff 32c4aa3bfe Bump polkadot meta (#1419) 2019-09-25 13:29:47 +02:00
Jaco Greeff 8293f4b585 Bumps & 0.93 CHANGELOG (#1420)
* Bumps & 0.93 CHANGELOG

* Linting
2019-09-25 13:29:07 +02:00
Travis CI 4d2dfb43b8 [CI Skip] 0.93.0-beta.18 2019-09-25 08:42:51 +00:00
Jaco Greeff a0b8619093 Author-only Babe compat over CC1 & latest (#1418) 2019-09-25 10:26:32 +02:00
Travis CI c1396bc23a [CI Skip] 0.93.0-beta.17 2019-09-24 16:06:35 +00:00
Jaco Greeff 692c208b20 Update of Babe Pre Digest from master (#1416) 2019-09-24 17:50:08 +02:00
Travis CI 498e3a1481 [CI Skip] 0.93.0-beta.16 2019-09-24 15:04:07 +00:00
Jaco Greeff 8de45cb09e Update metadata (Babe updates) (#1410)
* Update metadata (Babe updates)

* Bump with latest master

* Use genesisSlot as opposed to epochStartSlot (wrongly)

* Calculate session from genesis start

* Re-create after master merge

* Kusama CC1 chain type overrides
2019-09-24 16:47:04 +02:00
Travis CI 539b26ed87 [CI Skip] 0.93.0-beta.15 2019-09-24 13:11:55 +00:00
Jaco Greeff 68a3b18385 Example for hex & string seeds (#1415) 2019-09-24 14:55:12 +02:00
Travis CI 1573185bf8 [CI Skip] 0.93.0-beta.14 2019-09-23 16:23:10 +00:00
Jaco Greeff fff6f311e0 Typos... 2 in a short sentence, oompf. (#1413) 2019-09-23 17:59:06 +02:00
Travis CI a7b733daa7 [CI Skip] 0.93.0-beta.13 2019-09-23 15:02:16 +00:00
Amaury Martiny 00d86011a7 Correctly type api.query.*.* (#1406)
* v1, very wip

* Refactor file arch

* Clean some code

* Make it work for all methods

* Have correct typings!

* Add similar types

* Fix missing imports

* Move function order

* Put any for now

* Make api.queryMulti work

* Add override check

* Fix typings to make it better

* Uncomment code

* Fix lint

* Fix lint

* Put checkTypes into correct place in file

* Spaces...

* Add multi test

* Use interface instead of type alias

* Add comment

* Fix indentation

* Ignore query.types.ts
2019-09-23 16:46:35 +02:00
Travis CI 84b9b8dc09 [CI Skip] 0.93.0-beta.12 2019-09-20 15:28:39 +00:00
Amaury Martiny 06d0c1fdfb Factorize repeated logEvents function (#1409) 2019-09-20 17:16:12 +02:00
Travis CI bc8782a885 [CI Skip] 0.93.0-beta.11 2019-09-20 08:30:16 +00:00
James Lefrère e7f488ed89 Fixes for examples (#1408)
* Add various fixes for the examples
* Add the workaround for proposals for `impl_version` 94
* TODO: fix `toPromise` issue for queries with RxJS
2019-09-20 10:15:46 +02:00
Travis CI 7b56a52fc3 [CI Skip] 0.93.0-beta.10 2019-09-19 13:01:56 +00:00
Jaco Greeff 67929d34bd Fix FAQ link 2019-09-19 14:49:05 +02:00
Travis CI 5eef25c815 [CI Skip] 0.93.0-beta.9 2019-09-19 10:53:08 +00:00
Jaco Greeff 134c4b611a FAQ entry for root (#1407) 2019-09-19 12:40:52 +02:00
Travis CI 095f63c46e [CI Skip] 0.93.0-beta.8 2019-09-19 09:57:03 +00:00
James Lefrère 73d7a57d38 Add .eq() usage to docs and fix docs typos (#1405)
* Use `eq` for example

* Use the base `eq` function rather than `===`, so that comparisons are made in a consistent manner in docs

* Add `eq` example

* Add an example of using the `eq` method to the base docs

* Adjust docs/examples

* Fix a number of typos in the static docs and examples
* Adjust various comments in docs examples such that they are written in a consistent case

* Fix metadata docs spacing

* Adjust the metadata documentation generation such that unnecessary spaces are trimmed
2019-09-19 11:43:47 +02:00
Travis CI 229fd72526 [CI Skip] 0.93.0-beta.7 2019-09-17 17:32:08 +00:00
Jaco Greeff db9dcbdad5 Fix moved link for rpc methods (#1403) 2019-09-17 19:17:21 +02:00
Travis CI 9f065abb07 [CI Skip] 0.93.0-beta.6 2019-09-17 16:47:18 +00:00
Julien Eluard 564964a482 Fixed typos about module balances (#1402) 2019-09-17 18:33:33 +02:00
Travis CI ceee734ab1 [CI Skip] 0.93.0-beta.5 2019-09-17 14:53:05 +00:00
Julien Eluard 3720cf86cc Fixed typo (#1401) 2019-09-17 16:40:22 +02:00
Travis CI a4f1651f99 [CI Skip] 0.93.0-beta.4 2019-09-17 10:07:55 +00:00
Julien Eluard 5b6762373c Fixed typo (#1400) 2019-09-17 11:55:13 +02:00
Travis CI a72fbece96 [CI Skip] 0.93.0-beta.3 2019-09-16 10:13:28 +00:00
Jaco Greeff 587c9881f8 Typo, caused -> causes (#1399) 2019-09-16 12:01:03 +02:00
Travis CI 36991fb845 [CI Skip] 0.93.0-beta.2 2019-09-16 09:54:08 +00:00
Jaco Greeff bed3f9f4c5 Add rpc_methods (#1397)
* Add rpc_methods

* Adjust interface tests

* Add account_nextIndex & contracts_call, filter

* Rework AbstractArray includes with some

* Adjust tests

* Ordering

* Correct definitions (pull in from methods)

* Be agressive on filtering, regardless of isOptional

* async/await in filterRpcMethods

* map Text[] -> string[]

* Correct naming for account_nextIndex

* Remove/don't remove rpc_methods as applicable

* Cleanup method handling errors
2019-09-16 11:40:54 +02:00
Travis CI 5576dacd9a [CI Skip] 0.93.0-beta.1 2019-09-15 19:01:08 +00:00
Jaco Greeff 5d2caddcaf Support recursive type registration (#1396)
* Testcase for recursive types

* hasClass & hasDef

* Drop .only

* Option<Recursive> (simplified test)

* Expand cross-ref tests, plain getOrThrow
2019-09-15 20:48:45 +02:00
Jaco Greeff ed7bd61230 Sanitize types in createType (#1395) 2019-09-15 20:48:16 +02:00
Travis CI cd272e890f [CI Skip] 0.93.0-beta.0 2019-09-13 10:40:44 +00:00
Jaco Greeff 0f21d522d7 Don't fail session info when babe is not available (#1391) 2019-09-13 12:27:39 +02:00
Travis CI 957f3f404c [CI Skip] 0.92.1 2019-09-12 13:42:03 +00:00
Jaco Greeff d1105c899f 0.92 (#1390)
* Metadata for current Substrate master

* 0.92 doc updates

* @polkadot/util 1.4.1

* Update static polkadot metadata

* Version bump
2019-09-12 15:29:48 +02:00
Travis CI df97bc2bf8 [CI Skip] 0.92.0-beta.9 2019-09-12 10:26:07 +00:00
Jaco Greeff ebe77c25c7 FAQ for offline signing (#1388)
* FAQ for offline signing

* Shorten questions
2019-09-12 12:13:45 +02:00
Travis CI eed83fa5d9 [CI Skip] 0.92.0-beta.8 2019-09-12 09:34:51 +00:00
Jaco Greeff b62b1b248d Add specVersion to mini extraction (#1387) 2019-09-12 11:21:41 +02:00
Jaco Greeff 3b30f1fd43 Start FAQ (#1386)
* Start FAQ

* Update FAQ.md
2019-09-12 11:21:14 +02:00
Travis CI f28fff78b6 [CI Skip] 0.92.0-beta.7 2019-09-12 08:17:23 +00:00
Jaco Greeff 8b80ce7132 Expose keyring via @polkadot/api (#1385)
* Expose keyring via @polkadot/api

* typo, not -> now
2019-09-12 10:03:25 +02:00
Travis CI 8accd2945e [CI Skip] 0.92.0-beta.6 2019-09-11 16:03:32 +00:00
Jaco Greeff f8ec93adea Merge branch 'master' of github.com:polkadot-js/api 2019-09-11 17:51:30 +02:00
Jaco Greeff f4fc3589cc Docs sidebar depth 2019-09-11 17:51:26 +02:00
Travis CI 4e52a2ec02 [CI Skip] 0.92.0-beta.5 2019-09-11 15:44:52 +00:00
Jaco GreeffandThibaut Sardan 55fb391465 Things I wish I knew... (#1374)
* Make a start

* Intro

* Installation

* Flatten

* Move METHODS_*.md to substrate/*.md

* Basics

* Apply suggestions from code review

Co-Authored-By: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com>

* Substrate links

* Create

* api.consts

* Typo

* Typo, ms -> md

* types.basics (SIP)

* Type basics

* api.consts jumps to api.query

* Start to api.query

* Basic queries

* Point starting to actual overview

* api.rpc

* Derive detour

* Query subs & query multi

* Apply suggestions from code review

Co-Authored-By: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com>

* typo

* Query extras

* Basic transactions

* Misplaced ,

* keyring WIP

* Keyring wrap-up

* Subs SIP

* tx subs more WIP

* tx subs

* Small types cleanups

* Apply suggested changes from @JoshOrndorff

* Clarify naked await

* tx wrapping WIP

* Wrap api.wrap

* TS placeholder

* [WIP] markers for not-started

* Clarifying comments

* Additional clarifications

* types.extend... well, extended...

* Remove *nix

* Warp up TypeScript... it is it (for now)

* Some small text clarifications

* Some cleanups

* Cleanups, typos

* keyring cleanups

* Cleanups

* Wrap

* api.wrap wrapped... hopefully

* typos

* Registration typos

* typescript typos, hope I caught most...
2019-09-11 17:32:34 +02:00
Travis CI 3e417f4f94 [CI Skip] 0.92.0-beta.4 2019-09-11 11:02:56 +00:00
Jaco Greeff 158410011e Bump deps (#1384) 2019-09-11 12:51:00 +02:00
Travis CI 7383b1e1d7 [CI Skip] 0.92.0-beta.3 2019-09-10 18:37:45 +00:00
Jaco Greeff ad9d21cae2 Remove outdated blockNumber refs. in API docs (#1382)
* Remove outdated blockNumber refs

* ExtendedHeader

* Update subscribeNewHeads.ts
2019-09-10 20:23:37 +02:00
Travis CI 777007438c [CI Skip] 0.92.0-beta.2 2019-09-10 17:54:33 +00:00
Jaco Greeff a1a52fbdb6 Bump common (#1380) 2019-09-10 19:42:24 +02:00
Travis CI f9f5573abe [CI Skip] 0.92.0-beta.1 2019-09-10 16:07:03 +00:00
Jaco Greeff bdd0cb9d9a Remove ExtError from use (removed from util) 2019-09-10 17:55:02 +02:00
Travis CI 0096d17f2f [CI Skip] 0.92.0-beta.0 2019-09-09 15:43:23 +00:00
Jaco Greeff 3e3d03693a Set the ss58Format based on chain properties (#1378)
* Set the ss58Format based on chain properties

* Mock returns system_properties
2019-09-09 17:31:16 +02:00
Travis CI d06f88d036 [CI Skip] 0.91.1 2019-09-09 13:56:35 +00:00
Jaco Greeff 05d697ce3e 0.91 (#1377)
* Deps & CHANGELOG

* Current master metadata (format only)

* 0.91
2019-09-09 15:43:49 +02:00
Travis CI 0ea4d6934b [CI Skip] 0.91.0-beta.23 2019-09-09 10:08:33 +00:00
Shawn Tabrizi aebe56f471 Update subscribeNewHeads in example (#1376) 2019-09-09 11:56:34 +02:00
Travis CI ee7225ca0e [CI Skip] 0.91.0-beta.22 2019-09-05 10:12:17 +00:00
Jaco Greeff a0c6cd558e Bump deps (#1371) 2019-09-05 12:00:38 +02:00
Travis CI aa4dd63e2c [CI Skip] 0.91.0-beta.21 2019-09-05 09:05:46 +00:00
Jaco Greeff fac0934c46 Alternative lazy Submittable (#1370)
* Aletrnative lazy Submittable

* Extrinsic -> submittable

* .default
2019-09-05 10:52:32 +02:00
Travis CI acf00d3bbe [CI Skip] 0.91.0-beta.20 2019-09-04 15:51:55 +00:00
Jaco Greeff a3b0dde2cd Update metadata, system DispatchError type (#1367) 2019-09-04 17:39:22 +02:00
Travis CI af7a528a11 [CI Skip] 0.91.0-beta.19 2019-09-04 11:19:11 +00:00
Amaury Martiny b889e56b34 Make author_insertKey public arg required (#1366)
* Make author_insertKey public arg required

* Remove blank line

* Build interfaces

* Rename to publicKey
2019-09-04 13:06:11 +02:00
Travis CI fbf1f24f99 [CI Skip] 0.91.0-beta.18 2019-09-04 06:44:14 +00:00
Ian He 630b8318c0 Fix raw payload (#1365)
* fix inconsistent between toPayload() and toRaw()

* add comments
2019-09-04 08:30:41 +02:00
Travis CI 208a2a17cf [CI Skip] 0.91.0-beta.17 2019-09-04 06:11:38 +00:00
Ian He f66b2d00c4 move SignerPayload to @polkadot/types (#1360)
* move SignerPayload to @polkadot/types

* fix errors

* update changelog

* improve naming and code style
2019-09-04 07:58:15 +02:00
Jaco Greeff ffe7201fbc Add explicit payload comment (clarification) (#1363) 2019-09-04 07:57:00 +02:00
Travis CI 00aca88519 [CI Skip] 0.91.0-beta.16 2019-09-03 11:46:52 +00:00
Jaco Greeff 6ec3815669 Bump 1.x check to v5 metadata (#1362) 2019-09-03 13:34:39 +02:00
Travis CI 4b044799f6 [CI Skip] 0.91.0-beta.15 2019-09-03 09:51:41 +00:00
Jaco Greeff 7b844274fd User-provided types for chain & spec (#1361)
* User-provided types for chain & spec

* Remove unused node name

* Remove re-registration warning
2019-09-03 11:39:22 +02:00
Travis CI 7809ea5dad [CI Skip] 0.91.0-beta.14 2019-09-02 16:12:58 +00:00
Thibaut Sardan 8d34d66386 bash (#1359) 2019-09-02 18:00:18 +02:00
Jaco Greeff 9ffeda1749 Fix redeemables (#1358) 2019-09-02 17:58:36 +02:00
Travis CI 1968380f89 [CI Skip] 0.91.0-beta.13 2019-09-02 12:35:55 +00:00
Jaco Greeff bc3d21b66b Add extraction of calls-only metadata (#1356)
* Add extraction of calls-only metadata

* Add --ws option to chain info

* Validate types
2019-09-02 14:22:49 +02:00
Jaco Greeff 20b835778d Add ExtrinsicPayload to registry (as with Extrinsic & Unknown) (#1357) 2019-09-02 14:22:15 +02:00
Travis CI 2f03cdfd4a [CI Skip] 0.91.0-beta.12 2019-09-02 05:52:53 +00:00
Jaco Greeff 096aa83dd7 Bump metadata (#1354)
* Bump metadata

* Update for metadata constants
2019-09-02 07:39:12 +02:00
Travis CI 08f6b14701 [CI Skip] 0.91.0-beta.11 2019-09-02 05:13:40 +00:00
Jaco Greeff 2dd7cc0e69 Typescript-eslint 2 (#1353)
* Make a start

* More minor cleanups

* Some more cleanups

* Last round?

* Exclude build folders
2019-09-02 07:01:32 +02:00
Travis CI bd5c167c14 [CI Skip] 0.91.0-beta.10 2019-08-29 20:45:34 +00:00
Jaco Greeff d905b4fef3 Split Submittable into actual classes (#1350)
* Split Submittable into actual classes

* *sigh* Fix VSCode's "helpful" imports

* Rename option creation functions

* Extrinsic already has version embedded

* V3
2019-08-29 22:33:57 +02:00
Travis CI 3fa8f9f89d [CI Skip] 0.91.0-beta.9 2019-08-29 15:09:22 +00:00
Jaco Greeff 35622a9037 Warning for missing types via console.warn (not console.error) (#1352) 2019-08-29 16:54:35 +02:00
Travis CI eb0327880a [CI Skip] 0.91.0-beta.8 2019-08-29 14:32:46 +00:00
Jaco Greeff 417a9ffceb Bump deps (#1351) 2019-08-29 16:21:26 +02:00
Travis CI 14100d319d [CI Skip] 0.91.0-beta.7 2019-08-29 13:08:59 +00:00
Jaco Greeff a47b2ec1d2 Allow override of Extrinsic V1-V3 (#1349)
* Allow override of Extrinsic V1-V3

* Options only used once, pass in directly

* Linting, unused type
2019-08-29 14:56:56 +02:00
Travis CI 911087f05c [CI Skip] 0.91.0-beta.6 2019-08-29 12:50:48 +00:00
Jaco Greeff 07d23d5675 Cleanup storage create function (#1336)
* Cleanup storage create function

* Cleanup param ordering

* Cleaner expansion

* Small reworks

* Commenting

* String update (tests)
2019-08-29 14:38:40 +02:00
Travis CI b1e2befe74 [CI Skip] 0.91.0-beta.5 2019-08-29 09:55:04 +00:00
Jaco Greeff a0194685b8 Bytes & Extrinsic decoding cleanups (#1337)
* Bytes & Extrinsic decoding cleanups

* Add CHANGELOG entry for Extrinsic changes
2019-08-29 11:43:25 +02:00
Travis CI 470698247d [CI Skip] 0.91.0-beta.4 2019-08-29 08:36:46 +00:00
Jaco Greeff 87f195df2f Pass Extrinsic version, allow ExtrinsicUnknown override (#1348)
* Pass Extrinsic version, allow ExtrinsicUnknown override

* ExtrinsicUnknown should throw
2019-08-29 10:24:39 +02:00
Travis CI c2af5b3da9 [CI Skip] 0.91.0-beta.3 2019-08-28 14:26:08 +00:00
Sergei Pepyakin 098a7a0953 INK! -> ink! (#1347) 2019-08-28 16:13:06 +02:00
Travis CI 451dbf9eb3 [CI Skip] 0.91.0-beta.2 2019-08-27 11:32:36 +00:00
Jaco Greeff 9b1aa6aece Bump dev (#1344) 2019-08-27 13:20:29 +02:00
Travis CI 2801290e92 [CI Skip] 0.91.0-beta.1 2019-08-26 06:04:15 +00:00
Jaco Greeff 9ffb4b8d91 Add SetId from grandpa (#1343)
* Add SetId from grandpa

* Add latest static
2019-08-26 07:52:23 +02:00
Travis CI b59be5a5af [CI Skip] 0.91.0-beta.0 2019-08-25 07:14:48 +00:00
Jaco Greeff 97a5b16320 chain.getRuntimeVersion -> state.getRuntimeVersion (#1341) 2019-08-25 09:02:30 +02:00
889 changed files with 95209 additions and 45269 deletions
+3 -1
View File
@@ -1 +1,3 @@
6
19
1.4.2
1.4.2
-24
View File
@@ -1,24 +0,0 @@
version: 2
jobs:
build:
branches:
ignore:
- gh-pages
working_directory: ~/polkadot-js
docker:
- image: circleci/node:10
steps:
- checkout
- restore_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
- run:
name: install-deps
command: yarn install --frozen-lockfile
- save_cache:
key: dependency-cache-{{ checksum "yarn.lock" }}
paths:
- ./node_modules
- ~/.cache/yarn
- run:
name: build
command: yarn polkadot-dev-circleci-build
+5 -1
View File
@@ -4,5 +4,9 @@ exclude_patterns:
- "**/*.test.js"
- "**/*.test.ts"
- "docs/**/*.js"
- "docs/**/*.ts"
- "packages/api/src/augment/"
- "packages/typegen/scripts"
- "packages/typegen/src"
- "packages/types/src/interfaces/"
- "packages/types/src/scripts/"
- "packages/types/src/augment/"
+1
View File
@@ -1,3 +1,4 @@
**/build/*
**/coverage/*
**/node_modules/*
docs/examples/promise/90_typegen/*
+6
View File
@@ -2,6 +2,12 @@ const base = require('@polkadot/dev/config/eslint');
module.exports = {
...base,
parserOptions: {
...base.parserOptions,
project: [
'./tsconfig.json'
]
},
rules: {
...base.rules,
// add override for any (a metric ton of them, initial conversion)
+111
View File
@@ -0,0 +1,111 @@
name: PR
on: [pull_request]
jobs:
lint:
name: Linting
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Config yarn cache
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: lint
run: |
yarn install --immutable | grep -v 'YN0013'
yarn lint
test:
name: Testing
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Config yarn cache
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: test
run: |
yarn install --immutable | grep -v 'YN0013'
yarn test
build_code:
name: Build Code
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Config yarn cache
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: build
run: |
yarn install --immutable | grep -v 'YN0013'
yarn build
build_docs:
name: Build Docs
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Config yarn cache
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: build
run: |
yarn install --immutable | grep -v 'YN0013'
yarn docs
+87
View File
@@ -0,0 +1,87 @@
name: Master
on:
push:
branches:
- master
jobs:
build_code:
name: Build Code
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
with:
token: ${{ secrets.GH_PAT }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Config yarn cache
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: build
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
GH_PAT: ${{ secrets.GH_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn install --immutable | grep -v 'YN0013'
yarn polkadot-ci-ghact-build
build_docs:
name: Build Docs
if: "! contains(github.event.head_commit.message, '[CI Skip]')"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Config yarn cache
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: build
env:
GH_PAT: ${{ secrets.GH_PAT }}
GH_TOKEN: ${{ secrets.GH_PAT }}
GH_PAGES_SRC: build-docs
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
yarn install --immutable | grep -v 'YN0013'
yarn polkadot-ci-ghact-docs
dummy:
name: Dummy
if: "contains(github.event.head_commit.message, '[CI Skip]')"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- name: dummy
run: |
echo "Dummy skip step"
+6
View File
@@ -3,6 +3,7 @@ build/
build-docs/
coverage/
docs/.vuepress/dist/
docs/substrate/*.md
node_modules/
tmp/
.DS_Store
@@ -12,6 +13,11 @@ tmp/
.env.production.local
.npmrc
.rpt2_cache
.yarn/*
!.yarn/releases
!.yarn/plugins
.pnp.*
.vscode/
cc-test-reporter
lerna-debug.log*
npm-debug.log*
-28
View File
@@ -1,28 +0,0 @@
language: node_js
node_js:
- "10"
env:
global:
- CC_TEST_REPORTER_ID=b8983d04997f43ff9b9df9aa92904967547680e2a229af812b3cf14985713e84
- GH_PAGES_SRC="build-docs"
cache:
yarn: true
directories:
- node_modules
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- export PATH=$HOME/.yarn/bin::$(yarn global bin):$PATH
before_script:
- ./cc-test-reporter before-build
script:
- yarn polkadot-dev-travis-build
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
deploy:
skip_cleanup: true
provider: script
script: yarn polkadot-dev-travis-deploy
on:
branch: master
File diff suppressed because one or more lines are too long
Vendored Executable
+58
View File
File diff suppressed because one or more lines are too long
+10
View File
@@ -0,0 +1,10 @@
enableImmutableInstalls: false
enableProgressBars: false
nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.js
spec: "@yarnpkg/plugin-interactive-tools"
yarnPath: .yarn/releases/yarn-berry.js
+298 -40
View File
@@ -1,4 +1,222 @@
# 0.90.1
# 1.5.1 Mar 06, 2020
- **Important** Substrate master has updated staking, on older chains supply `StakingLedger: 'StakingLedgerTo223'`
- **Important** Substrate master has updated collective, on older chains supply `Votes: 'VotesTo230'`
- Add proper support for type generation with an Enum containing an Tuple (Thanks to https://github.com/monitz87)
- Fix storage parsing not resulting in rejected Promises (Fix from https://github.com/aniiantt applied)
- Remove use of deprecated `Observable.create` (Thanks to https://github.com/Himself65)
- Add types & metadata for the latest Polkadot/Substrate runtime versions (master branches)
- Type extraction will now allow the same sub-module name across packages, i.e. `@polkadot/types/interfaces/runtime` & `@mine/interfaces/runtime` will be valid
- Add `.range([from, to]: [Hash, Hash?], ...args: any[]): [Hash, Codec][]` on all storage entries
- Add `.raw(...args: any[]): Promise<Uint8Array & Codec>` to all RPC calls, returning the un-encoded result
- Allow pre-module type aliasing with `typesAlias: { <moduleName>: { <meta-type>: <alias-type> } }` in API construction options
- Allow `BTreeMap` to be initialized with a `Record<string, any>` object (in addition to `Map`)
- Allow for `HashMap<KeyType, ValueType>` definitions
- `Bool` will now correctly return `isEmpty` on false/default values
- Refresh the `NetworkState` types as returned by the `rpc.system.networkState()` call to current
- Expose `registry.createClass(<typeName>)` to allow for creating type classes. If you are using `createClass` or `ClassOf` in your code, it is recommended to swap to this instance.
- Add additional derives to `api.derive.staking` to handle lazy-payout retrievals
- Update `@polkadot/{util, util-crypto, keyring}` to 1.6.1 & `@polkadot/wasm` to 1.2.1
# 1.4.2 Feb 27, 2020
- Fix `api.tx(<extrinsic>): Submittable` decoration (non-working in 1.4.1, now with proper test)
# 1.4.1 Feb 26, 2020
- **Breaking change** (TypeScript only) The `*.d.ts` files now contain TypeScript 3.8 features (specifically `#private`), which is not usable in TS versions < 3.8
- **Breaking change** - `api.derive.staking.*` has updated result types and detects support for lazy payouts queries
- Rework type generation for `api.{query, tx}` to properly handle complex type inputs (Thanks to https://github.com/monitz87)
- Rework metadata `--strict` mode to effectively decorate chain metadata (Thanks to https://github.com/monitz87)
- Add `api.rpc.chain.subscribeAllHeads` (not just best) (Thanks to https://github.com/jak-pan)
- Add `api.rpc.engine.*` for manual seal support
- Add `api.injectMetadata(metadata)` to initialize API with a specific metadata version
- The api now checks for runtime upgrades, augmenting the interfaces with new metadata when found
- Support types & interfaces required for lazy reaping, lazy payouts & offchain phragmen
- `Option` types now has an `.unwrapOrDefault` as an complement to `.unwrap` & `.unwrapOr`
- Support JS `BigInt` inputs in any derived `UInt` and `Int` object, e.g. `api.tx.balances.transfer(..., 9876543210123456789n)`
- `UInt` & `Int` now does source bitLength checks upon construction
- Registry now exposes `.createType(<type>, ...args)` as an additional helper (like the API)
- Expand `.toHuman` on `ExtrinsicEra`, `SubmittableResult` & `Vote`
- Move `DigestItem`, `Fixed64`, `H160`, `H256` & `H512` to interfaces in `@polkadot/types/interfaces`
- Align construction of unknown types in `registry.get` consistently warn on detection, throw on use
- Support for arbitrary `u*`` types via `UInt<bitLength>` type definitions
- Expose static `.with` on `UInt`, `Int` & `U8aFixed` classes with optional type name override
- Remove [11 Jan 2019](https://github.com/polkadot-js/api/issues/574) extrinsic length hack
- Use ES `#field` on private class fields as applicable
- Move `types/primitive/{extrinsics, generic}` to `types/{extrinsics, generic}`
- Cleanup augmentation and generation scripts for type definitions, aligning with api augmentation
- Bump to `@polkadot/{util, util-crypto, keyring}` 2.5.1
# 1.3.1 Feb 18, 2020
- Add `@types/bn.js` as a normal dependency, exposed in `*.d.ts` (Thanks to https://github.com/monitz87)
- Type generation scripts (including `polkadot-types-from-{chain,defs}`) has been moved to the `@polkadot/typegen` package
- The `@polkadot/types/codec/create` has been moved to `@polkadot/types/create`, imports from `@polkadot/types` are unaffected
- Expose chain properties on registry (and use for API type formatting)
- Add `toHuman(isExtended?: boolean)` to all codec types, formatting into a human-readable structure
# 1.2.1 Feb 16, 2020
- **Important** Update RPC status codes (latest Substrate 2), with the `isInBlock` (`isFinalized` now indicates finality)
- Storage `.entries(arg?: any)` now has the correct argument type for DoubleMap (Thanks to https://github.com/monitz87)
- Swap Kusama and Polkadot aliases for `Address` to `AccountId` (future update)
- Add `LookupSource` and `LookupTarget` types instead of mapping these directly for aliasing
- Add `BitVec` type primitive
- Add support for `system.account` for balance & nonce queries in derives as well as Submittables (Substrate composites)
- Add `rpc.author.hasKey` and `rpc.author.hasSessionKeys` RPCs
- Add derives for the parachains interfaces
- Applied the latest types for Polkadot parachains
- `registry.findMetaError` now can take in a `DispatchErrorModule` object for error lookups (from `asModule` in `DispatchError`)
- Metadata now correctly serializes to the original input data via `toHex()` & `toU8a()`
- Metadata documentation generation rework, including the output of errors from metadata
- Update all examples and comments to use latest `system.account` queries (instead of `system.accountNonce` and `balances.freeBalance`/`balances.reservedBalance`)
- Cleanup `codec/Date` tests to make it run properly on all timezones
- Add explicit dependencies to all packages and move TypeScript `@types/*` to dev deps
# 1.1.1 Feb 06, 2020
- **Important** Chains without `balances.account` or `system.account` should supply `"BalanceLock": "BalanceLockTo212"` to their types to use the previous-generation `BalanceLock` (when querying locks)
- Add support for `balances.account` in all applicable derives (incl. `vesting` module)
- Inject and use SignedExtensions by name from V11 metadata (V4 extrinsics only)
- Add typings for `api.tx.*.*` - the `polkadot-types-from-chain` now also generates these
- Remove additional V1-only derives `(staking.recentlyOffline`, `balances.nominatorsFor`)
- Add `.isMax()` on int values, an opposite of `isZero()` (e.g. `u128`, as well as derived, e.g. `Balances`)
- Add `.keyPrefix()` to all `api.query.*` complementing the `.key()` call, both returning a hex string
- Council derives now takes bootstrapping (member, no elections) into account
- Account derives now allow for an optional indices module (not required)
- Adjust balances fees derivation with optional transfer and creation fees (removed in Substrate)
- Adjust enum `.toJSON()` to return type name as specified
# 1.0.1 Jan 30, 2020
- **Breaking change** Drop support for Substrate v1 chain in all derives
- Return unsub functions from provider .on emitters (Thanks to https://github.com/jak-pan)
- `ApiPromise.isReady` now rejects on unrecoverable errors (Thanks to https://github.com/laec)
- Add `polkadot-types-from-chain` & `polkadot-types-from-defs` TypeScript generators to `@polkadot/types`
- Only decorate derives where relevant parent `api.query.*` is available
- Support `.entries(arg?: any)` lookups on DoubleMaps (in addition to previously supported maps)
- Allow v9 metadata to parse even in cases where it was wrongly deployed pre-v10
- Allow type-aliases on a per-module basis (e.g. `Judgement` in identity as well as society)
- Allow passing `{ signer }` to both `api.tx.*` and `api.sign` (in addition to `api.setSigner`)
- Add derives for the society module
- Don't map empty tuples, e.g. `()` to `Null`, rather keep them empty
- Add lookups to the metadata errors via `findMetaError`
- Update metadata and types for the latest Substrate & Polkadot versions
- Support metadata V11 as per latest Substrate
- Remove support for un-deployed metadata
- Remove old known types for Substrate V1
# 0.100.1 Jan 13, 2020
- **Important** This will the the last API version with Substrate 1.x support. Although you will still be able to use subsequent versions with older chains, dependent libraries such as sr25519 may not be compatible.
- Add support for the Substrate identity module
- Remove the `codec/Data` type, to remove a conflict with Substrate. This type is now named `Raw`
- Fix for linked maps using `Option`
- Add support for `BTreeSet` (Thanks to https://github.com/satellitex)
- Add support for Metadata v10
- Add support for latest Polkadot/Substrate types
- Add `paymentInfo` to submittables to calculate fees
# 0.99.1 Dec 13, 2019
- **Breaking change** The `Data` and `U8a` type has been renamed and just replaced with the `Raw` type
- **Breaking change** The `api.derive.staking.info` has been split into 2 - `staking.query` for non-balance related information (more effective) and `staking.account` that enhances query for all the information previously found `.info`
- Cleanup `DoubleMap` hashing to always hash over the full value (in the case of `Vec<T>`, this includes the length)
- Update democracy derives to take care of nextTally and lowestUnbaked
- Add additional derives for both council & treasury
- Alignment with latest Polkadot/Substrate master branch types
# 0.98.1 Dec 04, 2019
- Make the TypeScript generation script mor re-usable (Thanks to https://github.com/xlc)
- Add `.entries()` for all map-types, returning storage keys and values
- Add `.signAsync` to submittable extrinsics (Thanks to https://github.com/c410-f3r)
- Cleanup circular references between internal dependencies
- Support for new Substrate democracy with preimages in derive
- Alignment of types with Substrate/Polkadot master branches
# 0.97.1 Nov 29, 2019
- **Breaking change** Add the passing on an explicit `Registry` to all calls to `createType` as well as all codec classes. If you are upgrading form an older version, use the [migration guide](UPGRADING.md) to walk through the changes required.
- **Breaking change** The metadata classes have been moved from `@polkadot/types` into `@polkadot/metadata`. If you explicitly create `Metadata` classes, you now would need to do so with the `import Metadata from '@polkadot/metadata';` This is a decorated class, where the previous metadata is now available on `Metadata.metadata`, alongside decorated `consts.*`', `tx.*` and `query.*`.
- **Breaking change** Session `Keys` defaults to 4 keys now (Substrate master), depending on your node config, you would want to override with e.g. `Keys: 'SessionKeys3'` (1, 2, 3, 4, 5 & 6)
- **Breaking change** `ValidatorPrefs` now default to the new percentage commission model, to use the previous `validatorPayment`, you can override with `ValidatorPrefs: 'ValidatorPrefsTo196'`
- `api.derive.*` now has built-in memomization
- Various fixes and cleanups to `api.derive.*` including era length progress and vesting calculations
- Aligned all types with the latest Polkadot & Substrate, including Kusama CC3
- Support for Metadata V9, which adjusts the hashing methods of storage entries
- Support for Metadata V10 (still un-released), which includes prefixed map support
# 0.96.1 Nov 09, 2019
- Updated types for latest Kusama
- Add `filterRecords` (in addition to `findRecord`) on submittable results
- Various ABI v2 contract fixes
- Update derive for elections (incl. RunnersUp) and heartbeat derives (with blocks & messages)
- Add vesting totals & locked breakdowns to derive balances
- Update council derives for the latest Substrate master support (with constants)
- Derive cleanups, including sharing of instances between the API and internal to derives
# 0.95.2 Oct 25, 2019
- Temporary removal of `account_nextIndex` use, will be re-added in a future release
# 0.95.1 Oct 25, 2019
- Support Extrinsic V4 with additional signature indicator (Latest Polkadot/Substrate/Kusama)
- Adjust subscription update checks to avoid duplicated data updates
- Support Metadata V8 (exposes per-module `decl_error` definitions)
- Support next generation contracts ABI (with additional type definitions)
- Support for `BTreeMap<K, V>` types and definitions
- All latest Polkadot & Substrate types (as per master branches)
- **Breaking change** `Call.injectMethods` is moved to `Call.injectMetadata` to align with `Events` (This _should_ not be used externally, however mentioned as breaking here)
# 0.94.1 Oct 07, 2019
- Add handling of `Result<Ok, Error>` definitions
- Adjust API cloning now takes RPC filters from source into account
- Simplification of isPedantic checks and less overhead on StorageData types
- Cleanups and fixes around RPC and derive type definitions
- Fix `derive.imOnline.receivedHeartbeats` to query via indexes
- Adjustment of `api.derive.elections.{approvalsOf|approvalsOfAt}` to allow ss58 address input
- Cleanup `Enum` `.eq` handling to be more exhaustive
- Add documentation for custom extrinsic formats (advanced chains)
- Update to latest substrate master metadata
# 0.93.1 Sep 26, 2019
- Support for Kusama CC2
- In extrinsic submission, use `rpc.account.nextIndex` to retrieve the nonce when available
- For TypeScript users `api.query.*.*` is now properly typed for default Substrate calls, i.e. `api.query.balances.freeBalance(...)` will return a `Balance` type. Additionally the `api.queryMulti` and `.multi` on queries not allow generic type params.
- Add `api.rpc.accounts.nextIndex`, `api.rpc.contracts.call` and `api.rpc.rpc.methods` calls. Optional calls (such as account/contracts) is decorated based on the results from `rpc.methods`, so they don't show up on nodes where they are not active.
- Updated types to support the latest Polkadot/Substrate master changes
- Support recursive type registration (self-referencing via `Box`) in addition to better sanitation of user-defined-types
- Documentation and example updates (thanks mostly to contributions)
# 0.92.1 Sep 12, 2019
- The API now correctly sets the ss58 prefix as retrieved from the chain properties via `ss58Format`
- Bump to `@polkadot/util` 1.4.1, removing use of `ExtError`
- The `Keyring` from `@polkadot/keyring` is now exposed on the API as well. You can do `import { Keyring } from '@polkadot/api'` - this alleviates the need for extra dependencies (apart from `@polkadot/api`), and since the keyring is critical for signing operations, aligns everything in one bundle
- Support the latest Polkadot & Substrate master branches (incl. metadata updates)
- Getting started documentation has been made available
# 0.91.1 Sep 09, 2019
- This release was focussed on stability, with a number of cleanups and bug-fixes
- Adjustments for Substrate 1.x chain detection (with auto-types) and Substrate 2.x support has been extended with all latest types
- The `getRuntimeVersion` and `subscribeRuntimeVersion` RPCs are now only available on the `rpc.state.*` endpoints. This aligns with the Substrate implementation.
- The `author_insertKey` RPC's last argument `publicKey` is now required, as to reflect Substrate implementation.
- Support for extrinsics with versions that is not in the base Substrate implementation (V1-V3) can now be done by providing an implementation for `ExtrinsicUnknown`
- Redeemed balance calculation if `api.derive` now returns the correct values again (bug fix)
- added the `yarn chain:info [--ws URL]` utility to extract a calls-only metadata version
- Missing types are now logged via a `console.warn`, not via `.error`
- `Extrinsic`, `ExtrinsicPayload` & `SignerPayload` is registered in the type registry and can be overridden now
- **Breaking change** `SignerPayload` is renamed to `SignerPayloadJSON`
- **Breaking change** `SignerPayloadJSON`, `SignerPayloadRawBase` and `SignerPayloadRaw` are all moved to `@polkadot/types`
# 0.90.1 Aug 24, 2019
If you are upgrading form an older version, use the CHANGELOG hand-in-hand with the [migration guide](UPGRADING.md).
@@ -7,7 +225,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- **Breaking change** `Api.create(...)` and `new Api(...)` now only takes an options Object, so if you passed the provider directly previously, you need to swap the use to `Api.create({ provider: ... })`
- **Breaking change** Runtime types have been extended and moved to definitions instead of classes
- Primitive types for `i*` and `u*` (e.g. `u32`) are now only available in their lowercase versions. Additionally `Vector` is now only available as `Vec`, and `Method` has been renamed to `Call`, in both cases aligning with Rust.
- `Moment` now implements as `u64` as per the Substrate codebase. (It it up to the user to interpret, for substrate 2.x it is not mili-second resolution)
- `Moment` now implements as `u64` as per the Substrate codebase. (It it up to the user to interpret, for substrate 2.x it is not ms resolution)
- For creation of types, it is recommended to use `createType(<TypeName>, <value>)` instead of e.g. `new Proposal(...)`. When passing these to methods/queries, construction should not be needed, the raw value can be passed.
- For moved types, a previous import would have been from `@polkadot/types`, i.e. `import { SetIndex } from '@polkadot/types`, now just the interfaces (TypeScript) are available via `import { SetIndex } from '@polkadot/types/interfaces`
- `usize` is now a blacklisted type that will throw on construction. Since it is platform-specific, it creates incompatibilities between native (generally `u64`) and WASM (always `u32`) code. Use one of the `u32` or `u64` types explicitly.
@@ -16,11 +234,11 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- The `types/codec/createType` has been moved to `types/codec/create` with the same exports. If you explicitly imported from here (and not doing the suggested `import { createType } from '@polkadot/types`), the reference needs to be updated
# 0.82.0-beta.x
# 0.82.0-beta.x Jul 28, 2019
- Support for substrate 2.x (master) has been extended,
- Additional types have been addedd for the modules
- `api.derive.contract` is now `api.derive.contracts` to align with the substrate 2.x rename. (Feture detection is used so it supports both 1.x and 2.x chains)
- `api.derive.contract` is now `api.derive.contracts` to align with the substrate 2.x rename. (Feature detection is used so it supports both 1.x and 2.x chains)
- Addition of `api.derive.elections`
- Support latest substrate 2 v6 metadata with module constants using `api.consts`.
@@ -35,7 +253,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- The `ContractsAbi` type has been moved from `@polkadot/types` to `import { Abi } from '@polkadot/api-contract`. This paves the way for an enhanced contracts interface, instead of dealing with low-level API calls.
# 0.81.1
# 0.81.1 Jun 14, 2019
- The dependency on `@polkadot/keyring` has been removed - if you relied on the API to provide this, you would now need to manually add it
- `createType` allows for the creation of `[u8; <length>]` types (opening the door for contract support)
@@ -55,7 +273,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Add `off` method to `Api` (Base, for both `ApiPromise` & `ApiRx`) to remove an event listener
# 0.80.1
# 0.80.1 Jun 04, 2019
- Support for mortal transactions
- Better DoubleMap storage support
@@ -65,7 +283,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Misc. cleanups and fixes
# 0.79.1
# 0.79.1 May 22, 2019
- DoubleMap query support
- Support latest EventRecord metadata (substrate master)
@@ -77,7 +295,7 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Add `toRawType` on all type classes (breakdown into primitive types)
# 0.78.1
# 0.78.1 May 08, 2019
- Fix linked-maps (not working since 0.77.1)
- Convert Usize to U32 (as found in WASM environments)
@@ -88,13 +306,13 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Metadata updates for substrate (WithdrawReasons, ContractInfo)
# 0.77.1
# 0.77.1 Apr 25, 2019
- Support Metadata v4, which introduces the use of a custom hasher to hash storage map keys.
- Add TresuryProposal (not the same as democracy, type aliassed)
- Add TreasuryProposal (not the same as democracy, type aliased)
# 0.76.1
# 0.76.1 Apr 03, 2019
- Caching improvements (duplicate queries, no duplicate subscriptions)
- Experimental contract API
@@ -102,23 +320,23 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Update @polkadot/util-crypto with smaller footprint
# 0.75.1
# 0.75.1 Mar 29, 2019
- Start journey to 1.0
# 0.53.1
# 0.53.1 Mar 29, 2019
- Change spelling to US English as per substrate master (1.0-rc1). Breaking changes as a result:
- For extrinsic status results, if you have checked the type returns, i.e. `result.type === 'Finalised'` now check on the status for `result.status.isFinalized` or `result.status.isBroadcast`, ... (the `type` property is now accessible only on `result.status.type`)
- If using `subscribeFinalisedHeads` update this to `subscribeFinalizedHeads` (likewise `getFinalisedHead` should be updated to `getFinalizedHead` and `derive.bestNumberFinalized`)
- The underlying ss58 addess checksums have changed
- The underlying ss58 address checksums have changed
- The updated keyring with support for this has been made available
- All examples have been updated with sr25519 addresses (with the new checksums)
# 0.52.1
# 0.52.1 Mar 28, 2019
- Support queries to linked mapped storage (found in new staking interfaces)
- Add `derive.staking.controllers` to retrieve all active staking controllers
@@ -128,42 +346,42 @@ If you are upgrading form an older version, use the CHANGELOG hand-in-hand with
- Check for single instances for api and types as they are loaded (assertSingletonPackage)
# 0.51.1
# 0.51.1 Mar 25, 2019
- Support metadata V2 as per latest substrate master
- Update metadata with new types as per lastest substrate master
- Update metadata with new types as per latest substrate master
# 0.50.1
# 0.50.1 Mar 23, 2019
- Lastest util-crypto (usage of WASM with JS fallbacks if not available)
- Latest util-crypto (usage of WASM with JS fallbacks if not available)
- Update upstream @polkadot dependencies (for new crypto)
# 0.49.1
# 0.49.1 Mar 20, 2019
- Fix large message signing on non-known nodes (default is now hashing, there has been enough time between upgrades)
# 0.48.1
# 0.48.1 Mar 18, 2019
- Pull in new sr25519 capable keyring for dev nodes
- When using dev mode, it assumes that the node is the latest with derived sr25519 keys
# 0.47.1
# 0.47.1 Mar 14, 2019
- Swap to publishing -beta.x on merge (non-breaking testing)
# 0.46.1
# 0.46.1 Mar 01, 2019
- Extended type registration to now handle internal types as well. Additionally the built-in Extrinsic type can now we overridden with a custom version.
- Where `Extrinsic` and `Method` is used as types, considder importing `{ IMethod, IExtrinsic }` from `@polkadot/types/types`, especially in the cases where this is uased from a `SubmittableExtrinsic`
- Where `Extrinsic` and `Method` is used as types, consider importing `{ IMethod, IExtrinsic }` from `@polkadot/types/types`, especially in the cases where this is used from a `SubmittableExtrinsic`
- The `typeRegistry` constant is now `getTypeRegistry()` as a function
# 0.45.1
# 0.45.1 Feb 19, 2019
- Storage with option values now correctly return `Option<Type>` and is indicated as such in the documentation
@@ -180,9 +398,9 @@ console.log('llo', llo.unwrapOr('not set') /* Option<BlockNumber> */)
```
# 0.44.1
# 0.44.1 Feb 19, 2019
- Split primitives and types into seperate folders. This should not affect external use since the exports remain the same, however does have an impact where classes are referenced directly. e.g.
- Split primitives and types into separate folders. This should not affect external use since the exports remain the same, however does have an impact where classes are referenced directly. e.g.
```js
// old (affected)
@@ -198,45 +416,45 @@ import { Method, Signature } from '@polkadot/types';
```
# 0.43.1
# 0.43.1 Feb 14, 2019
- Intrduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considerred breaking since @polkadot/keyring has interface changes. (Unless needed, don't rush the upgrade)
- Introduces support for the new keyring with sr25519 support in addition to ed25519. While this does not change the exposed API, it is considered breaking since @polkadot/keyring has interface changes. (Unless needed, don't rush the upgrade)
# 0.42.1
# 0.42.1 Jan 31, 2019
- Support for substrate hash signing with implVersion >= 18
- Changed signatures for Extrinsic signing, this should not have (much) of an impact since it is generally not used directly. SubmittableExtrinsic (as exposed by the API), supports the old-style use.
# 0.41.1
# 0.41.1 Jan 26, 2019
- Support the V1 metadata specification from Substrate in addition to the currently testnet-active V0 version
- Support the V1 metadata specification from Substrate in addition to the currently testnet active V0 version
# 0.40.1
# 0.40.1 Jan 16, 2019
- The API interfaces now require a WS-compatible provider, e.g. subscription support is a must. Previously the HTTPProvider could be use (although it was very limited in the interactions).
# 0.39.1
# 0.39.1 Jan 11, 2019
- The Promise API now returns a `Promise<UnsubFunction>` instead of `UnsubFunction` when making subscriptions.
# 0.38.1
# 0.38.1 Jan 08, 2019
Substrate has been updated with a breaking new transaction format where the Index/Nonce is now encoded as a Compact. This change is being rolled out to both Alexander (Polkadot testnet) as well as Charred Cherry (Substrate testnet) - transactions between old and new are not compatible.
# 0.37.1
# 0.37.1 Jan 04, 2019
api-observable has been removed. This was only used in /apps and inconsistent with the api/rx and api/promise APIs. Future work will include derivates like was included in api-observable into the base.
api-observable has been removed. This was only used in /apps and inconsistent with the api/rx and api/promise APIs. Future work will include derives like was included in api-observable into the base.
Tuples now return single types when only one type is available, i.e. `(AccountId)` would now resolve as `AccountId`. The extra type wrapper adds no benefit to users here.
# 0.36.1
# 0.36.1 Jan 03, 2019
Api Promise has been updated in the way we deal with subscriptions. Previously a subscription returned `Promise<number>` where the caller was to keep track of the id and use it in subsequent unsubscribes. Now any subscriptions return an unsubscribe/destroy function `(): void`, that is use for removing the subscriptions, e.g.
@@ -247,11 +465,51 @@ unsubscribe(); // here we destroy the subscription
```
# 0.35.1
# 0.35.1 Dec 20, 2018
Swapped to new metadata structures from Substrate. If the API is not working with your node, update Substrate to latest master branch. (Or 0.9.1 for Charred Cherry). Dropped support for old metadata as found as far back as BBQ Birch.
# 0.34.1
# 0.34.1 Dec 18, 2018
Changed the send signature (for future expansion of eg. events) to return `result: { status: ExtrinsicStatus }` instead of `status: ExtrinsicStatus`. For most cases where only status `type` checks are used, i.e. `status.type === 'Finalised'` this should not be a breaking change. Deep inspection of the status object however will need to adapt.
# 0.33.1 Dec 06, 2018
# 0.32.1 Nov 21, 2018
# 0.31.1 Oct 10, 2018
# 0.30.1 Sep 27, 2018
# 0.29.1 Sep 14, 2018
# 0.28.1 Aug 11, 2018
# 0.15.1 Aug 07, 2018
# 0.14.1 Jun 23, 2018
# 0.13.1 May 29, 2018
# 0.12.1 May 18, 2018
# 0.11.1 May 16, 2018
# 0.10.1 May 07, 2018
# 0.9.1 Apr 24, 2018
# 0.8.1 Mar 15, 2018
# 0.7.1 Jan 25, 2018
# 0.6.1 Dec 03, 2017
# 0.5.1 Nov 28, 2017
# 0.4.1 Nov 19, 2017
# 0.3.1 Nov 19, 2017
# 0.2.1 Nov 18, 2017
+2 -2
View File
@@ -22,12 +22,12 @@ The API is split up into a number of internal packages -
- [@polkadot/api](packages/api/) The API library, providing both Promise and RxJS Observable-based interfaces. This is the main user-facing entry point.
- [@polkadot/api-derive](packages/api-derive/) Derived results that are injected into the API, allowing for combinations of various query results (only used internally and exposed on the Api instances via `api.derive.*`)
- [@polkadot/api-metadata](packages/api-metadata/) Base extrinsic, storage and constant injectors for injection
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/api/METHODS_RPC.html) exposed by a Polkadot network client
- [@polkadot/rpc-core](packages/rpc-core/) Wrapper around all [JSON-RPC methods](https://polkadot.js.org/api/substrate/rpc.html) exposed by a Polkadot network client
- [@polkadot/rpc-provider](packages/rpc-provider/) Providers for connecting to nodes, including WebSockets and Http
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
- [@polkadot/jsonrpc](packages/type-jsonrpc/) Definitions for JSONRPC endpoints
- [@polkadot/jsonrpc](packages/jsonrpc/) Definitions for JSONRPC endpoints
- [@polkadot/types](packages/types/) Codecs for all Polkadot and Substrate primitives
## development
+90 -6
View File
@@ -2,7 +2,91 @@
This is an upgrade guide for users of the API. It does not attempt to detail each version (the [CHANGELOG](CHANGELOG.md) has all the changes between versions), but rather tries to explain the rationale behind major breaking changes and how users of the API should handle this.
While we try to keep the user-facing interfaces as stable as possible, sometimes you just need to make additions to move forward and improve things down the road, as painful as they may be. Like you, we are also users of the API, and eat our own dogfood - and as such, feel any pains introduced first.
While we try to keep the user-facing interfaces as stable as possible, sometimes you just need to make additions to move forward and improve things down the road, as painful as they may be. Like you, we are also users of the API, and eat our own dog food - and as such, feel any pains introduced first.
## 0.97.1 (and newer)
The 0.97 series lays the groundwork to allow type registration to be ties to a specific chain and a specific Api instance. In the past, 2 Api instances in the same process would share types, which mean that you could not connect to 2 independent chains with different types. This is very problematic for Polkadot chains, where the idea is to connect to multiple chains.
When using the Api, a new `Registry` will be created on using `new Api(...)` or `Api.create(...)` and this will be transparently passed when creating types. In the cases where you create type instances explicitly or create type classes for injection, you would need to make adjustments.
### Type classes
In a number of instances, developers are creating classes and making these available for interacting with their chains. For instance, an example of a custom type could be -
```js
import { Struct, Text, u32 } from '@polkadot/types';
export class Preferences extends Struct {
constructor (value?: ahy) {
super({
name: Text,
id: u32
}, value);
}
...
}
```
In the current iteration, the underlying `@polkadot/types` bases structures now require a `Registry` to be passed as the first parameter. This means that the above signature would be adjusted to -
```js
// the next import is only required for TypeScript
import { Registry } from '@polkadot/types/types';
import { Struct, Text, u32 } from '@polkadot/types';
export class Preferences extends Struct {
constructor (registry: Registry, value?: ahy) {
super(registry, {
name: Text,
id: u32
}, value);
}
...
}
```
Where the type is used or returned from the API, the `Registry` will be automatically passed to class creation.
### createType
Previously, when creating a type instance such as `BlockNumber`, you would do `api.createType('BlockNumber', <initValue>)`, this is unchanged. In the cases where you directly import from `@polkadot/types`, the following pattern is required -
```js
import { createType } from '@polkadot/types';
...
const blockNumber = createType(api.registry, 'BlockNumber', 12345);
```
In some cases, you would want to explicitly pass a `Registry` interface to the API, instead of relying on it explicitly. This is generally applicable in the cases where you want to use the `createType` independently from the API -
```js
import { ApiPromise } from '@polkadot/api';
import { TypeRegistry, createType } from '@polkadot/types';
...
const registry = new TypeRegistry();
const blockNumber = createType(registry, 'BlockNumber', 12345);
const api = await ApiPromise.create({ registry });
```
### Extrinsic metadata
In some applications, the undocumented `findFunction` has been used to determine the Api has the metadata for a specific extrinsic. The has been exposed on top of `GenericCall`, and it typically used in applications such as signers. Along with the compulsory registry, the above functions have been moved to the `Registry` itself, so if you previously had -
```js
const { meta, method, section } = GenericCall.findFunction(extrinsic.callIndex);
```
You need to change it to -
```js
const { meta, method, section } = registry.findMetaCall(extrinsic.callIndex);
```
## 0.90.1 (and newer), from 0.81.1 (and older)
@@ -29,10 +113,10 @@ To better align with the actual types from the metadata, and avoid (too much) co
The [@polkadot/api](packages/api) has always handled the conversion of types for parameters when making calls or queries. For example, when making a transfer to `BOB` (address), any of the following is valid -
- `api.tx.balances.transfer(BOB, 12345)` - value specied as a number
- `api.tx.balances.transfer(BOB, '12345')` - value specied as a string
- `api.tx.balances.transfer(BOB, '0x3039')` - value specied as a hex
- `api.tx.balances.transfer(BOB, new BN(12345))` - value specied as a [BN](https://github.com/indutny/bn.js/)
- `api.tx.balances.transfer(BOB, 12345)` - value specified as a number
- `api.tx.balances.transfer(BOB, '12345')` - value specified as a string
- `api.tx.balances.transfer(BOB, '0x3039')` - value specified as a hex
- `api.tx.balances.transfer(BOB, new BN(12345))` - value specified as a [BN](https://github.com/indutny/bn.js/)
Internally the API will take the input and convert the value into a `Balance`, serialize it using the SCALE codec and transfer it to the node. In some cases users would construct the `Balance` type manually, by importing the class and calling `new` on it. This last approach has now been removed, and where classes are still available (limited reach), discouraged.
@@ -108,7 +192,7 @@ export class MyStruct extends Struct {
}
```
Internally the [@polkadot/types](packages/types) package now only defines classes where there are specific encoding logic applied. For all other types, the definitions are done via a JSON-like format and then the TypeScript definitions are generated from these. (In a world where nodes inject types and the type definitions are not needed, this functionality will be useful to allow TS devs to auto-generate type definitions based on what the node defines.)
Internally the [@polkadot/types](packages/types) package now only defines classes where there are specific encoding logic applied. For all other types, the definitions are done via a JSON-like format and then the TypeScript definitions are generated from these. (In a world where nodes inject types and the type definitions are not needed, this functionality will be useful to allow TS developers to auto-generate type definitions based on what the node defines.)
### Signing transactions (Signer interface)
+1 -3
View File
@@ -1,3 +1 @@
module.exports = {
extends: '@polkadot/dev/config/babel'
};
module.exports = require('@polkadot/dev/config/babel');
+14 -13
View File
@@ -1,22 +1,23 @@
#!/bin/sh
#!/bin/bash
function copy_folder () {
SRC="packages/$1/build"
DST="apps/node_modules/@polkadot/$2"
DST="../apps/node_modules/@polkadot/$1"
echo "** Copying $SRC to apps/$DST"
echo "** Copying $SRC to $DST"
rm -rf ../$DST
cp -r $SRC ../$DST
rm -rf $DST
cp -r $SRC $DST
}
yarn polkadot-dev-build-ts
copy_folder "api" "api"
copy_folder "api-contract" "api-contract"
copy_folder "api-derive" "api-derive"
copy_folder "api-metadata" "api-metadata"
copy_folder "rpc-core" "rpc-core"
copy_folder "rpc-provider" "rpc-provider"
copy_folder "type-jsonrpc" "jsonrpc"
copy_folder "types" "types"
copy_folder "api"
copy_folder "api-contract"
copy_folder "api-derive"
copy_folder "metadata"
copy_folder "rpc-core"
copy_folder "rpc-provider"
copy_folder "jsonrpc"
copy_folder "types"
copy_folder "typegen"
+38 -8
View File
@@ -22,11 +22,38 @@ module.exports = {
],
search: false,
sidebar: [
{
title: 'Getting started',
path: '/start/',
collapsable: false,
sidebarDepth: 0,
children: [
['start/install.md', 'Installation'],
['start/basics.md', 'Basics & Metadata'],
['start/create.md', 'Creating an instance'],
['start/api.consts.md', 'Runtime Constants'],
['start/api.query.md', 'State queries'],
['start/api.rpc.md', 'RPC calls'],
['start/api.query.subs.md', 'Query subscriptions'],
['start/api.query.multi.md', 'Multi queries'],
['start/api.query.other.md', 'Query extras'],
['start/api.tx.md', 'Transactions'],
['start/keyring.md', 'Keyring'],
['start/api.tx.subs.md', 'Transaction subscriptions'],
['start/api.tx.wrap.md', 'Complex transactions'],
['start/types.basics.md', 'Type basics'],
['start/types.extend.md', 'Extending types'],
['start/types.create.md', 'Creating types'],
['start/typescript.md', 'TypeScript interfaces'],
['start/typescript.user.md', 'TypeScript user generated'],
['start/FAQ.md', 'FAQ']
]
},
{
title: 'Examples (Promise API)',
path: '/examples/promise/',
collapsable: false,
sidebarDepth: 1,
sidebarDepth: 0,
children: [
['examples/promise/01_simple_connect/', 'Simple connect'],
['examples/promise/02_listen_to_blocks/', 'Listen to blocks'],
@@ -36,19 +63,22 @@ module.exports = {
['examples/promise/06_make_transfer/', 'Make a transfer'],
['examples/promise/08_system_events/', 'Display system events'],
['examples/promise/09_transfer_events/', 'Transaction with events'],
['examples/promise/10_upgrade_chain/', 'Upgrade via sudo']
['examples/promise/10_upgrade_chain/', 'Upgrade via sudo'],
['examples/promise/90_typegen/', 'TypeScript augmentation']
]
},
{
title: 'Substrate interfaces',
title: 'Substrate defaults',
path: '/substrate/',
collapsable: false,
sidebarDepth: 0,
children: [
['/METHODS_RPC.md', 'Substrate RPC'],
['/METHODS_CONSTANTS.md', 'Constants (defaults)'],
['/METHODS_STORAGE.md', 'State storage (defaults)'],
['/METHODS_EXTRINSICS.md', 'Extrinsics (defaults)'],
['/METHODS_EVENTS.md', 'System events (defaults)']
['substrate/rpc.md', 'Substrate RPC'],
['substrate/constants.md', 'Constants'],
['substrate/storage.md', 'State storage'],
['substrate/extrinsics.md', 'Extrinsics'],
['substrate/events.md', 'System events'],
['substrate/errors.md', 'Errors']
]
},
['/api/', '@polkadot/api'],
-220
View File
@@ -1,220 +0,0 @@
## Constants
_The following sections contain the module constants, also known as parameter types.
- **[babe](#babe)**
- **[balances](#balances)**
- **[contracts](#contracts)**
- **[democracy](#democracy)**
- **[elections](#elections)**
- **[finalityTracker](#finalityTracker)**
- **[session](#session)**
- **[staking](#staking)**
- **[timestamp](#timestamp)**
- **[treasury](#treasury)**
___
### babe
▸ **epochDuration**: `u64`
- **summary**: The number of **slots** that an epoch takes. We couple sessions to epochs, i.e. we start a new session once the new epoch begins.
▸ **expectedBlockTime**: `Moment`
- **summary**: The expected average block time at which BABE should be creating blocks. Since BABE is probabilistic it is not trivial to figure out what the expected average block time should be based on the slot duration and the security parameter `c` (where `1 - c` represents the probability of a slot being empty).
___
### balances
▸ **creationFee**: `Balance`
- **summary**: The fee required to create an account.
▸ **existentialDeposit**: `Balance`
- **summary**: The minimum amount required to keep an account open.
▸ **transactionBaseFee**: `Balance`
- **summary**: The fee to be paid for making a transaction; the base.
▸ **transactionByteFee**: `Balance`
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
▸ **transferFee**: `Balance`
- **summary**: The fee required to make a transfer.
___
### contracts
▸ **blockGasLimit**: `Gas`
- **summary**: The maximum amount of gas that could be expended per block. A reasonable default value is 10_000_000.
▸ **callBaseFee**: `Gas`
- **summary**: The base fee charged for calling into a contract. A reasonable default value is 135.
▸ **contractFee**: `BalanceOf`
- **summary**: The fee required to create a contract instance. A reasonable default value is 21.
▸ **createBaseFee**: `Gas`
- **summary**: The base fee charged for creating a contract. A reasonable default value is 175.
▸ **creationFee**: `BalanceOf`
- **summary**: The fee required to create an account.
▸ **maxDepth**: `u32`
- **summary**: The maximum nesting level of a call/create stack. A reasonable default value is 100.
▸ **maxValueSize**: `u32`
- **summary**: The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
▸ **rentByteFee**: `BalanceOf`
- **summary**: Price of a byte of storage per one block interval. Should be greater than 0.
▸ **rentDepositOffset**: `BalanceOf`
- **summary**: The amount of funds a contract should deposit in order to offset the cost of one byte. Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day, 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.
▸ **signedClaimHandicap**: `BlockNumber`
- **summary**: 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
▸ **storageSizeOffset**: `u32`
- **summary**: Size of a contract at the time of creation. This is a simple way to ensure that empty contracts eventually gets deleted.
▸ **surchargeReward**: `BalanceOf`
- **summary**: Reward that is received by the party whose touch has led to removal of a contract.
▸ **tombstoneDeposit**: `BalanceOf`
- **summary**: The minimum amount required to generate a tombstone.
▸ **transactionBaseFee**: `BalanceOf`
- **summary**: The fee to be paid for making a transaction; the base.
▸ **transactionByteFee**: `BalanceOf`
- **summary**: The fee to be paid for making a transaction; the per-byte portion.
▸ **transferFee**: `BalanceOf`
- **summary**: The fee required to make a transfer.
___
### democracy
▸ **cooloffPeriod**: `BlockNumber`
- **summary**: Period in blocks where an external proposal may not be re-submitted after being vetoed.
▸ **emergencyVotingPeriod**: `BlockNumber`
- **summary**: Minimum voting period allowed for an emergency referendum.
▸ **enactmentPeriod**: `BlockNumber`
- **summary**: The minimum period of locking and 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.
▸ **launchPeriod**: `BlockNumber`
- **summary**: How often (in blocks) new public referenda are launched.
▸ **minimumDeposit**: `BalanceOf`
- **summary**: The minimum amount to be used as a deposit for a public referendum proposal.
▸ **votingPeriod**: `BlockNumber`
- **summary**: How often (in blocks) to check for new votes.
___
### elections
▸ **approvalSetSize**: `u32`
- **summary**: The chunk size of the approval vector.
▸ **candidacyBond**: `BalanceOf`
- **summary**: How much should be locked up in order to submit one's candidacy. A reasonable default value is 9.
▸ **carryCount**: `u32`
- **summary**: How many runners-up should have their approvals persist until the next vote. A reasonable default value is 2.
▸ **decayRatio**: `u32`
- **summary**: Decay factor of weight when being accumulated. It should typically be set to __at least__ `membership_size -1` to keep the collective secure. When set to `N`, it indicates `(1/N)^t` of staked is decayed at weight increment step `t`. 0 will result in no weight being added at all (normal approval voting). A reasonable default value is 24.
▸ **inactiveGracePeriod**: `VoteIndex`
- **summary**: How many vote indices need to go by after a target voter's last vote before they can be reaped if their approvals are moot. A reasonable default value is 1.
▸ **presentSlashPerVoter**: `BalanceOf`
- **summary**: The punishment, per voter, if you provide an invalid presentation. A reasonable default value is 1.
▸ **voterSetSize**: `u32`
- **summary**: The chunk size of the voter vector.
▸ **votingBond**: `BalanceOf`
- **summary**: How much should be locked up in order to be able to submit votes.
▸ **votingFee**: `BalanceOf`
- **summary**: The amount of fee paid upon each vote submission, unless if they submit a _hole_ index and replace it.
▸ **votingPeriod**: `BlockNumber`
- **summary**: How often (in blocks) to check for new votes. A reasonable default value is 1000.
___
### finalityTracker
▸ **reportLatency**: `BlockNumber`
- **summary**: The delay after which point things become suspicious. Default is 1000.
▸ **windowSize**: `BlockNumber`
- **summary**: The number of recent samples to keep from this chain. Default is 101.
___
### session
▸ **dedupKeyPrefix**: `Bytes`
- **summary**: Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch of the trie.
___
### staking
▸ **bondingDuration**: `EraIndex`
- **summary**: Number of eras that staked funds must remain bonded for.
▸ **sessionsPerEra**: `SessionIndex`
- **summary**: Number of sessions per era.
___
### timestamp
▸ **minimumPeriod**: `Moment`
- **summary**: 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.
___
### treasury
▸ **burn**: `Permill`
- **summary**: Percentage of spare funds (if any) that are burnt per spend period.
▸ **proposalBond**: `Permill`
- **summary**: 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.
▸ **proposalBondMinimum**: `BalanceOf`
- **summary**: Minimum amount of funds that should be placed in a deposit for making a proposal.
▸ **spendPeriod**: `BlockNumber`
- **summary**: Period between successive spends.
-284
View File
@@ -1,284 +0,0 @@
## Events
Events are emitted for certain operations on the runtime. The following sections describe the events that are part of the default Substrate runtime.
- **[balances](#balances)**
- **[contracts](#contracts)**
- **[council](#council)**
- **[democracy](#democracy)**
- **[elections](#elections)**
- **[grandpa](#grandpa)**
- **[imOnline](#imOnline)**
- **[indices](#indices)**
- **[offences](#offences)**
- **[session](#session)**
- **[staking](#staking)**
- **[sudo](#sudo)**
- **[system](#system)**
- **[technicalCommittee](#technicalCommittee)**
- **[technicalMembership](#technicalMembership)**
- **[treasury](#treasury)**
___
### balances
▸ **NewAccount**(`AccountId`, `Balance`)
- **summary**: A new account was created.
▸ **ReapedAccount**(`AccountId`)
- **summary**: An account was reaped.
▸ **Transfer**(`AccountId`, `AccountId`, `Balance`, `Balance`)
- **summary**: Transfer succeeded (from, to, value, fees).
___
### contracts
▸ **CodeStored**(`Hash`)
- **summary**: Code with the specified hash has been stored.
▸ **Contract**(`AccountId`, `Bytes`)
- **summary**: An event from contract of account.
▸ **Dispatched**(`AccountId`, `bool`)
- **summary**: A call was dispatched from the given account. The bool signals whether it was successful execution or not.
▸ **Instantiated**(`AccountId`, `AccountId`)
- **summary**: Contract deployed by address at the specified address.
▸ **ScheduleUpdated**(`u32`)
- **summary**: Triggered when the current schedule is updated.
▸ **Transfer**(`AccountId`, `AccountId`, `Balance`)
- **summary**: Transfer happened `from` to `to` with given `value` as part of a `call` or `create`.
___
### council
▸ **Approved**(`Hash`)
- **summary**: A motion was approved by the required threshold.
▸ **Disapproved**(`Hash`)
- **summary**: A motion was not approved by the required threshold.
▸ **Executed**(`Hash`, `bool`)
- **summary**: A motion was executed; `bool` is true if returned without error.
▸ **MemberExecuted**(`Hash`, `bool`)
- **summary**: A single member did some action; `bool` is true if returned without error.
▸ **Proposed**(`AccountId`, `ProposalIndex`, `Hash`, `MemberCount`)
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
▸ **Voted**(`AccountId`, `Hash`, `bool`, `MemberCount`, `MemberCount`)
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
___
### democracy
▸ **Cancelled**(`ReferendumIndex`)
▸ **Delegated**(`AccountId`, `AccountId`)
▸ **Executed**(`ReferendumIndex`, `bool`)
▸ **ExternalTabled**()
▸ **NotPassed**(`ReferendumIndex`)
▸ **Passed**(`ReferendumIndex`)
▸ **Proposed**(`PropIndex`, `Balance`)
▸ **Started**(`ReferendumIndex`, `VoteThreshold`)
▸ **Tabled**(`PropIndex`, `Balance`, `Vec<AccountId>`)
▸ **Undelegated**(`AccountId`)
▸ **Vetoed**(`AccountId`, `Hash`, `BlockNumber`)
___
### elections
▸ **BadReaperSlashed**(`AccountId`)
- **summary**: slashed reaper
▸ **TallyFinalized**(`Vec<AccountId>`, `Vec<AccountId>`)
- **summary**: A tally (for approval votes of seat(s)) has ended (with one or more new members).
▸ **TallyStarted**(`u32`)
- **summary**: A tally (for approval votes of seat(s)) has started.
▸ **VoterReaped**(`AccountId`, `AccountId`)
- **summary**: reaped voter, reaper
___
### grandpa
▸ **NewAuthorities**(`Vec<(AuthorityId,u64)>`)
- **summary**: New authority set has been applied.
▸ **Paused**()
- **summary**: Current authority set has been paused.
▸ **Resumed**()
- **summary**: Current authority set has been resumed.
___
### imOnline
▸ **HeartbeatReceived**(`AuthorityId`)
- **summary**: A new heartbeat was received from `AuthorityId`
___
### indices
▸ **NewAccountIndex**(`AccountId`, `AccountIndex`)
- **summary**: A new account index was assigned. This event is not triggered when an existing index is reassigned to another `AccountId`.
___
### offences
▸ **Offence**(`Kind`, `OpaqueTimeSlot`)
- **summary**: There is an offence reported of the given `kind` happened at the `session_index` and (kind-specific) time slot. This event is not deposited for duplicate slashes.
___
### session
▸ **NewSession**(`SessionIndex`)
- **summary**: New session has happened. Note that the argument is the session index, not the block number as the type might suggest.
___
### staking
▸ **OldSlashingReportDiscarded**(`SessionIndex`)
- **summary**: An old slashing report from a prior era was discarded because it could not be processed.
▸ **Reward**(`Balance`)
- **summary**: All validators have been rewarded by the given balance.
▸ **Slash**(`AccountId`, `Balance`)
- **summary**: One validator (and its nominators) has been slashed by the given amount.
___
### sudo
▸ **KeyChanged**(`AccountId`)
- **summary**: The sudoer just switched identity; the old key is supplied.
▸ **Sudid**(`bool`)
- **summary**: A sudo just took place.
___
### system
▸ **ExtrinsicFailed**()
- **summary**: An extrinsic failed.
▸ **ExtrinsicSuccess**()
- **summary**: An extrinsic completed successfully.
___
### technicalCommittee
▸ **Approved**(`Hash`)
- **summary**: A motion was approved by the required threshold.
▸ **Disapproved**(`Hash`)
- **summary**: A motion was not approved by the required threshold.
▸ **Executed**(`Hash`, `bool`)
- **summary**: A motion was executed; `bool` is true if returned without error.
▸ **MemberExecuted**(`Hash`, `bool`)
- **summary**: A single member did some action; `bool` is true if returned without error.
▸ **Proposed**(`AccountId`, `ProposalIndex`, `Hash`, `MemberCount`)
- **summary**: A motion (given hash) has been proposed (by given account) with a threshold (given `MemberCount`).
▸ **Voted**(`AccountId`, `Hash`, `bool`, `MemberCount`, `MemberCount`)
- **summary**: A motion (given hash) has been voted on by given account, leaving a tally (yes votes and no votes given respectively as `MemberCount`).
___
### technicalMembership
▸ **Dummy**(`PhantomData`)
- **summary**: Phantom member, never used.
▸ **MemberAdded**()
- **summary**: The given member was added; see the transaction for who.
▸ **MemberRemoved**()
- **summary**: The given member was removed; see the transaction for who.
▸ **MembersReset**()
- **summary**: The membership was reset; see the transaction for who the new set is.
▸ **MembersSwapped**()
- **summary**: Two members were swapped; see the transaction for who.
___
### treasury
▸ **Awarded**(`ProposalIndex`, `Balance`, `AccountId`)
- **summary**: Some funds have been allocated.
▸ **Burnt**(`Balance`)
- **summary**: Some of our funds have been burnt.
▸ **Proposed**(`ProposalIndex`)
- **summary**: New proposal.
▸ **Rollover**(`Balance`)
- **summary**: Spending has finished; this is the amount that rolls over until next spend.
▸ **Spending**(`Balance`)
- **summary**: We have ended a spend period and will now allocate funds.
-359
View File
@@ -1,359 +0,0 @@
## Extrinsics
_The following sections contain Extrinsics methods are part of the default Substrate runtime._
- **[authorship](#authorship)**
- **[babe](#babe)**
- **[balances](#balances)**
- **[contracts](#contracts)**
- **[council](#council)**
- **[democracy](#democracy)**
- **[elections](#elections)**
- **[finalityTracker](#finalityTracker)**
- **[grandpa](#grandpa)**
- **[imOnline](#imOnline)**
- **[session](#session)**
- **[staking](#staking)**
- **[sudo](#sudo)**
- **[system](#system)**
- **[technicalCommittee](#technicalCommittee)**
- **[technicalMembership](#technicalMembership)**
- **[timestamp](#timestamp)**
- **[treasury](#treasury)**
___
### authorship
▸ **setUncles**(new_uncles: `Vec<Header>`)
- **summary**: Provide a set of uncles.
___
### babe
▸ **setPendingSecondarySlotsChange**(change: `Option<bool>`)
- **summary**: Sets a pending change to enable / disable secondary slot assignment. The pending change will be set at the end of the current epoch and will be enacted at `current_epoch + 2`.
___
### balances
▸ **setBalance**(who: `Address`, new_free: `Compact<Balance>`, new_reserved: `Compact<Balance>`)
- **summary**: Set the balances of a given account. This will alter `FreeBalance` and `ReservedBalance` in storage. it will also decrease the total issuance of the system (`TotalIssuance`). If the new free or reserved balance is below the existential deposit, it will reset the account nonce (`system::AccountNonce`). The dispatch origin for this call is `root`. # <weight> - Independent of the arguments. - Contains a limited number of reads and writes. # </weight>
▸ **transfer**(dest: `Address`, value: `Compact<Balance>`)
- **summary**: Transfer some liquid free balance to another account. `transfer` will set the `FreeBalance` of the sender and receiver. It will decrease the total issuance of the system by the `TransferFee`. If the sender's account is below the existential deposit as a result of the transfer, the account will be reaped. The dispatch origin for this call must be `Signed` by the transactor. # <weight> - Dependent on arguments but not critical, given proper implementations for input config types. See related functions below. - It contains a limited number of reads and writes internally and no complex computation. Related functions: - `ensure_can_withdraw` is always called internally but has a bounded complexity. - Transferring balances to accounts that did not exist before will cause `T::OnNewAccount::on_new_account` to be called. - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced` and `T::OnFreeBalanceZero::on_free_balance_zero`. # </weight>
___
### contracts
▸ **call**(dest: `Address`, value: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, data: `Bytes`)
- **summary**: Makes a call to an account, optionally transferring some balance. * If the account is a smart-contract account, the associated code will be executed and any value will be transferred. * If the account is a regular account, any value will be transferred. * If no account exists and the call value is not less than `existential_deposit`, a regular account will be created and any value will be transferred.
▸ **claimSurcharge**(dest: `AccountId`, aux_sender: `Option<AccountId>`)
- **summary**: Allows block producers to claim a small reward for evicting a contract. If a block producer fails to do so, a regular users will be allowed to claim the reward. If contract is not evicted as a result of this call, no actions are taken and the sender is not eligible for the reward.
▸ **create**(endowment: `Compact<BalanceOf>`, gas_limit: `Compact<Gas>`, code_hash: `CodeHash`, data: `Bytes`)
- **summary**: Creates a new contract from the `codehash` generated by `put_code`, optionally transferring some balance. Creation is executed as follows: - The destination address is computed based on the sender and hash of the code. - The smart-contract account is created at the computed address. - The `ctor_code` is executed in the context of the newly-created account. Buffer returned after the execution is saved as the `code` of the account. That code will be invoked upon any call received by this account. - The contract is initialized.
▸ **putCode**(gas_limit: `Compact<Gas>`, code: `Bytes`)
- **summary**: Stores the given binary Wasm code into the chain's storage and returns its `codehash`. You can instantiate contracts only with stored code.
▸ **updateSchedule**(schedule: `Schedule`)
- **summary**: Updates the schedule for metering contracts. The schedule must have a greater version than the stored schedule.
___
### council
▸ **execute**(proposal: `Proposal`)
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
▸ **propose**(threshold: `Compact<MemberCount>`, proposal: `Proposal`)
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
▸ **setMembers**(new_members: `Vec<AccountId>`)
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
▸ **vote**(proposal: `Hash`, index: `Compact<ProposalIndex>`, approve: `bool`)
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
___
### democracy
▸ **cancelQueued**(when: `Compact<BlockNumber>`, which: `Compact<u32>`, what: `Compact<ReferendumIndex>`)
- **summary**: Cancel a proposal queued for enactment.
▸ **cancelReferendum**(ref_index: `Compact<ReferendumIndex>`)
- **summary**: Remove a referendum.
▸ **delegate**(to: `AccountId`, conviction: `Conviction`)
- **summary**: Delegate vote. # <weight> - One extra DB entry. # </weight>
▸ **emergencyCancel**(ref_index: `ReferendumIndex`)
- **summary**: Schedule an emergency cancellation of a referendum. Cannot happen twice to the same referendum.
▸ **externalPropose**(proposal: `Proposal`)
- **summary**: Schedule a referendum to be tabled once it is legal to schedule an external referendum.
▸ **externalProposeDefault**(proposal: `Proposal`)
- **summary**: Schedule a negative-turnout-bias referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
▸ **externalProposeMajority**(proposal: `Proposal`)
- **summary**: Schedule a majority-carries referendum to be tabled next once it is legal to schedule an external referendum. Unlike `external_propose`, blacklisting has no effect on this and it may replace a pre-scheduled `external_propose` call.
▸ **fastTrack**(proposal_hash: `Hash`, voting_period: `BlockNumber`, delay: `BlockNumber`)
- **summary**: Schedule the currently externally-proposed majority-carries referendum to be tabled immediately. If there is no externally-proposed referendum currently, or if there is one but it is not a majority-carries referendum then it fails. - `proposal_hash`: The hash of the current external proposal. - `voting_period`: The period that is allowed for voting on this proposal. - `delay`: The number of block after voting has ended in approval and this should be enacted. Increased to `EmergencyVotingPeriod` if too low.
▸ **propose**(proposal: `Proposal`, value: `Compact<BalanceOf>`)
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - Two DB changes, one DB entry. # </weight>
▸ **proxyVote**(ref_index: `Compact<ReferendumIndex>`, vote: `Vote`)
- **summary**: Vote in a referendum on behalf of a stash. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # <weight> - O(1). - One DB change, one DB entry. # </weight>
▸ **removeProxy**(proxy: `AccountId`)
- **summary**: Clear the proxy. Called by the stash. # <weight> - One DB clear. # </weight>
▸ **resignProxy**()
- **summary**: Clear the proxy. Called by the proxy. # <weight> - One DB clear. # </weight>
▸ **second**(proposal: `Compact<PropIndex>`)
- **summary**: Propose a sensitive action to be taken. # <weight> - O(1). - One DB entry. # </weight>
▸ **setProxy**(proxy: `AccountId`)
- **summary**: Specify a proxy. Called by the stash. # <weight> - One extra DB entry. # </weight>
▸ **undelegate**()
- **summary**: Undelegate vote. # <weight> - O(1). # </weight>
▸ **vetoExternal**(proposal_hash: `Hash`)
- **summary**: Veto and blacklist the external proposal hash.
▸ **vote**(ref_index: `Compact<ReferendumIndex>`, vote: `Vote`)
- **summary**: Vote in a referendum. If `vote.is_aye()`, the vote is to enact the proposal; otherwise it is a vote to keep the status quo. # <weight> - O(1). - One DB change, one DB entry. # </weight>
___
### elections
▸ **presentWinner**(candidate: `Address`, total: `Compact<BalanceOf>`, index: `Compact<VoteIndex>`)
- **summary**: Claim that `signed` is one of the top Self::carry_count() + current_vote().1 candidates. Only works if the `block_number >= current_vote().0` and `< current_vote().0 + presentation_duration()` `signed` should have at least # <weight> - O(voters) compute. - One DB change. # </weight>
▸ **proxySetApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`)
- **summary**: Set candidate approvals from a proxy. Approval slots stay valid as long as candidates in those slots are registered. # <weight> - Same as `set_approvals` with one additional storage read. # </weight>
▸ **reapInactiveVoter**(reporter_index: `Compact<u32>`, who: `Address`, who_index: `Compact<u32>`, assumed_vote_index: `Compact<VoteIndex>`)
- **summary**: Remove a voter. For it not to be a bond-consuming no-op, all approved candidate indices must now be either unregistered or registered to a candidate that registered the slot after the voter gave their last approval set. Both indices must be provided as explained in [`voter_at`] function. May be called by anyone. Returns the voter deposit to `signed`. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
▸ **removeMember**(who: `Address`)
- **summary**: Remove a particular member from the set. This is effective immediately. Note: A tally should happen instantly (if not already in a presentation period) to fill the seat if removal means that the desired members are not met.
▸ **retractVoter**(index: `Compact<u32>`)
- **summary**: Remove a voter. All votes are cancelled and the voter deposit is returned. The index must be provided as explained in [`voter_at`] function. Also removes the lock on the balance of the voter. See [`do_set_approvals()`]. # <weight> - O(1). - Two fewer DB entries, one DB change. # </weight>
▸ **setApprovals**(votes: `Vec<bool>`, index: `Compact<VoteIndex>`, hint: `SetIndex`)
- **summary**: Set candidate approvals. Approval slots stay valid as long as candidates in those slots are registered. Locks the total balance of caller indefinitely. Only [`retract_voter`] or [`reap_inactive_voter`] can unlock the balance. `hint` argument is interpreted differently based on: - if `origin` is setting approvals for the first time: The index will be checked for being a valid _hole_ in the voter list. - if the hint is correctly pointing to a hole, no fee is deducted from `origin`. - Otherwise, the call will succeed but the index is ignored and simply a push to the last chunk with free space happens. If the new push causes a new chunk to be created, a fee indicated by [`VotingFee`] is deducted. - if `origin` is already a voter: the index __must__ be valid and point to the correct position of the `origin` in the current voters list. Note that any trailing `false` votes in `votes` is ignored; In approval voting, not voting for a candidate and voting false, are equal. # <weight> - O(1). - Two extra DB entries, one DB change. - Argument `votes` is limited in length to number of candidates. # </weight>
▸ **setDesiredSeats**(count: `Compact<u32>`)
- **summary**: Set the desired member count; if lower than the current count, then seats will not be up election when they expire. If more, then a new vote will be started if one is not already in progress.
▸ **setPresentationDuration**(count: `Compact<BlockNumber>`)
- **summary**: Set the presentation duration. If there is currently a vote being presented for, will invoke `finalize_vote`.
▸ **setTermDuration**(count: `Compact<BlockNumber>`)
- **summary**: Set the presentation duration. If there is current a vote being presented for, will invoke `finalize_vote`.
▸ **submitCandidacy**(slot: `Compact<u32>`)
- **summary**: Submit oneself for candidacy. Account must have enough transferrable funds in it to pay the bond. NOTE: if `origin` has already assigned approvals via [`set_approvals`], it will NOT have any usable funds to pass candidacy bond and must first retract. Note that setting approvals will lock the entire balance of the voter until retraction or being reported. # <weight> - Independent of input. - Three DB changes. # </weight>
___
### finalityTracker
▸ **finalHint**(hint: `Compact<BlockNumber>`)
- **summary**: Hint that the author of this block thinks the best finalized block is the given number.
___
### grandpa
▸ **reportMisbehavior**(_report: `Bytes`)
- **summary**: Report some misbehavior.
___
### imOnline
▸ **heartbeat**(heartbeat: `Heartbeat`, signature: `AuthoritySignature`)
___
### session
▸ **setKeys**(keys: `Keys`, proof: `Bytes`)
- **summary**: Sets the session key(s) of the function caller to `key`. Allows an account to set its session key prior to becoming a validator. This doesn't take effect until the next session. The dispatch origin of this function must be signed. # <weight> - O(log n) in number of accounts. - One extra DB entry. # </weight>
___
### staking
▸ **bond**(controller: `Address`, value: `Compact<BalanceOf>`, payee: `RewardDestination`)
- **summary**: Take the origin account as a stash and lock up `value` of its balance. `controller` will be the account that controls it. `value` must be more than the `existential_deposit` defined in the Balances module. The dispatch origin for this call must be _Signed_ by the stash account. # <weight> - Independent of the arguments. Moderate complexity. - O(1). - Three extra DB entries. NOTE: Two of the storage writes (`Self::bonded`, `Self::payee`) are _never_ cleaned unless the `origin` falls below _existential deposit_ and gets removed as dust. # </weight>
▸ **bondExtra**(max_additional: `Compact<BalanceOf>`)
- **summary**: Add some extra amount that have appeared in the stash `free_balance` into the balance up for staking. Use this if there are additional funds in your stash account that you wish to bond. Unlike [`bond`] or [`unbond`] this function does not impose any limitation on the amount that can be added. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # <weight> - Independent of the arguments. Insignificant complexity. - O(1). - One DB entry. # </weight>
▸ **chill**()
- **summary**: Declare no desire to either validate or nominate. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains one read. - Writes are limited to the `origin` account key. # </weight>
▸ **forceNewEra**()
- **summary**: Force there to be a new era at the end of the next session. After this, it will be reset to normal (non-forced) behaviour. # <weight> - No arguments. # </weight>
▸ **forceNoEras**()
- **summary**: Force there to be no new eras indefinitely. # <weight> - No arguments. # </weight>
▸ **nominate**(targets: `Vec<Address>`)
- **summary**: Declare the desire to nominate `targets` for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - The transaction's complexity is proportional to the size of `targets`, which is capped at `MAX_NOMINATIONS`. - Both the reads and writes follow a similar pattern. # </weight>
▸ **setController**(controller: `Address`)
- **summary**: (Re-)set the controller of a stash. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the stash, not the controller. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
▸ **setInvulnerables**(validators: `Vec<AccountId>`)
- **summary**: Set the validators who cannot be slashed (if any).
▸ **setPayee**(payee: `RewardDestination`)
- **summary**: (Re-)set the payment target for a controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
▸ **setValidatorCount**(new: `Compact<u32>`)
- **summary**: The ideal number of validators.
▸ **unbond**(value: `Compact<BalanceOf>`)
- **summary**: Schedule a portion of the stash to be unlocked ready for transfer out after the bond period ends. If this leaves an amount actively bonded less than T::Currency::existential_deposit(), then it is increased to the full amount. Once the unlock period is done, you can call `withdraw_unbonded` to actually move the funds out of management ready for transfer. No more than a limited number of unlocking chunks (see `MAX_UNLOCKING_CHUNKS`) can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need to be called first to remove some of the chunks (if possible). The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::withdraw_unbonded`]. # <weight> - Independent of the arguments. Limited but potentially exploitable complexity. - Contains a limited number of reads. - Each call (requires the remainder of the bonded balance to be above `minimum_balance`) will cause a new entry to be inserted into a vector (`Ledger.unlocking`) kept in storage. The only way to clean the aforementioned storage item is also user-controlled via `withdraw_unbonded`. - One DB entry. </weight>
▸ **validate**(prefs: `ValidatorPrefs`)
- **summary**: Declare the desire to validate for the origin controller. Effects will be felt at the beginning of the next era. The dispatch origin for this call must be _Signed_ by the controller, not the stash. # <weight> - Independent of the arguments. Insignificant complexity. - Contains a limited number of reads. - Writes are limited to the `origin` account key. # </weight>
▸ **withdrawUnbonded**()
- **summary**: Remove any unlocked chunks from the `unlocking` queue from our management. This essentially frees up that balance to be used by the stash account to do whatever it wants. The dispatch origin for this call must be _Signed_ by the controller, not the stash. See also [`Call::unbond`]. # <weight> - Could be dependent on the `origin` argument and how much `unlocking` chunks exist. It implies `consolidate_unlocked` which loops over `Ledger.unlocking`, which is indirectly user-controlled. See [`unbond`] for more detail. - Contains a limited number of reads, yet the size of which could be large based on `ledger`. - Writes are limited to the `origin` account key. # </weight>
___
### sudo
▸ **setKey**(new: `Address`)
- **summary**: Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
▸ **sudo**(proposal: `Proposal`)
- **summary**: Authenticates the sudo key and dispatches a function call with `Root` origin. The dispatch origin for this call must be _Signed_. # <weight> - O(1). - Limited storage reads. - No DB writes. # </weight>
___
### system
▸ **fillBlock**()
- **summary**: A big dispatch that will disallow any other transaction to be included.
▸ **killStorage**(keys: `Vec<Key>`)
- **summary**: Kill some items from storage.
▸ **remark**(_remark: `Bytes`)
- **summary**: Make some on-chain remark.
▸ **setCode**(new: `Bytes`)
- **summary**: Set the new code.
▸ **setHeapPages**(pages: `u64`)
- **summary**: Set the number of pages in the WebAssembly environment's heap.
▸ **setStorage**(items: `Vec<KeyValue>`)
- **summary**: Set some items of storage.
___
### technicalCommittee
▸ **execute**(proposal: `Proposal`)
- **summary**: Dispatch a proposal from a member using the `Member` origin. Origin must be a member of the collective.
▸ **propose**(threshold: `Compact<MemberCount>`, proposal: `Proposal`)
- **summary**: # <weight> - Bounded storage reads and writes. - Argument `threshold` has bearing on weight. # </weight>
▸ **setMembers**(new_members: `Vec<AccountId>`)
- **summary**: Set the collective's membership manually to `new_members`. Be nice to the chain and provide it pre-sorted. Requires root origin.
▸ **vote**(proposal: `Hash`, index: `Compact<ProposalIndex>`, approve: `bool`)
- **summary**: # <weight> - Bounded storage read and writes. - Will be slightly heavier if the proposal is approved / disapproved after the vote. # </weight>
___
### technicalMembership
▸ **addMember**(who: `AccountId`)
- **summary**: Add a member `who` to the set. May only be called from `AddOrigin` or root.
▸ **removeMember**(who: `AccountId`)
- **summary**: Remove a member `who` from the set. May only be called from `RemoveOrigin` or root.
▸ **resetMembers**(members: `Vec<AccountId>`)
- **summary**: Change the membership to a new set, disregarding the existing membership. Be nice and pass `members` pre-sorted. May only be called from `ResetOrigin` or root.
▸ **swapMember**(remove: `AccountId`, add: `AccountId`)
- **summary**: Swap out one member `remove` for another `add`. May only be called from `SwapOrigin` or root.
___
### timestamp
▸ **set**(now: `Compact<Moment>`)
- **summary**: Set the current time. This call should be invoked exactly once per block. It will panic at the finalization phase, if this call hasn't been invoked by that time. The timestamp should be greater than the previous one by the amount specified by `MinimumPeriod`. The dispatch origin for this call must be `Inherent`.
___
### treasury
▸ **approveProposal**(proposal_id: `Compact<ProposalIndex>`)
- **summary**: Approve a proposal. At a later time, the proposal will be allocated to the beneficiary and the original deposit will be returned. # <weight> - O(1). - Limited storage reads. - One DB change. # </weight>
▸ **proposeSpend**(value: `Compact<BalanceOf>`, beneficiary: `Address`)
- **summary**: Put forward a suggestion for spending. A deposit proportional to the value is reserved and slashed if the proposal is rejected. It is returned once the proposal is awarded. # <weight> - O(1). - Limited storage reads. - One DB change, one extra DB entry. # </weight>
▸ **rejectProposal**(proposal_id: `Compact<ProposalIndex>`)
- **summary**: Reject a proposed spend. The original deposit will be slashed. # <weight> - O(1). - Limited storage reads. - One DB clear. # </weight>
-141
View File
@@ -1,141 +0,0 @@
## JSON-RPC
_The following sections contain RPC methods that are Remote Calls available by default and allow you to interact with the actual node, query, and submit. The RPCs are provided by Substrate itself._
- **[author](#author)**
- **[chain](#chain)**
- **[state](#state)**
- **[system](#system)**
___
### author
_Authoring of network items_
▸ **insertKey**(keyType: `Text`, suri: `Text`, maybePublic?: `Bytes`): `Bytes`
- **summary**: Insert a key into the keystore.
▸ **pendingExtrinsics**(): `Vec<Extrinsic>`
- **summary**: Returns all pending extrinsics, potentially grouped by sender
▸ **removeExtrinsic**(bytesOrHash: `Vec<ExtrinsicOrHash>`): `Vec<Hash>`
- **summary**: Remove given extrinsic from the pool and temporarily ban it to prevent reimporting
▸ **rotateKeys**(): `Bytes`
- **summary**: Generate new session keys and returns the corresponding public keys
▸ **submitAndWatchExtrinsic**(extrinsic: `Extrinsic`): `ExtrinsicStatus`
- **summary**: Submit and subscribe to watch an extrinsic until unsubscribed
▸ **submitExtrinsic**(extrinsic: `Extrinsic`): `Hash`
- **summary**: Submit a fully formatted extrinsic for block inclusion
___
### chain
_Retrieval of chain data_
▸ **getBlock**(hash?: `Hash`): `SignedBlock`
- **summary**: Get header and body of a relay chain block
▸ **getBlockHash**(blockNumber?: `BlockNumber`): `Hash`
- **summary**: Get the block hash for a specific block
▸ **getFinalizedHead**(): `Hash`
- **summary**: Get hash of the last finalized block in the canon chain
▸ **getHeader**(hash?: `Hash`): `Header`
- **summary**: Retrieves the header for a specific block
▸ **getRuntimeVersion**(hash?: `Hash`): `RuntimeVersion`
- **summary**: Get the runtime version (alias of state_getRuntimeVersion)
▸ **subscribeFinalizedHeads**(): `Header`
- **summary**: Retrieves the best finalized header via subscription
▸ **subscribeNewHeads**(): `Header`
- **summary**: Retrieves the best header via subscription
▸ **subscribeRuntimeVersion**(): `RuntimeVersion`
- **summary**: Retrieves the runtime version via subscription
___
### state
_Query of state_
▸ **call**(method: `Text`, data: `Bytes`, block?: `Hash`): `Bytes`
- **summary**: Perform a call to a builtin on the chain
▸ **getChildKeys**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `Vec<StorageKey>`
- **summary**: Retrieves the keys with prefix of a specific child storage
▸ **getChildStorage**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `StorageData`
- **summary**: Retrieves the child storage for a key
▸ **getChildStorageHash**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `Hash`
- **summary**: Retrieves the child storage hash
▸ **getChildStorageSize**(childStorageKey: `StorageKey`, key: `StorageKey`, block?: `Hash`): `u64`
- **summary**: Retrieves the child storage size
▸ **getKeys**(key: `StorageKey`, block?: `Hash`): `Vec<StorageKey>`
- **summary**: Retrieves the keys with a certain prefix
▸ **getMetadata**(block?: `Hash`): `Metadata`
- **summary**: Returns the runtime metadata
▸ **getRuntimeVersion**(hash?: `Hash`): `RuntimeVersion`
- **summary**: Get the runtime version
▸ **getStorage**(key: `StorageKey`, block?: `Hash`): `StorageData`
- **summary**: Retrieves the storage for a key
▸ **getStorageHash**(key: `StorageKey`, block?: `Hash`): `Hash`
- **summary**: Retrieves the storage hash
▸ **getStorageSize**(key: `StorageKey`, block?: `Hash`): `u64`
- **summary**: Retrieves the storage size
▸ **queryStorage**(keys: `Vec<StorageKey>`, startBlock: `Hash`, block?: `Hash`): `Vec<StorageChangeSet>`
- **summary**: Query historical storage entries (by key) starting from a start block
▸ **subscribeStorage**(keys: `Vec<StorageKey>`): `StorageChangeSet`
- **summary**: Subscribes to storage changes for the provided keys
___
### system
_Calls to retrieve system info_
▸ **chain**(): `Text`
- **summary**: Retrieves the chain
▸ **health**(): `Health`
- **summary**: Return health status of the node
▸ **name**(): `Text`
- **summary**: Retrieves the node name
▸ **networkState**(): `NetworkState`
- **summary**: Returns current state of the network
▸ **peers**(): `Vec<PeerInfo>`
- **summary**: Returns the currently connected peers
▸ **properties**(): `ChainProperties`
- **summary**: Get a custom set of properties as a JSON object, defined in the chain spec
▸ **version**(): `Text`
- **summary**: Retrieves the version of the node
-544
View File
@@ -1,544 +0,0 @@
## Storage
_The following sections contain Storage methods are part of the default Substrate runtime._
- **[authorship](#authorship)**
- **[babe](#babe)**
- **[balances](#balances)**
- **[contracts](#contracts)**
- **[council](#council)**
- **[democracy](#democracy)**
- **[elections](#elections)**
- **[grandpa](#grandpa)**
- **[imOnline](#imOnline)**
- **[indices](#indices)**
- **[offences](#offences)**
- **[session](#session)**
- **[staking](#staking)**
- **[sudo](#sudo)**
- **[system](#system)**
- **[technicalCommittee](#technicalCommittee)**
- **[technicalMembership](#technicalMembership)**
- **[timestamp](#timestamp)**
- **[treasury](#treasury)**
- **[substrate](#substrate)**
___
### authorship
▸ **author**(): `Option<AccountId>`
- **summary**: Author of current block.
▸ **didSetUncles**(): `bool`
- **summary**: Whether uncles were already set in this block.
▸ **uncles**(): `Vec<UncleEntryItem>`
- **summary**: Uncles
___
### babe
▸ **authorities**(): `Vec<(AuthorityId,BabeAuthorityWeight)>`
- **summary**: Current epoch authorities.
▸ **currentSlot**(): `u64`
- **summary**: Current slot number.
▸ **epochIndex**(): `u64`
- **summary**: Current epoch index.
▸ **epochStartSlot**(): `u64`
- **summary**: Slot at which the current epoch started. It is possible that no block was authored at the given slot and the epoch change was signalled later than this.
▸ **initialized**(): `Option<bool>`
- **summary**: Temporary value (cleared at block finalization) which is true if per-block initialization has already been called for current block.
▸ **nextRandomness**(): `[u8;32]`
- **summary**: Next epoch randomness.
▸ **pendingSecondarySlotsChange**(): `Option<bool>`
- **summary**: Pending change to enable/disable secondary slots which will be triggered at `current_epoch + 2`.
▸ **randomness**(): `[u8;32]`
- **summary**: The epoch randomness for the *current* epoch. # Security This MUST NOT be used for gambling, as it can be influenced by a malicious validator in the short term. It MAY be used in many cryptographic protocols, however, so long as one remembers that this (like everything else on-chain) it is public. For example, it can be used where a number is needed that cannot have been chosen by an adversary, for purposes such as public-coin zero-knowledge proofs.
▸ **secondarySlots**(): `(bool,bool)`
- **summary**: Whether secondary slots are enabled in case the VRF-based slot is empty for the current epoch and the next epoch, respectively.
▸ **segmentIndex**(): `u32`
- **summary**: Randomness under construction. We make a tradeoff between storage accesses and list length. We store the under-construction randomness in segments of up to `UNDER_CONSTRUCTION_SEGMENT_LENGTH`. Once a segment reaches this length, we begin the next one. We reset all segments and return to `0` at the beginning of every epoch.
▸ **underConstruction**(`u32`): `Vec<[u8;32]>`
___
### balances
▸ **freeBalance**(`AccountId`): `Balance`
- **summary**: The 'free' balance of a given account. This is the only balance that matters in terms of most operations on tokens. It alone is used to determine the balance when in the contract execution environment. When this balance falls below the value of `ExistentialDeposit`, then the 'current account' is deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback is invoked, giving a chance to external modules to clean up data associated with the deleted account. `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.
▸ **locks**(`AccountId`): `Vec<BalanceLock>`
- **summary**: Any liquidity locks on some account balances.
▸ **reservedBalance**(`AccountId`): `Balance`
- **summary**: The amount of the balance of a given account that is externally reserved; this can still get slashed, but gets slashed last of all. This balance is a 'reserve' balance that other subsystems use in order to set aside tokens that are still 'owned' by the account holder, but which are suspendable. When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account' is deleted: specifically, `ReservedBalance`. `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets collapsed to zero if it ever becomes less than `ExistentialDeposit`.)
▸ **totalIssuance**(): `Balance`
- **summary**: The total units issued in the system.
▸ **vesting**(`AccountId`): `Option<VestingSchedule>`
- **summary**: Information regarding the vesting of a given account.
___
### contracts
▸ **accountCounter**(): `u64`
- **summary**: The subtrie counter.
▸ **codeStorage**(`CodeHash`): `Option<PrefabWasmModule>`
- **summary**: A mapping between an original code hash and instrumented wasm code, ready for execution.
▸ **contractInfoOf**(`AccountId`): `Option<ContractInfo>`
- **summary**: The code associated with a given account.
▸ **currentSchedule**(): `Schedule`
- **summary**: Current cost schedule for contracts.
▸ **gasPrice**(): `BalanceOf`
- **summary**: The price of one unit of gas.
▸ **gasSpent**(): `Gas`
- **summary**: Gas spent so far in this block.
▸ **pristineCode**(`CodeHash`): `Option<Bytes>`
- **summary**: A mapping from an original code hash to the original code, untouched by instrumentation.
___
### council
▸ **members**(): `Vec<AccountId>`
- **summary**: The current members of the collective. This is stored sorted (just by value).
▸ **proposalCount**(): `u32`
- **summary**: Proposals so far.
▸ **proposalOf**(`Hash`): `Option<Proposal>`
- **summary**: Actual proposal for a given hash, if it's current.
▸ **proposals**(): `Vec<Hash>`
- **summary**: The hashes of the active proposals.
▸ **voting**(`Hash`): `Option<Votes>`
- **summary**: Votes on a given proposal, if it is ongoing.
___
### democracy
▸ **blacklist**(`Hash`): `Option<(BlockNumber,Vec<AccountId>)>`
- **summary**: A record of who vetoed what. Maps proposal hash to a possible existent block number (until when it may not be resubmitted) and who vetoed it.
▸ **cancellations**(`Hash`): `bool`
- **summary**: Record of all proposals that have been subject to emergency cancellation.
▸ **delegations**(`AccountId`): `((AccountId,Conviction), Linkage<AccountId>)`
- **summary**: Get the account (and lock periods) to which another account is delegating vote.
▸ **depositOf**(`PropIndex`): `Option<(BalanceOf,Vec<AccountId>)>`
- **summary**: Those who have locked a deposit.
▸ **dispatchQueue**(`BlockNumber`): `Vec<Option<(Proposal,ReferendumIndex)>>`
- **summary**: Queue of successful referenda to be dispatched.
▸ **lastTabledWasExternal**(): `bool`
- **summary**: True if the last referendum tabled was submitted externally. False if it was a public proposal.
▸ **nextExternal**(): `Option<(Proposal,VoteThreshold)>`
- **summary**: The referendum to be tabled whenever it would be valid to table an external proposal. This happens when a referendum needs to be tabled and one of two conditions are met: - `LastTabledWasExternal` is `false`; or - `PublicProps` is empty.
▸ **nextTally**(): `ReferendumIndex`
- **summary**: The next referendum index that should be tallied.
▸ **proxy**(`AccountId`): `Option<AccountId>`
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
▸ **publicPropCount**(): `PropIndex`
- **summary**: The number of (public) proposals that have been made so far.
▸ **publicProps**(): `Vec<(PropIndex,Proposal,AccountId)>`
- **summary**: The public proposals. Unsorted.
▸ **referendumCount**(): `ReferendumIndex`
- **summary**: The next free referendum index, aka the number of referenda started so far.
▸ **referendumInfoOf**(`ReferendumIndex`): `Option<ReferendumInfo>`
- **summary**: Information concerning any given referendum.
▸ **voteOf**(`(ReferendumIndex,AccountId)`): `Vote`
- **summary**: Get the vote in a given referendum of a particular voter. The result is meaningful only if `voters_for` includes the voter when called with the referendum (you'll get the default `Vote` value otherwise). If you don't want to check `voters_for`, then you can also check for simple existence with `VoteOf::exists` first.
▸ **votersFor**(`ReferendumIndex`): `Vec<AccountId>`
- **summary**: Get the voters for the current proposal.
___
### elections
▸ **approvalsOf**(`(AccountId,SetIndex)`): `Vec<ApprovalFlag>`
- **summary**: A list of votes for each voter. The votes are stored as numeric values and parsed in a bit-wise manner. In order to get a human-readable representation (`Vec<bool>`), use [`all_approvals_of`]. Furthermore, each vector of scalars is chunked with the cap of `APPROVAL_SET_SIZE`.
▸ **candidateCount**(): `u32`
- **summary**: Current number of active candidates
▸ **candidates**(): `Vec<AccountId>`
- **summary**: The present candidate list.
▸ **desiredSeats**(): `u32`
- **summary**: Number of accounts that should constitute the collective.
▸ **leaderboard**(): `Option<Vec<(BalanceOf,AccountId)>>`
- **summary**: Get the leaderboard if we're in the presentation phase. The first element is the weight of each entry; It may be the direct summed approval stakes, or a weighted version of it.
▸ **members**(): `Vec<(AccountId,BlockNumber)>`
- **summary**: The current membership. When there's a vote going on, this should still be used for executive matters. The block number (second element in the tuple) is the block that their position is active until (calculated by the sum of the block number when the member was elected and their term duration).
▸ **nextFinalize**(): `Option<(BlockNumber,u32,Vec<AccountId>)>`
- **summary**: The accounts holding the seats that will become free on the next tally.
▸ **nextVoterSet**(): `SetIndex`
- **summary**: the next free set to store a voter in. This will keep growing.
▸ **presentationDuration**(): `BlockNumber`
- **summary**: How long to give each top candidate to present themselves after the vote ends.
▸ **proxy**(`AccountId`): `Option<AccountId>`
- **summary**: Who is able to vote for whom. Value is the fund-holding account, key is the vote-transaction-sending account.
▸ **registerInfoOf**(`AccountId`): `Option<(VoteIndex,u32)>`
- **summary**: The vote index and list slot that the candidate `who` was registered or `None` if they are not currently registered.
▸ **termDuration**(): `BlockNumber`
- **summary**: How long each position is active for.
▸ **voteCount**(): `VoteIndex`
- **summary**: The total number of vote rounds that have happened or are in progress.
▸ **voterCount**(): `SetIndex`
- **summary**: Current number of Voters.
▸ **voterInfoOf**(`AccountId`): `Option<VoterInfo>`
- **summary**: Basic information about a voter.
▸ **voters**(`SetIndex`): `Vec<Option<AccountId>>`
- **summary**: The present voter list (chunked and capped at [`VOTER_SET_SIZE`]).
___
### grandpa
▸ **authorities**(): `Vec<(AuthorityId,AuthorityWeight)>`
- **summary**: The current authority set.
▸ **nextForced**(): `Option<BlockNumber>`
- **summary**: next block number where we can force a change.
▸ **pendingChange**(): `Option<StoredPendingChange>`
- **summary**: Pending change: (signaled at, scheduled change).
▸ **stalled**(): `Option<(BlockNumber,BlockNumber)>`
- **summary**: `true` if we are currently stalled.
▸ **state**(): `StoredState`
- **summary**: State of the current authority set.
___
### imOnline
▸ **gossipAt**(): `BlockNumber`
- **summary**: The block number when we should gossip.
▸ **keys**(): `Vec<AuthorityId>`
- **summary**: The current set of keys that may issue a heartbeat.
▸ **receivedHeartbeats**(`SessionIndex, AuthIndex`): `Bytes`
- **summary**: For each session index we keep a mapping of `AuthorityId` to `offchain::OpaqueNetworkState`.
___
### indices
▸ **enumSet**(`AccountIndex`): `Vec<AccountId>`
- **summary**: The enumeration sets.
▸ **nextEnumSet**(): `AccountIndex`
- **summary**: The next free enumeration set.
___
### offences
▸ **concurrentReportsIndex**(`Kind, OpaqueTimeSlot`): `Vec<ReportIdOf>`
- **summary**: A vector of reports of the same kind that happened at the same time slot.
▸ **reports**(`ReportIdOf`): `Option<OffenceDetails>`
- **summary**: The primary structure that holds all offence records keyed by report identifiers.
▸ **reportsByKindIndex**(`Kind`): `Bytes`
- **summary**: Enumerates all reports of a kind along with the time they happened. All reports are sorted by the time of offence. Note that the actual type of this mapping is `Vec<u8>`, this is because values of different types are not supported at the moment so we are doing the manual serialization.
___
### session
▸ **changed**(): `bool`
- **summary**: True if anything has changed in this session.
▸ **currentIndex**(): `SessionIndex`
- **summary**: Current index of the session.
▸ **keyOwner**(`Bytes, (KeyTypeId,Bytes)`): `Option<ValidatorId>`
- **summary**: The owner of a key. The second key is the `KeyTypeId` + the encoded key. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
▸ **nextKeys**(`Bytes, ValidatorId`): `Option<Keys>`
- **summary**: The next session keys for a validator. The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of the trie. Having all data in the same branch should prevent slowing down other queries.
▸ **queuedChanged**(): `bool`
- **summary**: Queued keys changed.
▸ **queuedKeys**(): `Vec<(ValidatorId,Keys)>`
- **summary**: The queued keys for the next session. When the next session begins, these keys will be used to determine the validator's session keys.
▸ **validators**(): `Vec<ValidatorId>`
- **summary**: The current set of validators.
___
### staking
▸ **bonded**(`AccountId`): `Option<AccountId>`
- **summary**: Map from all locked "stash" accounts to the controller account.
▸ **bondedEras**(): `Vec<(EraIndex,SessionIndex)>`
- **summary**: A mapping from still-bonded eras to the first session index of that era.
▸ **currentElected**(): `Vec<AccountId>`
- **summary**: The currently elected validator set keyed by stash account ID.
▸ **currentEra**(): `EraIndex`
- **summary**: The current era index.
▸ **currentEraRewards**(): `EraRewards`
- **summary**: Rewards for the current era. Using indices of current elected set.
▸ **currentEraStart**(): `MomentOf`
- **summary**: The start of the current era.
▸ **currentEraStartSessionIndex**(): `SessionIndex`
- **summary**: The session index at which the current era started.
▸ **eraSlashJournal**(`EraIndex`): `Vec<SlashJournalEntry>`
- **summary**: All slashes that have occurred in a given era.
▸ **forceEra**(): `Forcing`
- **summary**: True if the next session change will be a new era regardless of index.
▸ **invulnerables**(): `Vec<AccountId>`
- **summary**: Any validators that may never be slashed or forcibly kicked. It's a Vec since they're easy to initialize and the performance hit is minimal (we expect no more than four invulnerables) and restricted to testnets.
▸ **ledger**(`AccountId`): `Option<StakingLedger>`
- **summary**: Map from all (unlocked) "controller" accounts to the info regarding the staking.
▸ **minimumValidatorCount**(): `u32`
- **summary**: Minimum number of staking participants before emergency conditions are imposed.
▸ **nominators**(`AccountId`): `(Vec<AccountId>, Linkage<AccountId>)`
- **summary**: The map from nominator stash key to the set of stash keys of all validators to nominate.
▸ **payee**(`AccountId`): `RewardDestination`
- **summary**: Where the reward payment should be made. Keyed by stash.
▸ **slashRewardFraction**(): `Perbill`
- **summary**: The percentage of the slash that is distributed to reporters. The rest of the slashed value is handled by the `Slash`.
▸ **slotStake**(): `BalanceOf`
- **summary**: The amount of balance actively at stake for each validator slot, currently. This is used to derive rewards and punishments.
▸ **stakers**(`AccountId`): `Exposure`
- **summary**: Nominators for a particular account that is in action right now. You can't iterate through validators here, but you can find them in the Session module. This is keyed by the stash account.
▸ **validatorCount**(): `u32`
- **summary**: The ideal number of staking participants.
▸ **validators**(`AccountId`): `(ValidatorPrefs, Linkage<AccountId>)`
- **summary**: The map from (wannabe) validator stash key to the preferences of that validator.
___
### sudo
▸ **key**(): `AccountId`
- **summary**: The `AccountId` of the sudo key.
___
### system
▸ **accountNonce**(`AccountId`): `Index`
- **summary**: Extrinsics nonce for accounts.
▸ **allExtrinsicsLen**(): `Option<u32>`
- **summary**: Total length (in bytes) for all extrinsics put together, for the current block.
▸ **allExtrinsicsWeight**(): `Option<Weight>`
- **summary**: Total weight for all extrinsics put together, for the current block.
▸ **blockHash**(`BlockNumber`): `Hash`
- **summary**: Map of block numbers to block hashes.
▸ **digest**(): `DigestOf`
- **summary**: Digest of the current block, also part of the block header.
▸ **eventCount**(): `EventIndex`
- **summary**: The number of events in the `Events<T>` list.
▸ **events**(): `Vec<EventRecord>`
- **summary**: Events deposited for the current block.
▸ **eventTopics**(`Null, Hash`): `Vec<(BlockNumber,EventIndex)>`
- **summary**: Mapping between a topic (represented by T::Hash) and a vector of indexes of events in the `<Events<T>>` list. The first key serves no purpose. This field is declared as double_map just for convenience of using `remove_prefix`. All topic vectors have deterministic storage locations depending on the topic. This allows light-clients to leverage the changes trie storage tracking mechanism and in case of changes fetch the list of events of interest. The value has the type `(T::BlockNumber, EventIndex)` because if we used only just the `EventIndex` then in case if the topic has the same contents on the next block no notification will be triggered thus the event might be lost.
▸ **extrinsicCount**(): `Option<u32>`
- **summary**: Total extrinsics count for the current block.
▸ **extrinsicData**(`u32`): `Bytes`
- **summary**: Extrinsics data for the current block (maps an extrinsic's index to its data).
▸ **extrinsicsRoot**(): `Hash`
- **summary**: Extrinsics root of the current block, also part of the block header.
▸ **nextWeightMultiplier**(): `WeightMultiplier`
- **summary**: The next weight multiplier. This should be updated at the end of each block based on the saturation level (weight).
▸ **number**(): `BlockNumber`
- **summary**: The current block number being processed. Set by `execute_block`.
▸ **parentHash**(): `Hash`
- **summary**: Hash of the previous block.
▸ **randomMaterial**(): `(i8,Vec<Hash>)`
- **summary**: Series of block headers from the last 81 blocks that acts as random seed material. This is arranged as a ring buffer with the `i8` prefix being the index into the `Vec` of the oldest hash.
___
### technicalCommittee
▸ **members**(): `Vec<AccountId>`
- **summary**: The current members of the collective. This is stored sorted (just by value).
▸ **proposalCount**(): `u32`
- **summary**: Proposals so far.
▸ **proposalOf**(`Hash`): `Option<Proposal>`
- **summary**: Actual proposal for a given hash, if it's current.
▸ **proposals**(): `Vec<Hash>`
- **summary**: The hashes of the active proposals.
▸ **voting**(`Hash`): `Option<Votes>`
- **summary**: Votes on a given proposal, if it is ongoing.
___
### technicalMembership
▸ **members**(): `Vec<AccountId>`
- **summary**: The current membership, stored as an ordered Vec.
___
### timestamp
▸ **didUpdate**(): `bool`
- **summary**: Did the timestamp get updated in this block?
▸ **now**(): `Moment`
- **summary**: Current time for the current block.
___
### treasury
▸ **approvals**(): `Vec<ProposalIndex>`
- **summary**: Proposal indices that have been approved but not yet awarded.
▸ **proposalCount**(): `ProposalIndex`
- **summary**: Number of proposals that have been made.
▸ **proposals**(`ProposalIndex`): `Option<TreasuryProposal>`
- **summary**: Proposals that have been made.
---
### substrate
_These are keys that are always available to the runtime implementation_
▸ **changesTrieConfig**(): `u32`
- **summary**: Changes trie configuration is stored under this key.
▸ **childStorageKeyPrefix**(): `u32`
- **summary**: Prefix of child storage keys.
▸ **code**(): `Bytes`
- **summary**: Wasm code of the runtime.
▸ **extrinsicIndex**(): `u32`
- **summary**: Current extrinsic index (u32) is stored under this key.
▸ **heapPages**(): `u64`
- **summary**: Number of wasm linear memory pages required for execution of the runtime.
---
+2 -2
View File
@@ -20,8 +20,8 @@ footer: Apache-2 Licensed | Copyright © 2017-2019 polkadot-js authors and contr
The API provides application developers the ability to query a node and interact with the Polkadot or Substrate chains using Javascript. Here you will find documentation and examples to get you started.
::: tip Examples
In a rush and just want examples? [Jump right in](/examples/promise/) and get a handle on using the API in your projects.
::: tip Getting started & Examples
[Jump right in](/start/) and get an overview on using the API in your projects, from installation all the way through to making it do magic. Already understand how things work and just want the examples? [The ApiPromise examples](/examples/promise/) provide some basic recipies.
:::
## Available packages
+29 -6
View File
@@ -1,3 +1,24 @@
## Getting started
- [Introduction](start/README.md)
- [Installation](start/install.md)
- [Basics](start/basics.md)
- [Creating](start/create.md)
- [Constant queries](start/api.consts.md)
- [State queries](start/api.query.md)
- [RPC queries](start/api.rpc.md)
- [State subscriptions](start/api.query.subs.md)
- [Multi state retrieval](start/api.query.multi.md)
- [State query utilities](start/api.query.other.md)
- [Transactions](start/api.tx.md)
- [Keyring](start/keyring.md)
- [Transaction subscriptions](start/api.tx.subs.md)
- [Complex transactions](start/api.tx.wrap.md)
- [Type basics](start/types.basics.md)
- [Type extension](start/types.extend.md)
- [TypeScript interfaces](start/typescript.md)
- [TypeScript user generated](start/typescript.user.md)
## Packages
- [api](api/README.md)
@@ -10,13 +31,15 @@
## Interfaces
- [RPC](METHODS_RPC.md)
- [Constants (runtime)](METHODS_CONSTANTS.md)
- [Chain state (runtime)](METHODS_STORAGE.md)
- [Extrinsics (runtime)](METHODS_EXTRINSICS.md)
- [Events (runtime)](METHODS_EVENTS.md)
- [Substrate](substrate/README.md)
- [RPC](substrate/rpc.md)
- [Constants (runtime)](substrate/constants.md)
- [Chain state (runtime)](substrate/storage.md)
- [Extrinsics (runtime)](substrate/extrinsics.md)
- [Events (runtime)](substrate/events.md)
## Examples
- [ApiPromise](examples/promise/README.md)
- [Simple connect](examples/promise/01_simple_connect/README.md)
- [Listen to blocks](examples/promise/02_listen_to_blocks/README.md)
@@ -24,7 +47,7 @@
- [Unsubscribe from listening](examples/promise/04_unsubscribe/README.md)
- [Read chain state](examples/promise/05_read_storage/README.md)
- [Make a transfer](examples/promise/06_make_transfer/README.md)
- [Display system events](examples/promise/08_system_events/README.md)(
- [Display system events](examples/promise/08_system_events/README.md)
- [Transaction with events](examples/promise/09_transfer_events/README.md)
- [Upgrade via sudo](examples/promise/10_upgrade_chain/README.md)
- [ApiRx](examples/rx/README.md)
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Required imports
const { ApiPromise, WsProvider } = require('@polkadot/api');
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -8,13 +10,13 @@ async function main () {
// the API has connected to the node and completed the initialisation process
const api = await ApiPromise.create();
// we only display a couple, then unsubscribe
// We only display a couple, then unsubscribe
let count = 0;
// Subscribe to the new headers on-chain. The callback is fired when new headers
// are found, the call itself returns a promise with a subscription that can be
// used to unsubscribe from the newHead subscription
const unsubscribe = await api.rpc.chain.subscribeNewHead((header) => {
const unsubscribe = await api.rpc.chain.subscribeNewHeads((header) => {
console.log(`Chain is at block: #${header.number}`);
if (++count === 256) {
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -11,21 +13,23 @@ async function main () {
// Retrieve the initial balance. Since the call has no callback, it is simply a promise
// that resolves to the current on-chain value
let previous = await api.query.balances.freeBalance(Alice);
let { nonce: previousNonce, data: { free: previousFree } } = await api.query.system.account(Alice);
console.log(`${Alice} has a balance of ${previous}`);
console.log(`${Alice} has a balance of ${previousFree}, nonce ${previousNonce}`);
console.log(`You may leave this example running and start example 06 or transfer any value to ${Alice}`);
// Here we subscribe to any balance changes and update the on-screen value
api.query.balances.freeBalance(Alice, (current) => {
api.query.system.account(Alice, ({ nonce: currentNonce, data: { free: currentFree } }) => {
// Calculate the delta
const change = current.sub(previous);
const change = currentFree.sub(previousFree);
// Only display positive value changes (Since we are pulling `previous` above already,
// the initial balance change will also be zero)
if (!change.isZero()) {
previous = current;
console.log(`New balance change of: ${change}`);
console.log(`New balance change of ${change}, nonce ${currentNonce}`);
previousFree = currentFree;
previousNonce = currentNonce;
}
});
}
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -13,8 +15,8 @@ async function main () {
console.log('Tracking balances for:', [ALICE, BOB]);
// Subscribe and listen to several balance changes
api.query.balances.freeBalance.multi([ALICE, BOB], (balances) => {
console.log('Change detected, new balances: ', balances);
api.query.system.account.multi([ALICE, BOB], (balances) => {
console.log('Change detected, new balances: ', balances.map(({ data: { free } }) => free));
});
}
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -6,8 +8,8 @@ async function main () {
// Create a new instance of the api
const api = await ApiPromise.create();
// Subscribe to chain updates and log the current block number on update.
const unsubscribe = await api.rpc.chain.subscribeNewHead((header) => {
// Subscribe to chain updates and log the current block number on update.
const unsubscribe = await api.rpc.chain.subscribeNewHeads((header) => {
console.log(`Chain is at block: #${header.number}`);
});
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -10,8 +12,8 @@ async function main () {
const api = await ApiPromise.create();
// Make our basic chain state/storage queries, all in one go
const [accountNonce, now, validators] = await Promise.all([
api.query.system.accountNonce(ALICE),
const [{ nonce: accountNonce }, now, validators] = await Promise.all([
api.query.system.account(ALICE),
api.query.timestamp.now(),
api.query.session.validators()
]);
@@ -23,14 +25,15 @@ async function main () {
// Retrieve the balances for all validators
const validatorBalances = await Promise.all(
validators.map(authorityId =>
api.query.balances.freeBalance(authorityId)
api.query.system.account(authorityId)
)
);
// Print out the authorityIds and balances of all validators
console.log('validators', validators.map((authorityId, index) => ({
address: authorityId.toString(),
balance: validatorBalances[index].toString()
balance: validatorBalances[index].data.free.toHuman(),
nonce: validatorBalances[index].nonce.toHuman()
})));
}
}
@@ -2,4 +2,4 @@
In addition to querying the latest storage, you can make storage queries at a specific blockhash. Be aware that the node applies a pruning strategy and typically only keeps the last 256 blocks, unless run in archive mode.
<<< @/docs/examples/promise/07_read_storage_at/index.js
<<< @/docs/examples/promise/05_read_storage_at/index.js
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -10,21 +12,21 @@ async function main () {
// Create our API with a default connection to the local node
const api = await ApiPromise.create();
// retrieve the last block header, extracting the hash and parentHash
// Retrieve the last block header, extracting the hash and parentHash
const { hash, parentHash } = await api.rpc.chain.getHeader();
console.log(`last header hash ${hash.toHex()}`);
// retrieve the balance at the preceding block for Alice. For at queries
// Retrieve the balance at the preceding block for Alice. For at queries
// the format is always `.at(<blockhash>, ...params)`
const balance = await api.query.balances.freeBalance.at(parentHash, ALICE);
const balance = await api.query.system.account.at(parentHash, ALICE);
console.log(`Alice's balance at ${parentHash.toHex()} was ${balance}`);
console.log(`Alice's balance at ${parentHash.toHex()} was ${balance.data.free}`);
// now perform a multi query, returning multiple balances at once
const balances = await api.query.balances.freeBalance.multi([ALICE, BOB]);
// Now perform a multi query, returning multiple balances at once
const balances = await api.query.system.account.multi([ALICE, BOB]);
console.log(`Current balances for Alice and Bob are ${balances[0]} and ${balances[1]}`);
console.log(`Current balances for Alice and Bob are ${balances[0].data.free} and ${balances[1].data.free}`);
}
main().catch(console.error).finally(() => process.exit());
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API, Keyring and some utility functions
const { ApiPromise } = require('@polkadot/api');
@@ -12,7 +14,7 @@ async function main () {
// Constuct the keying after the API (crypto has an async init)
const keyring = new Keyring({ type: 'sr25519' });
// Add alice to our keyring with a hard-deived path (empty phrase, so uses dev)
// Add Alice to our keyring with a hard-deived path (empty phrase, so uses dev)
const alice = keyring.addFromUri('//Alice');
// Create a extrinsic, transferring 12345 units to Bob
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API, Keyring and some utility functions
const { ApiPromise } = require('@polkadot/api');
@@ -13,16 +15,16 @@ async function main () {
// Constuct the keying after the API (crypto has an async init)
const keyring = new Keyring({ type: 'sr25519' });
// Add alice to our keyring with a hard-derived path (empty phrase, so uses dev)
// Add Alice to our keyring with a hard-derived path (empty phrase, so uses dev)
const alice = keyring.addFromUri('//Alice');
// Get nonce for account
const nonce = await api.query.system.accountNonce(alice.address);
const { nonce } = await api.query.system.account(alice.address);
// get current block
// Get current block
const signedBlock = await api.rpc.chain.getBlock();
// get current block height and hash
// Get current block height and hash
const currentHeight = signedBlock.block.header.number;
const blockHash = signedBlock.block.header.hash;
@@ -10,8 +10,7 @@
"start": "node index.js"
},
"dependencies": {
"@polkadot/api": "0.80.1",
"@polkadot/keyring": "^0.93.1"
"@polkadot/api": "*"
},
"devDependencies": {
"rimraf": "^2.6.2"
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiPromise } = require('@polkadot/api');
@@ -6,21 +8,21 @@ async function main () {
// Create our API with a default connection to the local node
const api = await ApiPromise.create();
// subscribe to system events via storage
// Subscribe to system events via storage
api.query.system.events((events) => {
console.log(`\nReceived ${events.length} events:`);
// loop through the Vec<EventRecord>
// Loop through the Vec<EventRecord>
events.forEach((record) => {
// extract the phase, event and the event types
// Extract the phase, event and the event types
const { event, phase } = record;
const types = event.typeDef;
// show what we are busy with
// Show what we are busy with
console.log(`\t${event.section}:${event.method}:: (phase=${phase.toString()})`);
console.log(`\t\t${event.meta.documentation.toString()}`);
// loop through each of the parameters, displaying the type and data
// Loop through each of the parameters, displaying the type and data
event.data.forEach((data, index) => {
console.log(`\t\t\t${types[index].type}: ${data.toString()}`);
});
@@ -1,14 +1,16 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API & Provider and some utility functions
const { ApiPromise } = require('@polkadot/api');
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
const testKeyring = require('@polkadot/keyring/testing');
// utility function for random values
// Utility function for random values
const { randomAsU8a } = require('@polkadot/util-crypto');
// some constants we are using in this sample
// Some constants we are using in this sample
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
const AMOUNT = 10000;
@@ -16,18 +18,18 @@ async function main () {
// Create the API and wait until ready
const api = await ApiPromise.create();
// create an instance of our testing keyring
// Create an instance of our testing keyring
// If you're using ES6 module imports instead of require, just change this line to:
// const keyring = testKeyring();
const keyring = testKeyring.default();
// get the nonce for the admin key
const nonce = await api.query.system.accountNonce(ALICE);
// Get the nonce for the admin key
const { nonce } = await api.query.system.account(ALICE);
// find the actual keypair in the keyring
// Find the actual keypair in the keyring
const alicePair = keyring.getPair(ALICE);
// create a new random recipient
// Create a new random recipient
const recipient = keyring.addFromSeed(randomAsU8a(32)).address;
console.log('Sending', AMOUNT, 'from', alicePair.address, 'to', recipient, 'with nonce', nonce.toString());
@@ -35,17 +37,18 @@ async function main () {
// Do the transfer and track the actual status
api.tx.balances
.transfer(recipient, AMOUNT)
.sign(alicePair, { nonce })
.send(({ events = [], status }) => {
.signAndSend(alicePair, { nonce }, ({ events = [], status }) => {
console.log('Transaction status:', status.type);
if (status.isFinalized) {
console.log('Completed at block hash', status.asFinalized.toHex());
if (status.isInBlock) {
console.log('Included at block hash', status.asInBlock.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
});
} else if (status.isFinalized) {
console.log('Finalized block hash', status.asFinalized.toHex());
process.exit(0);
}
@@ -1,5 +1,5 @@
# Chain upgrade
Performs a chain upgrade using the `sudo` module. This may brick your chain, so us it as an educational sample. (use `substrate --dev purge-chain` to remove DB and recover).
Performs a chain upgrade using the `sudo` module. This may brick your chain, so use it as an educational sample. (use `substrate purge-chain --dev` to remove DB and recover).
<<< @/docs/examples/promise/10_upgrade_chain/index.js
+14 -10
View File
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API & Provider and some utility functions
const { ApiPromise, WsProvider } = require('@polkadot/api');
@@ -14,36 +16,38 @@ async function main () {
// Create the API and wait until ready (optional provider passed through)
const api = await ApiPromise.create({ provider });
// retrieve the upgrade key from the chain state
// Retrieve the upgrade key from the chain state
const adminId = await api.query.sudo.key();
// find the actual keypair in the keyring (if this is an changed value, the key
// Find the actual keypair in the keyring (if this is a changed value, the key
// needs to be added to the keyring before - this assumes we have defaults, i.e.
// Alice as the key - and this already exists on the test keyring)
const keyring = testKeyring.default();
const adminPair = keyring.getPair(adminId.toString());
// retrieve the runtime to upgrade to
// Retrieve the runtime to upgrade
const code = fs.readFileSync('./test.wasm').toString('hex');
const proposal = api.tx.consensus.setCode(`0x${code}`);
const proposal = api.tx.system && api.tx.system.setCode
? api.tx.system.setCode(`0x${code}`) // For newer versions of Substrate
: api.tx.consensus.setCode(`0x${code}`); // For previous versions
console.log(`Upgrading from ${adminId}, ${code.length / 2} bytes`);
// preform the actual chain upgrade via the sudo module
// Perform the actual chain upgrade via the sudo module
api.tx.sudo
.sudo(proposal)
.signAndSend(adminPair, ({ events = [], status }) => {
console.log('Proposal status:', status.type);
if (status.isFinalized) {
if (status.isInBlock) {
console.error('You have just upgraded your chain');
console.log('Completed at block hash', status.asFinalized.toHex());
console.log('Included at block hash', status.asInBlock.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
});
console.log(JSON.stringify(events.toHuman(), null, 2));
} else if (status.isFinalized) {
console.log('Finalized block hash', status.asFinalized.toHex());
process.exit(0);
}
+248
View File
@@ -0,0 +1,248 @@
# typegen
This is a sample TypeScript project [with full source & config on GithHub](https://github.com/polkadot-js/api/tree/master/docs/examples/promise/90_typegen), that uses `@polkadot/typegen` to generate type definitions that can be used to decorate the `@polkadot/api`. It uses both types defined for the specific chain as well as the chain metadata to generate TypeScript interfaces. This means that interfaces such as `api.query.*`, `api.tx.*` and `api.consts.*` will be decorated based on chain-specific information, instead of an un-augmented catch-all definition.
**NOTE** This is built using the updates in the `1.4.0` api track and as such it uses the latest (at the time of writing) `@polkadot/api 1.4.0`. If you want to play on your own, it is also suggested that you use the `1.4+` series since some generation types have moved around internally, making it easier to augment.
## Packages
For the packages we need from the `@polkadot/*` we have added `@polkadot/api` (we want to do API stuff) and `@polkadot/typegen` (to generate the actual interfaces). So our scripts and dependencies inside `package.json` contain the following -
```json
{
"scripts": {
"build": "yarn generate:defs && yarn generate:meta",
"generate:defs": "ts-node --skip-project node_modules/.bin/polkadot-types-from-defs --package sample-polkadotjs-typegen/interfaces --input ./src/interfaces",
"generate:meta": "ts-node --skip-project node_modules/.bin/polkadot-types-from-chain --package sample-polkadotjs-typegen/interfaces --endpoint ./edgeware.json --output ./src/interfaces",
"lint": "tsc --noEmit --pretty"
},
"dependencies": {
"@polkadot/api": "^1.4.0"
},
"devDependencies": {
"@polkadot/typegen": "^1.4.0",
"ts-node": "^8.6.2",
"typescript": "^3.8.2"
}
}
```
We will delve into the setup and running the scripts and what they do in a short bit, but as of now just notice that we are running the scripts via `ts-node`. Since we supply our definitions as `*.ts` files, this is important otherwise they will not be parsable. `build` will just run both the types and meta generators (in that order, so metadata can use the types) and we have a `lint` that can just check that everything is as it is meant to be.
## Metadata setup
The idea here is to use the actual chain metadata to generate the actual api augmented endpoints. The metadata we are adding here (in addition to the user types), is from the Edgeware Berlin testnet. So this is a real-world example of configuring the API for a specific substrate chain. For the metadata retrieval, we just ran a simple curl command to get it from the node -
`curl -H "Content-Type: application/json" -d '{"id":"1", "jsonrpc":"2.0", "method": "state_getMetadata", "params":[]}' http://localhost:9933`
And then add the full JSONPC output as received to the `edgeware.json` file as specified by the generation command. A trimmed version would look like -
```json
{"jsonrpc":"2.0","result":"0x6d6574610b6c185379737....","id":29}
```
The generator can also use a `wss://` as an `--endpoint` param as part of the generation, but in most cases you would want a static metadata to work from in development, hence we are actually adding it here.
## Types setup
The types are defined in the `src/interfaces` folder. While this repo contains a number of generated files in there as well, you basically only need to manually add the following -
- `src/interfaces/definitions.ts` - this just exports all the sub-folder definitions in one go
- `src/interfaces/<module>/definitions.ts` - type definitions for a specific module
This structure fully matches what is available in the `@polkadot/type/interfaces` folder, so the structure is setup based on the convention used in the `@polkadot/types` library. The generating scripts will expect something matching this since the same underlying code is actually used inside `@polkadot/types` as well. The top-level `interfaces/` folder can be name anything, however the internal content structure need to match what is defined above.
For the top-level the definition file has the following contents -
```js
export { default as signaling } from './signaling/definitions';
export { default as treasuryRewards } from './treasuryRewards/definitions';
export { default as voting } from './voting/definitions';
```
As explained above, it really is just a re-export of the definitions, so they are all easily accessible to the outside, i.e. we will use this import inside our own code to use the definitions in API initialization. The generation scripts will load this file to determine which types it needs to import. By the `@polkadot/types` convention, match the export names with the folders (preferably your runtime module names), the generation scripts will use these names to find the correct folders to output the generated `types.ts` to.
For each of the folders, `signaling`, `treasuryRewards` and `voting` another `definitions.ts` file is contained within. Looking at the one from `signaling`, it contains this -
```js
export default {
types: {
ProposalRecord: {
index: 'u32',
author: 'AccountId',
stage: 'VoteStage',
transition_time: 'u32',
title: 'Text',
contents: 'Text',
vote_id: 'u64'
},
ProposalContents: 'Vec<u8>',
ProposalTitle: 'Vec<u8>'
}
}
```
Just the type definitions (the structure of which you should be familiar with), nested inside a `types: {...}` container. This allows us future extension points, i.e. there is some work to expose the custom RPC types alongside, so that would become another key on a per-module basis.
In the above, you will note that the `ProposalRecord` references a type for `voting`, i.e. `VoteStage`. The type generation and resolution will determine where the type comes from, and provide the required imports on generation.
Looking at the example in this repo, it also has `augment*`, `index.ts` and `types.ts` files in the interfaces folder. These are all generated, and will be re-generated when the generator is run - so all edits to these files will be lost. The only requirement for user-edits are the `definitions.ts` files.
## Generating
Now that both the metadata nd types setup is completed, we just run the build command via `yarn build` and magically (assuming you didn't have the `augment*` and other generated files), these files will be added. When running this command, the console should display something like -
```
> yarn build
$ yarn generate:defs && yarn generate:meta
$ ts-node --skip-project \
node_modules/.bin/polkadot-types-from-defs \
--package sample-polkadotjs-typegen/interfaces \
--input ./src/interfaces
sample-polkadotjs-typegen/src/interfaces/types.ts
Generating
Extracting interfaces for signaling
...
Writing
sample-polkadotjs-typegen/src/interfaces/augment-types.ts
Generating
Writing
$ ts-node --skip-project \
node_modules/.bin/polkadot-types-from-chain \
--package sample-polkadotjs-typegen/interfaces \
--endpoint ./edgeware.json \
--output ./src/interfaces
Generating from metadata, 81,267 bytes
...
sample-polkadotjs-typegen/src/interfaces/augment-api.ts
Generating
Writing
✨ Done in 4.04s.
```
Now if we check the actual output against the source via `yarn lint`, we would see that valid output has been generated -
```
> yarn lint
$ tsc --noEmit --pretty
✨ Done in 2.28s.
```
## Peering at the output
We are ready to use all these generated types this after some TS config. If you take a look at the generated `src/signaling/types.ts`, you would see generated TS interfaces, such as -
```js
import { Struct } from '@polkadot/types/codec';
import { Bytes, Text, u32, u64 } from '@polkadot/types/primitive';
import { AccountId } from '@polkadot/types/interfaces/runtime';
import { VoteStage } from 'sample-polkadotjs-typegen/interfaces/voting';
/** @name ProposalContents */
export interface ProposalContents extends Bytes {}
/** @name ProposalRecord */
export interface ProposalRecord extends Struct {
readonly index: u32;
readonly author: AccountId;
readonly stage: VoteStage;
readonly transition_time: u32;
readonly title: Text;
readonly contents: Text;
readonly vote_id: u64;
}
/** @name ProposalTitle */
export interface ProposalTitle extends Bytes {}
```
As mentioned earlier, here you will notice the `import { VoteStage }`, the generator has determined that `voting` exports that interface and has added the required imports.
## TypeScript config
Now that we have files generated, it is time to make TypeScript aware of the types and add an explicit override into out `tsconfig.json`. After some changes, the paths in the config looks as follow (comments are in teh actual config file here) -
```json
{
"compilerOptions": {
"paths": {
"sample-polkadotjs-typegen/*": ["src/*"],
"@polkadot/api/augment": ["src/interfaces/augment-api.ts"],
"@polkadot/types/augment": ["src/interfaces/augment-types.ts"]
}
}
}
```
Effectively what we do above is tell the TypeScript compiler to not use the built-in API augmentation, but rather to replace it with our version. This means that all types from these are injected not by the substrate-latest-master version, but rather with what we have defined above.
## Usage
For simple usage, we have added the `src/index.ts` file that show how the metadata and types actually decorate the API. In addition, we also have setup instructions included here.
```js
// We need to import the augmented definitions "somewhere" in our project, however since we have
// it in tsconfig as an override and the api/types has imports, it is not strictly required here.
// Because of the tsconfig override, we could import from '@polkadot/{api, types}/augment'
import './interfaces/augment-api';
import './interfaces/augment-types';
// all type stuff, the only one we are using here
import type { VoteRecord } from './interfaces';
// external imports
import { ApiPromise } from '@polkadot/api';
import { createType } from '@polkadot/types';
// our local stuff
import * as definitions from './interfaces/definitions';
async function main (): Promise<void> {
// extract all types from definitions - fast and dirty approach, flatted on 'types'
const types = Object.values(definitions).reduce((res, { types }): object => ({ ...res, ...types }), {});
const api = await ApiPromise.create({
types: {
...types,
// aliases that don't do well as part of interfaces
'voting::VoteType': 'VoteType',
'voting::TallyType': 'TallyType',
// chain-specific overrides
Keys: 'SessionKeys4'
}
});
// get a query
const recordOpt = await api.query.voting.voteRecords(123);
// the types match with what we expect here
let firstRecord: VoteRecord | null = recordOpt.unwrapOr(null);
console.log(firstRecord?.toHuman());
// it even does work for arrays & subscriptions
api.query.signaling.activeProposals((results): void => {
results.forEach(([hash, blockNumber]): void => {
console.log(hash.toHex(), ':', blockNumber.toNumber());
});
});
// even createType works, allowing for our types to be used
console.log(`Balance2 bitLength:`, [
api.createType('Balance2').bitLength(),
api.registry.createType('Balance2').bitLength(),
createType(api.registry, 'Balance2').bitLength()
]);
}
await main();
```
## And that is a ...
... wrap. Just a really simple walk-through to customizing the API TypeScript definitions for your chain.
File diff suppressed because one or more lines are too long
@@ -0,0 +1,24 @@
{
"name": "sample-polkadotjs-typegen",
"version": "0.0.1",
"description": "A sample using @polkadot/typegen to generate type definitions",
"main": "index.js",
"repository": "https://github.com/jacogr/sample-polkadotjs-typegen",
"author": "Jaco Greeff <jacogr@gmail.com>",
"license": "The Unlicense",
"private": true,
"scripts": {
"build": "yarn generate:defs && yarn generate:meta",
"generate:defs": "ts-node --skip-project node_modules/.bin/polkadot-types-from-defs --package sample-polkadotjs-typegen/interfaces --input ./src/interfaces",
"generate:meta": "ts-node --skip-project node_modules/.bin/polkadot-types-from-chain --package sample-polkadotjs-typegen/interfaces --endpoint ./edgeware.json --output ./src/interfaces --strict",
"lint": "tsc --noEmit --pretty"
},
"dependencies": {
"@polkadot/api": "^1.4.0"
},
"devDependencies": {
"@polkadot/typegen": "^1.4.0",
"ts-node": "^8.6.2",
"typescript": "^3.8.2"
}
}
@@ -0,0 +1,54 @@
// We need to import the augmented definitions "somewhere" in our project, however since we have
// it in tsconfig as an override and the api/types has imports, it is not strictly required here.
// Because of the tsconfig override, we could import from '@polkadot/{api, types}/augment'
import './interfaces/augment-api';
import './interfaces/augment-types';
// all type stuff, the only one we are using here
import type { VoteRecord } from './interfaces';
// external imports
import { ApiPromise } from '@polkadot/api';
import { createType } from '@polkadot/types';
// our local stuff
import * as definitions from './interfaces/definitions';
async function main (): Promise<void> {
// extract all types from definitions - fast and dirty approach, flatted on 'types'
const types = Object.values(definitions).reduce((res, { types }): object => ({ ...res, ...types }), {});
const api = await ApiPromise.create({
types: {
...types,
// aliasses that don't do well as part of interfaces
'voting::VoteType': 'VoteType',
'voting::TallyType': 'TallyType',
// chain-specific overrides
Keys: 'SessionKeys4'
}
});
// get a query
const recordOpt = await api.query.voting.voteRecords(123);
// the types match with what we expect here
let firstRecord: VoteRecord | null = recordOpt.unwrapOr(null);
console.log(firstRecord?.toHuman());
// it even does work for arrays & subscriptions
api.query.signaling.activeProposals((results): void => {
results.forEach(([hash, blockNumber]): void => {
console.log(hash.toHex(), ':', blockNumber.toNumber());
});
});
// even createType works, allowing for our types to be used
console.log(`Balance2 bitLength:`, [
api.createType('Balance2').bitLength(),
api.registry.createType('Balance2').bitLength(),
createType(api.registry, 'Balance2').bitLength()
]);
}
await main();
@@ -0,0 +1,253 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
import { Bytes, u32 } from '@polkadot/types/primitive';
import { Gas } from '@polkadot/types/interfaces/contracts';
import { Balance, BalanceOf, BlockNumber, Moment, Percent, Permill } from '@polkadot/types/interfaces/runtime';
import { SessionIndex } from '@polkadot/types/interfaces/session';
import { EraIndex } from '@polkadot/types/interfaces/staking';
declare module '@polkadot/metadata/Decorated/consts/types' {
export interface Constants {
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.
**/
minimumPeriod: AugmentedConst<Moment>;
};
balances: {
/**
* The minimum amount required to keep an account open.
**/
existentialDeposit: AugmentedConst<Balance>;
/**
* The fee required to make a transfer.
**/
transferFee: AugmentedConst<Balance>;
/**
* The fee required to create an account.
**/
creationFee: AugmentedConst<Balance>;
};
transactionPayment: {
/**
* The fee to be paid for making a transaction; the base.
**/
transactionBaseFee: AugmentedConst<BalanceOf>;
/**
* The fee to be paid for making a transaction; the per-byte portion.
**/
transactionByteFee: AugmentedConst<BalanceOf>;
};
staking: {
/**
* Number of sessions per era.
**/
sessionsPerEra: AugmentedConst<SessionIndex>;
/**
* Number of eras that staked funds must remain bonded for.
**/
bondingDuration: AugmentedConst<EraIndex>;
};
session: {
/**
* Used as first key for `NextKeys` and `KeyOwner` to put all the data into the same branch
* of the trie.
**/
dedupKeyPrefix: AugmentedConst<Bytes>;
};
democracy: {
/**
* The minimum period of locking and 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.
**/
enactmentPeriod: AugmentedConst<BlockNumber>;
/**
* How often (in blocks) new public referenda are launched.
**/
launchPeriod: AugmentedConst<BlockNumber>;
/**
* How often (in blocks) to check for new votes.
**/
votingPeriod: AugmentedConst<BlockNumber>;
/**
* The minimum amount to be used as a deposit for a public referendum proposal.
**/
minimumDeposit: AugmentedConst<BalanceOf>;
/**
* Minimum voting period allowed for an emergency referendum.
**/
emergencyVotingPeriod: AugmentedConst<BlockNumber>;
/**
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
**/
cooloffPeriod: AugmentedConst<BlockNumber>;
/**
* The amount of balance that must be deposited per byte of preimage stored.
**/
preimageByteDeposit: AugmentedConst<BalanceOf>;
};
elections: {
candidacyBond: AugmentedConst<BalanceOf>;
votingBond: AugmentedConst<BalanceOf>;
desiredMembers: AugmentedConst<u32>;
desiredRunnersUp: AugmentedConst<u32>;
termDuration: AugmentedConst<BlockNumber>;
};
finalityTracker: {
/**
* The number of recent samples to keep from this chain. Default is 101.
**/
windowSize: AugmentedConst<BlockNumber>;
/**
* The delay after which point things become suspicious. Default is 1000.
**/
reportLatency: AugmentedConst<BlockNumber>;
};
treasury: {
/**
* 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.
**/
proposalBond: AugmentedConst<Permill>;
/**
* Minimum amount of funds that should be placed in a deposit for making a proposal.
**/
proposalBondMinimum: AugmentedConst<BalanceOf>;
/**
* Period between successive spends.
**/
spendPeriod: AugmentedConst<BlockNumber>;
/**
* Percentage of spare funds (if any) that are burnt per spend period.
**/
burn: AugmentedConst<Permill>;
/**
* The period for which a tip remains open after is has achieved threshold tippers.
**/
tipCountdown: AugmentedConst<BlockNumber>;
/**
* The amount of the final tip which goes to the original reporter of the tip.
**/
tipFindersFee: AugmentedConst<Percent>;
/**
* The amount held on deposit for placing a tip report.
**/
tipReportDepositBase: AugmentedConst<BalanceOf>;
/**
* The amount held on deposit per byte within the tip report reason.
**/
tipReportDepositPerByte: AugmentedConst<BalanceOf>;
};
contracts: {
/**
* 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: AugmentedConst<BlockNumber>;
/**
* The minimum amount required to generate a tombstone.
**/
tombstoneDeposit: AugmentedConst<BalanceOf>;
/**
* Size of a contract at the time of instantiaion. This is a simple way to ensure that
* empty contracts eventually gets deleted.
**/
storageSizeOffset: AugmentedConst<u32>;
/**
* Price of a byte of storage per one block interval. Should be greater than 0.
**/
rentByteFee: AugmentedConst<BalanceOf>;
/**
* The amount of funds a contract should deposit in order to offset
* the cost of one byte.
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
* 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.
**/
rentDepositOffset: AugmentedConst<BalanceOf>;
/**
* Reward that is received by the party whose touch has led
* to removal of a contract.
**/
surchargeReward: AugmentedConst<BalanceOf>;
/**
* The fee required to make a transfer.
**/
transferFee: AugmentedConst<BalanceOf>;
/**
* The fee required to create an account.
**/
creationFee: AugmentedConst<BalanceOf>;
/**
* The fee to be paid for making a transaction; the base.
**/
transactionBaseFee: AugmentedConst<BalanceOf>;
/**
* The fee to be paid for making a transaction; the per-byte portion.
**/
transactionByteFee: AugmentedConst<BalanceOf>;
/**
* The fee required to instantiate a contract instance. A reasonable default value
* is 21.
**/
contractFee: AugmentedConst<BalanceOf>;
/**
* The base fee charged for calling into a contract. A reasonable default
* value is 135.
**/
callBaseFee: AugmentedConst<Gas>;
/**
* The base fee charged for instantiating a contract. A reasonable default value
* is 175.
**/
instantiateBaseFee: AugmentedConst<Gas>;
/**
* The maximum nesting level of a call/instantiate stack. A reasonable default
* value is 100.
**/
maxDepth: AugmentedConst<u32>;
/**
* The maximum size of a storage value in bytes. A reasonable default is 16 KiB.
**/
maxValueSize: AugmentedConst<u32>;
/**
* The maximum amount of gas that could be expended per block. A reasonable
* default value is 10_000_000.
**/
blockGasLimit: AugmentedConst<Gas>;
};
nicks: {
/**
* Reservation fee.
**/
reservationFee: AugmentedConst<BalanceOf>;
/**
* The minimum length a name may be.
**/
minLength: AugmentedConst<u32>;
/**
* The maximum length a name may be.
**/
maxLength: AugmentedConst<u32>;
};
}
}
@@ -0,0 +1,706 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
import { AnyNumber, ITuple } from '@polkadot/types/types';
import { Option, U8aFixed, Vec } from '@polkadot/types/codec';
import { Bytes, Data, bool, u32, u64 } from '@polkadot/types/primitive';
import { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
import { BalanceLock, VestingSchedule } from '@polkadot/types/interfaces/balances';
import { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
import { AuthorityId } from '@polkadot/types/interfaces/consensus';
import { CodeHash, ContractInfo, Gas, PrefabWasmModule, Schedule } from '@polkadot/types/interfaces/contracts';
import { Conviction, PropIndex, Proposal, ReferendumIndex, ReferendumInfo } from '@polkadot/types/interfaces/democracy';
import { Vote, VoteThreshold } from '@polkadot/types/interfaces/elections';
import { AuthorityList, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
import { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
import { AuthIndex } from '@polkadot/types/interfaces/imOnline';
import { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, Hash, Index, KeyTypeId, Moment, Perbill, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime';
import { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
import { ProposalRecord } from 'sample-polkadotjs-typegen/interfaces/signaling';
import { EraIndex, EraPoints, Exposure, Forcing, MomentOf, Nominations, RewardDestination, SlashingSpans, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
import { DigestOf, EventIndex, EventRecord } from '@polkadot/types/interfaces/system';
import { OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
import { Multisig } from '@polkadot/types/interfaces/utility';
import { VoteRecord } from 'sample-polkadotjs-typegen/interfaces/voting';
import { Observable } from 'rxjs';
import { ApiTypes } from '@polkadot/api/types';
declare module '@polkadot/api/types/storage' {
export interface AugmentedQueries<ApiType> {
system: {
/**
* Extrinsics nonce for accounts.
**/
accountNonce: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Index>>;
/**
* Total extrinsics count for the current block.
**/
extrinsicCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>>;
/**
* Total weight for all extrinsics put together, for the current block.
**/
allExtrinsicsWeight: AugmentedQuery<ApiType, () => Observable<Option<Weight>>>;
/**
* Total length (in bytes) for all extrinsics put together, for the current block.
**/
allExtrinsicsLen: AugmentedQuery<ApiType, () => Observable<Option<u32>>>;
/**
* Map of block numbers to block hashes.
**/
blockHash: AugmentedQuery<ApiType, (arg: BlockNumber | AnyNumber | Uint8Array) => Observable<Hash>>;
/**
* Extrinsics data for the current block (maps an extrinsic's index to its data).
**/
extrinsicData: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Bytes>>;
/**
* The current block number being processed. Set by `execute_block`.
**/
number: AugmentedQuery<ApiType, () => Observable<BlockNumber>>;
/**
* Hash of the previous block.
**/
parentHash: AugmentedQuery<ApiType, () => Observable<Hash>>;
/**
* Extrinsics root of the current block, also part of the block header.
**/
extrinsicsRoot: AugmentedQuery<ApiType, () => Observable<Hash>>;
/**
* Digest of the current block, also part of the block header.
**/
digest: AugmentedQuery<ApiType, () => Observable<DigestOf>>;
/**
* Events deposited for the current block.
**/
events: AugmentedQuery<ApiType, () => Observable<Vec<EventRecord>>>;
/**
* The number of events in the `Events<T>` list.
**/
eventCount: AugmentedQuery<ApiType, () => Observable<EventIndex>>;
/**
* Mapping between a topic (represented by T::Hash) and a vector of indexes
* of events in the `<Events<T>>` list.
* All topic vectors have deterministic storage locations depending on the topic. This
* allows light-clients to leverage the changes trie storage tracking mechanism and
* in case of changes fetch the list of events of interest.
* The value has the type `(T::BlockNumber, EventIndex)` because if we used only just
* the `EventIndex` then in case if the topic has the same contents on the next block
* no notification will be triggered thus the event might be lost.
**/
eventTopics: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Vec<ITuple<[BlockNumber, EventIndex]>>>>;
};
utility: {
/**
* The set of open multisig operations.
**/
multisigs: AugmentedQueryDoubleMap<ApiType, (key1: AccountId | string | Uint8Array, key2: U8aFixed | string | Uint8Array) => Observable<Option<Multisig>>>;
};
timestamp: {
/**
* Current time for the current block.
**/
now: AugmentedQuery<ApiType, () => Observable<Moment>>;
/**
* Did the timestamp get updated in this block?
**/
didUpdate: AugmentedQuery<ApiType, () => Observable<bool>>;
};
authorship: {
/**
* Uncles
**/
uncles: AugmentedQuery<ApiType, () => Observable<Vec<UncleEntryItem>>>;
/**
* Author of current block.
**/
author: AugmentedQuery<ApiType, () => Observable<Option<AccountId>>>;
/**
* Whether uncles were already set in this block.
**/
didSetUncles: AugmentedQuery<ApiType, () => Observable<bool>>;
};
indices: {
/**
* The next free enumeration set.
**/
nextEnumSet: AugmentedQuery<ApiType, () => Observable<AccountIndex>>;
/**
* The enumeration sets.
**/
enumSet: AugmentedQuery<ApiType, (arg: AccountIndex | AnyNumber | Uint8Array) => Observable<Vec<AccountId>>>;
};
balances: {
/**
* The total units issued in the system.
**/
totalIssuance: AugmentedQuery<ApiType, () => Observable<Balance>>;
/**
* Information regarding the vesting of a given account.
**/
vesting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VestingSchedule>>>;
/**
* The 'free' balance of a given account.
* This is the only balance that matters in terms of most operations on tokens. It
* alone is used to determine the balance when in the contract execution environment. When this
* balance falls below the value of `ExistentialDeposit`, then the 'current account' is
* deleted: specifically `FreeBalance`. Further, the `OnFreeBalanceZero` callback
* is invoked, giving a chance to external modules to clean up data associated with
* the deleted account.
* `frame_system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets
* collapsed to zero if it ever becomes less than `ExistentialDeposit`.
**/
freeBalance: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Balance>>;
/**
* The amount of the balance of a given account that is externally reserved; this can still get
* slashed, but gets slashed last of all.
* This balance is a 'reserve' balance that other subsystems use in order to set aside tokens
* that are still 'owned' by the account holder, but which are suspendable.
* When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account'
* is deleted: specifically, `ReservedBalance`.
* `frame_system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets
* collapsed to zero if it ever becomes less than `ExistentialDeposit`.)
**/
reservedBalance: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Balance>>;
/**
* Any liquidity locks on some account balances.
**/
locks: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<BalanceLock>>>;
};
transactionPayment: {
nextFeeMultiplier: AugmentedQuery<ApiType, () => Observable<Multiplier>>;
};
staking: {
/**
* The ideal number of staking participants.
**/
validatorCount: AugmentedQuery<ApiType, () => Observable<u32>>;
/**
* Minimum number of staking participants before emergency conditions are imposed.
**/
minimumValidatorCount: AugmentedQuery<ApiType, () => Observable<u32>>;
/**
* Any validators that may never be slashed or forcibly kicked. It's a Vec since they're
* easy to initialize and the performance hit is minimal (we expect no more than four
* invulnerables) and restricted to testnets.
**/
invulnerables: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>>;
/**
* Map from all locked "stash" accounts to the controller account.
**/
bonded: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<AccountId>>>;
/**
* Map from all (unlocked) "controller" accounts to the info regarding the staking.
**/
ledger: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<StakingLedger>>>;
/**
* Where the reward payment should be made. Keyed by stash.
**/
payee: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<RewardDestination>>;
/**
* The map from (wannabe) validator stash key to the preferences of that validator.
**/
validators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>>;
/**
* The map from nominator stash key to the set of stash keys of all validators to nominate.
* NOTE: is private so that we can ensure upgraded before all typical accesses.
* Direct storage APIs can still bypass this protection.
**/
nominators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Nominations>>>;
/**
* Nominators for a particular account that is in action right now. You can't iterate
* through validators here, but you can find them in the Session module.
* This is keyed by the stash account.
**/
stakers: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Exposure>>;
/**
* The currently elected validator set keyed by stash account ID.
**/
currentElected: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>>;
/**
* The current era index.
**/
currentEra: AugmentedQuery<ApiType, () => Observable<EraIndex>>;
/**
* The start of the current era.
**/
currentEraStart: AugmentedQuery<ApiType, () => Observable<MomentOf>>;
/**
* The session index at which the current era started.
**/
currentEraStartSessionIndex: AugmentedQuery<ApiType, () => Observable<SessionIndex>>;
/**
* Rewards for the current era. Using indices of current elected set.
**/
currentEraPointsEarned: AugmentedQuery<ApiType, () => Observable<EraPoints>>;
/**
* The amount of balance actively at stake for each validator slot, currently.
* This is used to derive rewards and punishments.
**/
slotStake: AugmentedQuery<ApiType, () => Observable<BalanceOf>>;
/**
* True if the next session change will be a new era regardless of index.
**/
forceEra: AugmentedQuery<ApiType, () => Observable<Forcing>>;
/**
* The percentage of the slash that is distributed to reporters.
* The rest of the slashed value is handled by the `Slash`.
**/
slashRewardFraction: AugmentedQuery<ApiType, () => Observable<Perbill>>;
/**
* The amount of currency given to reporters of a slash event which was
* canceled by extraordinary circumstances (e.g. governance).
**/
canceledSlashPayout: AugmentedQuery<ApiType, () => Observable<BalanceOf>>;
/**
* All unapplied slashes that are queued for later.
**/
unappliedSlashes: AugmentedQuery<ApiType, (arg: EraIndex | AnyNumber | Uint8Array) => Observable<Vec<UnappliedSlash>>>;
/**
* A mapping from still-bonded eras to the first session index of that era.
**/
bondedEras: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[EraIndex, SessionIndex]>>>>;
/**
* All slashing events on validators, mapped by era to the highest slash proportion
* and slash value of the era.
**/
validatorSlashInEra: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<ITuple<[Perbill, BalanceOf]>>>>;
/**
* All slashing events on nominators, mapped by era to the highest slash value of the era.
**/
nominatorSlashInEra: AugmentedQueryDoubleMap<ApiType, (key1: EraIndex | AnyNumber | Uint8Array, key2: AccountId | string | Uint8Array) => Observable<Option<BalanceOf>>>;
/**
* Slashing spans for stash accounts.
**/
slashingSpans: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<SlashingSpans>>>;
/**
* Records information about the maximum slash of a stash within a slashing span,
* as well as how much reward has been paid out.
**/
spanSlash: AugmentedQuery<ApiType, (arg: ITuple<[AccountId, SpanIndex]> | [AccountId | string | Uint8Array, SpanIndex | AnyNumber | Uint8Array]) => Observable<SpanRecord>>;
/**
* The earliest era for which we have a pending, unapplied slash.
**/
earliestUnappliedSlash: AugmentedQuery<ApiType, () => Observable<Option<EraIndex>>>;
/**
* The version of storage for upgrade.
**/
storageVersion: AugmentedQuery<ApiType, () => Observable<u32>>;
};
session: {
/**
* The current set of validators.
**/
validators: AugmentedQuery<ApiType, () => Observable<Vec<ValidatorId>>>;
/**
* Current index of the session.
**/
currentIndex: AugmentedQuery<ApiType, () => Observable<SessionIndex>>;
/**
* True if the underlying economic identities or weighting behind the validators
* has changed in the queued validator set.
**/
queuedChanged: AugmentedQuery<ApiType, () => Observable<bool>>;
/**
* The queued keys for the next session. When the next session begins, these keys
* will be used to determine the validator's session keys.
**/
queuedKeys: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[ValidatorId, Keys]>>>>;
/**
* Indices of disabled validators.
* The set is cleared when `on_session_ending` returns a new set of identities.
**/
disabledValidators: AugmentedQuery<ApiType, () => Observable<Vec<u32>>>;
/**
* The next session keys for a validator.
* The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of
* the trie. Having all data in the same branch should prevent slowing down other queries.
**/
nextKeys: AugmentedQueryDoubleMap<ApiType, (key1: Bytes | string | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<Option<Keys>>>;
/**
* The owner of a key. The second key is the `KeyTypeId` + the encoded key.
* The first key is always `DEDUP_KEY_PREFIX` to have all the data in the same branch of
* the trie. Having all data in the same branch should prevent slowing down other queries.
**/
keyOwner: AugmentedQueryDoubleMap<ApiType, (key1: Bytes | string | Uint8Array, key2: ITuple<[KeyTypeId, Bytes]> | [KeyTypeId | AnyNumber | Uint8Array, Bytes | string | Uint8Array]) => Observable<Option<ValidatorId>>>;
};
democracy: {
/**
* The number of (public) proposals that have been made so far.
**/
publicPropCount: AugmentedQuery<ApiType, () => Observable<PropIndex>>;
/**
* The public proposals. Unsorted. The second item is the proposal's hash.
**/
publicProps: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[PropIndex, Hash, AccountId]>>>>;
/**
* Map of hashes to the proposal preimage, along with who registered it and their deposit.
* The block number is the block at which it was deposited.
**/
preimages: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<ITuple<[Bytes, AccountId, BalanceOf, BlockNumber]>>>>;
/**
* Those who have locked a deposit.
**/
depositOf: AugmentedQuery<ApiType, (arg: PropIndex | AnyNumber | Uint8Array) => Observable<Option<ITuple<[BalanceOf, Vec<AccountId>]>>>>;
/**
* The next free referendum index, aka the number of referenda started so far.
**/
referendumCount: AugmentedQuery<ApiType, () => Observable<ReferendumIndex>>;
/**
* The lowest referendum index representing an unbaked referendum. Equal to
* `ReferendumCount` if there isn't a unbaked referendum.
**/
lowestUnbaked: AugmentedQuery<ApiType, () => Observable<ReferendumIndex>>;
/**
* Information concerning any given referendum.
**/
referendumInfoOf: AugmentedQuery<ApiType, (arg: ReferendumIndex | AnyNumber | Uint8Array) => Observable<Option<ReferendumInfo>>>;
/**
* Queue of successful referenda to be dispatched. Stored ordered by block number.
**/
dispatchQueue: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[BlockNumber, Hash, ReferendumIndex]>>>>;
/**
* Get the voters for the current proposal.
**/
votersFor: AugmentedQuery<ApiType, (arg: ReferendumIndex | AnyNumber | Uint8Array) => Observable<Vec<AccountId>>>;
/**
* Get the vote in a given referendum of a particular voter. The result is meaningful only
* if `voters_for` includes the voter when called with the referendum (you'll get the
* default `Vote` value otherwise). If you don't want to check `voters_for`, then you can
* also check for simple existence with `VoteOf::exists` first.
**/
voteOf: AugmentedQuery<ApiType, (arg: ITuple<[ReferendumIndex, AccountId]> | [ReferendumIndex | AnyNumber | Uint8Array, AccountId | string | Uint8Array]) => Observable<Vote>>;
/**
* Who is able to vote for whom. Value is the fund-holding account, key is the
* vote-transaction-sending account.
**/
proxy: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<AccountId>>>;
/**
* Get the account (and lock periods) to which another account is delegating vote.
**/
delegations: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[AccountId, Conviction]>>>;
/**
* True if the last referendum tabled was submitted externally. False if it was a public
* proposal.
**/
lastTabledWasExternal: AugmentedQuery<ApiType, () => Observable<bool>>;
/**
* The referendum to be tabled whenever it would be valid to table an external proposal.
* This happens when a referendum needs to be tabled and one of two conditions are met:
* - `LastTabledWasExternal` is `false`; or
* - `PublicProps` is empty.
**/
nextExternal: AugmentedQuery<ApiType, () => Observable<Option<ITuple<[Hash, VoteThreshold]>>>>;
/**
* A record of who vetoed what. Maps proposal hash to a possible existent block number
* (until when it may not be resubmitted) and who vetoed it.
**/
blacklist: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<ITuple<[BlockNumber, Vec<AccountId>]>>>>;
/**
* Record of all proposals that have been subject to emergency cancellation.
**/
cancellations: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<bool>>;
};
council: {
/**
* The hashes of the active proposals.
**/
proposals: AugmentedQuery<ApiType, () => Observable<Vec<Hash>>>;
/**
* Actual proposal for a given hash, if it's current.
**/
proposalOf: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Proposal>>>;
/**
* Votes on a given proposal, if it is ongoing.
**/
voting: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Votes>>>;
/**
* Proposals so far.
**/
proposalCount: AugmentedQuery<ApiType, () => Observable<u32>>;
/**
* The current members of the collective. This is stored sorted (just by value).
**/
members: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>>;
};
elections: {
/**
* The current elected membership. Sorted based on account id.
**/
members: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>>;
/**
* The current runners_up. Sorted based on low to high merit (worse to best runner).
**/
runnersUp: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId, BalanceOf]>>>>;
/**
* The total number of vote rounds that have happened, excluding the upcoming one.
**/
electionRounds: AugmentedQuery<ApiType, () => Observable<u32>>;
/**
* Votes of a particular voter, with the round index of the votes.
**/
votesOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<AccountId>>>;
/**
* Locked stake of a voter.
**/
stakeOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<BalanceOf>>;
/**
* The present candidate list. Sorted based on account-id. A current member or a runner can
* never enter this vector and is always implicitly assumed to be a candidate.
**/
candidates: AugmentedQuery<ApiType, () => Observable<Vec<AccountId>>>;
};
grandpa: {
/**
* DEPRECATED
* This used to store the current authority set, which has been migrated to the well-known
* GRANDPA_AUTHORITES_KEY unhashed key.
**/
authorities: AugmentedQuery<ApiType, () => Observable<AuthorityList>>;
/**
* State of the current authority set.
**/
state: AugmentedQuery<ApiType, () => Observable<StoredState>>;
/**
* Pending change: (signaled at, scheduled change).
**/
pendingChange: AugmentedQuery<ApiType, () => Observable<Option<StoredPendingChange>>>;
/**
* next block number where we can force a change.
**/
nextForced: AugmentedQuery<ApiType, () => Observable<Option<BlockNumber>>>;
/**
* `true` if we are currently stalled.
**/
stalled: AugmentedQuery<ApiType, () => Observable<Option<ITuple<[BlockNumber, BlockNumber]>>>>;
/**
* The number of changes (both in terms of keys and underlying economic responsibilities)
* in the "set" of Grandpa validators from genesis.
**/
currentSetId: AugmentedQuery<ApiType, () => Observable<SetId>>;
/**
* A mapping from grandpa set ID to the index of the *most recent* session for which its members were responsible.
**/
setIdSession: AugmentedQuery<ApiType, (arg: SetId | AnyNumber | Uint8Array) => Observable<Option<SessionIndex>>>;
};
treasury: {
/**
* Number of proposals that have been made.
**/
proposalCount: AugmentedQuery<ApiType, () => Observable<ProposalIndex>>;
/**
* Proposals that have been made.
**/
proposals: AugmentedQuery<ApiType, (arg: ProposalIndex | AnyNumber | Uint8Array) => Observable<Option<TreasuryProposal>>>;
/**
* Proposal indices that have been approved but not yet awarded.
**/
approvals: AugmentedQuery<ApiType, () => Observable<Vec<ProposalIndex>>>;
/**
* Tips that are not yet completed. Keyed by the hash of `(reason, who)` from the value.
* This has the insecure enumerable hash function since the key itself is already
* guaranteed to be a secure hash.
**/
tips: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<OpenTip>>>;
/**
* Simple preimage lookup from the reason's hash to the original data. Again, has an
* insecure enumerable hash since the key is guaranteed to be the result of a secure hash.
**/
reasons: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<Bytes>>>;
};
contracts: {
/**
* Gas spent so far in this block.
**/
gasSpent: AugmentedQuery<ApiType, () => Observable<Gas>>;
/**
* Current cost schedule for contracts.
**/
currentSchedule: AugmentedQuery<ApiType, () => Observable<Schedule>>;
/**
* A mapping from an original code hash to the original code, untouched by instrumentation.
**/
pristineCode: AugmentedQuery<ApiType, (arg: CodeHash | string | Uint8Array) => Observable<Option<Bytes>>>;
/**
* A mapping between an original code hash and instrumented wasm code, ready for execution.
**/
codeStorage: AugmentedQuery<ApiType, (arg: CodeHash | string | Uint8Array) => Observable<Option<PrefabWasmModule>>>;
/**
* The subtrie counter.
**/
accountCounter: AugmentedQuery<ApiType, () => Observable<u64>>;
/**
* The code associated with a given account.
**/
contractInfoOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ContractInfo>>>;
/**
* The price of one unit of gas.
**/
gasPrice: AugmentedQuery<ApiType, () => Observable<BalanceOf>>;
};
identity: {
/**
* Information that is pertinent to identify the entity behind an account.
**/
identityOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Registration>>>;
/**
* The super-identity of an alternative "sub" identity together with its name, within that
* context. If the account is not some other account's sub-identity, then just `None`.
**/
superOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ITuple<[AccountId, Data]>>>>;
/**
* Alternative "sub" identities of this account.
* The first item is the deposit, the second is a vector of the accounts.
**/
subsOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ITuple<[BalanceOf, Vec<AccountId>]>>>;
/**
* The set of registrars. Not expected to get very big as can only be added through a
* special origin (likely a council motion).
* The index into this can be cast to `RegistrarIndex` to get a valid value.
**/
registrars: AugmentedQuery<ApiType, () => Observable<Vec<Option<RegistrarInfo>>>>;
};
imOnline: {
/**
* The block number after which it's ok to send heartbeats in current session.
* At the beginning of each session we set this to a value that should
* fall roughly in the middle of the session duration.
* The idea is to first wait for the validators to produce a block
* in the current session, so that the heartbeat later on will not be necessary.
**/
heartbeatAfter: AugmentedQuery<ApiType, () => Observable<BlockNumber>>;
/**
* The current set of keys that may issue a heartbeat.
**/
keys: AugmentedQuery<ApiType, () => Observable<Vec<AuthorityId>>>;
/**
* For each session index, we keep a mapping of `AuthIndex`
* to `offchain::OpaqueNetworkState`.
**/
receivedHeartbeats: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: AuthIndex | AnyNumber | Uint8Array) => Observable<Option<Bytes>>>;
/**
* For each session index, we keep a mapping of `T::ValidatorId` to the
* number of blocks authored by the given authority.
**/
authoredBlocks: AugmentedQueryDoubleMap<ApiType, (key1: SessionIndex | AnyNumber | Uint8Array, key2: ValidatorId | string | Uint8Array) => Observable<u32>>;
};
offences: {
/**
* The primary structure that holds all offence records keyed by report identifiers.
**/
reports: AugmentedQuery<ApiType, (arg: ReportIdOf | string | Uint8Array) => Observable<Option<OffenceDetails>>>;
/**
* A vector of reports of the same kind that happened at the same time slot.
**/
concurrentReportsIndex: AugmentedQueryDoubleMap<ApiType, (key1: Kind | string | Uint8Array, key2: OpaqueTimeSlot | string | Uint8Array) => Observable<Vec<ReportIdOf>>>;
/**
* Enumerates all reports of a kind along with the time they happened.
* All reports are sorted by the time of offence.
* Note that the actual type of this mapping is `Vec<u8>`, this is because values of
* different types are not supported at the moment so we are doing the manual serialization.
**/
reportsByKindIndex: AugmentedQuery<ApiType, (arg: Kind | string | Uint8Array) => Observable<Bytes>>;
};
randomnessCollectiveFlip: {
/**
* Series of block headers from the last 81 blocks that acts as random seed material. This
* is arranged as a ring buffer with `block_number % 81` being the index into the `Vec` of
* the oldest hash.
**/
randomMaterial: AugmentedQuery<ApiType, () => Observable<Vec<Hash>>>;
};
nicks: {
/**
* The lookup table for names.
**/
nameOf: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<ITuple<[Bytes, BalanceOf]>>>>;
};
sudo: {
/**
* The `AccountId` of the sudo key.
**/
key: AugmentedQuery<ApiType, () => Observable<AccountId>>;
};
signaling: {
/**
* The total number of proposals created thus far.
**/
proposalCount: AugmentedQuery<ApiType, () => Observable<u32>>;
/**
* A list of all extant proposals.
**/
inactiveProposals: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[Hash, BlockNumber]>>>>;
/**
* A list of active proposals along with the time at which they complete.
**/
activeProposals: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[Hash, BlockNumber]>>>>;
/**
* A list of completed proposals, pending deletion
**/
completedProposals: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[Hash, BlockNumber]>>>>;
/**
* Amount of time a proposal remains in "Voting" stage.
**/
votingLength: AugmentedQuery<ApiType, () => Observable<BlockNumber>>;
/**
* Map for retrieving the information about any proposal from its hash.
**/
proposalOf: AugmentedQuery<ApiType, (arg: Hash | string | Uint8Array) => Observable<Option<ProposalRecord>>>;
/**
* Registration bond
**/
proposalCreationBond: AugmentedQuery<ApiType, () => Observable<BalanceOf>>;
};
voting: {
/**
* The map of all vote records indexed by id
**/
voteRecords: AugmentedQuery<ApiType, (arg: u64 | AnyNumber | Uint8Array) => Observable<Option<VoteRecord>>>;
/**
* The number of vote records that have been created
**/
voteRecordCount: AugmentedQuery<ApiType, () => Observable<u64>>;
};
treasuryReward: {
/**
* Interval in number of blocks to reward treasury
**/
mintingInterval: AugmentedQuery<ApiType, () => Observable<BlockNumber>>;
/**
* Current payout of module
**/
currentPayout: AugmentedQuery<ApiType, () => Observable<BalanceOf>>;
/**
* Current pot
**/
pot: AugmentedQuery<ApiType, () => Observable<Balance>>;
};
}
export interface QueryableStorage<ApiType extends ApiTypes> extends AugmentedQueries<ApiType> {
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
import '@polkadot/api/augment/rpc';
import './augment-api-consts';
import './augment-api-query';
import './augment-api-tx';
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
// order here matches with what is found in (unused removed)
// https://www.npmjs.com/package/edgeware-node-types
// https://github.com/hicommonwealth/edgeware-node-types/tree/master/types
export { default as signaling } from './signaling/definitions';
export { default as treasuryRewards } from './treasuryRewards/definitions';
export { default as voting } from './voting/definitions';
@@ -1,4 +1,4 @@
// Auto-generated via `yarn build:interfaces`, do not edit
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
export * from './types';
@@ -0,0 +1,17 @@
/* eslint-disable @typescript-eslint/camelcase */
export default {
types: {
ProposalRecord: {
index: 'u32',
author: 'AccountId',
stage: 'VoteStage',
transition_time: 'u32',
title: 'Text',
contents: 'Text',
vote_id: 'u64'
},
ProposalContents: 'Vec<u8>',
ProposalTitle: 'Vec<u8>'
}
};
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
export * from './types';
@@ -0,0 +1,24 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
import { Struct } from '@polkadot/types/codec';
import { Bytes, Text, u32, u64 } from '@polkadot/types/primitive';
import { AccountId } from '@polkadot/types/interfaces/runtime';
import { VoteStage } from 'sample-polkadotjs-typegen/interfaces/voting';
/** @name ProposalContents */
export interface ProposalContents extends Bytes {}
/** @name ProposalRecord */
export interface ProposalRecord extends Struct {
readonly index: u32;
readonly author: AccountId;
readonly stage: VoteStage;
readonly transition_time: u32;
readonly title: Text;
readonly contents: Text;
readonly vote_id: u64;
}
/** @name ProposalTitle */
export interface ProposalTitle extends Bytes {}
@@ -0,0 +1,7 @@
/* eslint-disable @typescript-eslint/camelcase */
export default {
types: {
Balance2: 'u128'
}
};
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
export * from './types';
@@ -0,0 +1,7 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
import { u128 } from '@polkadot/types/primitive';
/** @name Balance2 */
export interface Balance2 extends u128 {}
@@ -0,0 +1,6 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
export * from './signaling/types';
export * from './treasuryRewards/types';
export * from './voting/types';
@@ -0,0 +1,33 @@
/* eslint-disable @typescript-eslint/camelcase */
export default {
types: {
VoteStage: {
_enum: ['PreVoting', 'Commit', 'Voting', 'Completed']
},
VoteType: {
_enum: ['Binary', 'MultiOption', 'RankedChoice']
},
TallyType: {
_enum: ['OnePerson', 'OneCoin']
},
VoteOutcome: '[u8; 32]',
Tally: 'Option<Vec<(VoteOutcome, u128)>>',
VoteData: {
initiator: 'AccountId',
stage: 'VoteStage',
vote_type: 'VoteType',
tally_type: 'TallyType',
is_commit_reveal: 'bool'
},
Commitments: 'Vec<(AccountId, VoteOutcome)>',
Reveals: 'Vec<(AccountId, Vec<VoteOutcome>)>',
VoteRecord: {
id: 'u64',
commitments: 'Commitments',
reveals: 'Reveals',
data: 'VoteData',
outcomes: 'Vec<VoteOutcome>'
}
}
};
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
export * from './types';
@@ -0,0 +1,58 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable @typescript-eslint/no-empty-interface */
import { ITuple } from '@polkadot/types/types';
import { Enum, Option, Struct, U8aFixed, Vec } from '@polkadot/types/codec';
import { bool, u128, u64 } from '@polkadot/types/primitive';
import { AccountId } from '@polkadot/types/interfaces/runtime';
/** @name Commitments */
export interface Commitments extends Vec<ITuple<[AccountId, VoteOutcome]>> {}
/** @name Reveals */
export interface Reveals extends Vec<ITuple<[AccountId, Vec<VoteOutcome>]>> {}
/** @name Tally */
export interface Tally extends Option<Vec<ITuple<[VoteOutcome, u128]>>> {}
/** @name TallyType */
export interface TallyType extends Enum {
readonly isOnePerson: boolean;
readonly isOneCoin: boolean;
}
/** @name VoteData */
export interface VoteData extends Struct {
readonly initiator: AccountId;
readonly stage: VoteStage;
readonly vote_type: VoteType;
readonly tally_type: TallyType;
readonly is_commit_reveal: bool;
}
/** @name VoteOutcome */
export interface VoteOutcome extends U8aFixed {}
/** @name VoteRecord */
export interface VoteRecord extends Struct {
readonly id: u64;
readonly commitments: Commitments;
readonly reveals: Reveals;
readonly data: VoteData;
readonly outcomes: Vec<VoteOutcome>;
}
/** @name VoteStage */
export interface VoteStage extends Enum {
readonly isPreVoting: boolean;
readonly isCommit: boolean;
readonly isVoting: boolean;
readonly isCompleted: boolean;
}
/** @name VoteType */
export interface VoteType extends Enum {
readonly isBinary: boolean;
readonly isMultiOption: boolean;
readonly isRankedChoice: boolean;
}
@@ -0,0 +1,34 @@
{
"compilerOptions": {
// this is specific with augmented overrides
"paths": {
// this is the package name we use (in the interface imports, --package for generators)
"sample-polkadotjs-typegen/*": ["src/*"],
// here we replace the @polkadot/api augmentation with our own, generated from chain
"@polkadot/api/augment": ["src/interfaces/augment-api.ts"],
// replace the augmented types with our own, as generated from definitions
"@polkadot/types/augment": ["src/interfaces/augment-types.ts"]
},
// some other options, whatever you want for your environment
"target": "esnext",
"module": "esnext",
"jsx": "preserve",
"declaration": true,
"strict": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"baseUrl": ".",
"skipLibCheck": true,
"typeRoots": [
"./node_modules/@types"
]
},
"exclude": [
"build/**/*",
"node_modules"
]
}
+3 -1
View File
@@ -1,10 +1,12 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Required imports
const { zip } = require('rxjs');
const { ApiRx } = require('@polkadot/api');
const { WsProvider } = require('@polkadot/rpc-provider');
function main () {
async function main () {
// Initialise the provider to connect to the local node
const provider = new WsProvider('ws://127.0.0.1:9944');
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiRx } = require('@polkadot/api');
@@ -10,7 +12,7 @@ async function main () {
new ApiRx().isReady
.pipe(
switchMap((api) =>
api.rpc.chain.subscribeNewHead()
api.rpc.chain.subscribeNewHeads()
))
.subscribe((header) => {
console.log(`Chain is at block: #${header.number}`);
@@ -2,4 +2,4 @@
This example shows how to instantiate a Polkadot API object and use it to connect to a node and retrieve balance updates.
<<< @/docs/examples/rx/03_listent_to_balance_change/index.js
<<< @/docs/examples/rx/03_listen_to_balance_change/index.js
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API and operators from RxJs
const { ApiRx } = require('@polkadot/api');
@@ -12,7 +14,7 @@ async function main () {
// Here we subscribe to any balance changes and update the on-screen value.
// We're using RxJs pairwise() operator to get the previous and current values as an array.
api.query.balances.freeBalance(Alice)
api.query.system.account(Alice)
.pipe(
// since pairwise only starts emitting values on the second emission, we prepend an
// initial value with the startWith() operator to be able to also receive the first value
@@ -23,12 +25,13 @@ async function main () {
if (balance[0] === 'first') {
// Now we know that if the previous value emitted as balance[0] is `first`,
// then balance[1] is the initial value of Alice account.
console.log(`Alice ${Alice} has a balance of ${balance[1]}`);
console.log(`Alice ${Alice} has a balance of ${balance[1].data.free}`);
console.log('You may leave this example running and start the "Make a transfer" example or transfer any value to Alice address');
return;
}
const change = balance[1].sub(balance[0]);
const change = balance[1].data.free.sub(balance[0].date.free);
// Only display value changes
if (!change.isZero()) {
console.log(`New balance change of: ${change}`);
+4 -2
View File
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiRx } = require('@polkadot/api');
@@ -5,11 +7,11 @@ const { switchMap } = require('rxjs/operators');
async function main () {
// Create a new instance of the api
// Subscribe to chain updates and log the current block number on update.
// Subscribe to chain updates and log the current block number on update.
const subscription = new ApiRx().isReady
.pipe(
switchMap((api) =>
api.rpc.chain.subscribeNewHead()
api.rpc.chain.subscribeNewHeads()
))
.subscribe((header) => {
console.log(`Chain is at block: #${header.number}`);
+8 -5
View File
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API
const { ApiRx } = require('@polkadot/api');
@@ -20,13 +22,13 @@ function main () {
// In the next step, we're checking if the node has active validators.
// If it does, we're making another call to the api to get the balances for all validators
const balances = (validators && validators.length > 0)
? combineLatest(validators.map(authorityId => api.query.balances.freeBalance(authorityId).pipe(first())))
? combineLatest(validators.map(authorityId => api.query.system.account(authorityId).pipe(first())))
: of(null);
// We're combining the results together with the emitted value 'validators',
// which we're turning back into an observable using of()
return combineLatest(
api.query.system.accountNonce(Alice).pipe(first()),
api.query.system.account(Alice).pipe(first()),
api.query.timestamp.blockPeriod().pipe(first()),
of(validators),
balances
@@ -34,15 +36,16 @@ function main () {
})
)
// Then we're subscribing to the emitted results
.subscribe(([accountNonce, blockPeriod, validators, validatorBalances]) => {
console.log(`accountNonce(${Alice}) ${accountNonce}`);
.subscribe(([{ nonce }, blockPeriod, validators, validatorBalances]) => {
console.log(`accountNonce(${Alice}) ${nonce}`);
console.log(`blockPeriod ${blockPeriod.toNumber()} seconds`);
if (validatorBalances) {
// And lastly we print out the authorityIds and balances of all validators
console.log('validators', validators.map((authorityId, index) => ({
address: authorityId.toString(),
balance: validatorBalances[index].toString()
balance: validatorBalances[index].data.free.toString(),
nonce: validatorBalances[index].data.toString()
})));
}
});
+16 -8
View File
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API, Keyring and some utility functions
const { ApiRx } = require('@polkadot/api');
@@ -10,25 +12,31 @@ async function main () {
const api = await ApiRx.create().toPromise();
// Create an instance of the keyring
const keyring = new Keyring({ type: 's25519' });
const keyring = new Keyring({ type: 'sr25519' });
// Add Alice to our keyring (with the known seed for the account)
const alice = keyring.addFomUri('//Alice');
const alice = keyring.addFromUri('//Alice');
// Create a extrinsic, transferring 12345 units to Bob.
api.tx.balances
// Create a extrinsic, transferring 12345 units to Bob.
const subscription = api.tx.balances
// create transfer
.transfer(BOB, 12345)
// Sign and send the transcation
.signAndSend(alice)
// Subscribe to the status updates of the transfer
.subscribe(({ status }) => {
if (status.isFinalized) {
console.log(`Successful transfer of 12345 from Alice to Bob with hash ${status.asFinalized.toHex()}`);
if (status.isInBlock) {
console.log(`Successful transfer of 12345 from Alice to Bob at block ${status.asInBlock.toHex()}`);
} else if (status.isFinalized) {
console.log('Finalized block hash', status.asFinalized.toHex());
subscription.unsubscribe();
process.exit(0);
} else {
console.log(`Staus of transfer: ${status.type}`);
console.log(`Status of transfer: ${status.type}`);
}
});
}
main().catch(console.error).finally(() => process.exit());
main().catch(console.error);
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API and selected RxJs operators
const { switchMap } = require('rxjs/operators');
+16 -10
View File
@@ -1,14 +1,16 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API and some utility functions
const { ApiRx } = require('@polkadot/api');
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
const testKeyring = require('@polkadot/keyring/testing');
// utility function for random values
// Utility function for random values
const { randomAsU8a } = require('@polkadot/util-crypto');
// some constants we are using in this sample
// Some constants we are using in this sample
const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';
const AMOUNT = 10000;
@@ -16,21 +18,21 @@ async function main () {
// Create our API with a connection to the node
const api = await ApiRx.create().toPromise();
// create an instance of our testign keyring
// Create an instance of our testign keyring
// If you're using ES6 module imports instead of require, just change this line to:
// const keyring = testKeyring();
const keyring = testKeyring.default();
// find the actual keypair in the keyring
// Find the actual keypair in the keyring
const alicePair = keyring.getPair(ALICE);
// create a new random recipient
// Create a new random recipient
const recipient = keyring.addFromSeed(randomAsU8a(32)).address;
console.log('Sending', AMOUNT, 'from', alicePair.address, 'to', recipient);
// get the nonce for the admin key
// Create a extrinsic, transferring 12345 units to Bob.
// Get the nonce for the admin key
// Create a extrinsic, transferring 12345 units to Bob.
api.tx.balances
// Do the transfer
.transfer(recipient, AMOUNT)
@@ -42,13 +44,17 @@ async function main () {
console.log('Transfer status:', status.type);
// Log system events once the transfer is finalised
if (status.isFinalized) {
console.log('Completed at block hash', status.asFinalized.toHex());
if (status.isInBlock) {
console.log('Included at block hash', status.asInBlock.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
});
} else if (status.isFinalized) {
console.log('Finalized block hash', status.asFinalized.toHex());
process.exit(0);
}
});
}
+15 -12
View File
@@ -1,7 +1,9 @@
/* eslint-disable @typescript-eslint/require-await */
/* eslint-disable @typescript-eslint/unbound-method */
/* eslint-disable @typescript-eslint/no-var-requires */
// Import the API & Provider and some utility functions
const { ApiRx, WsProvider } = require('@polkadot/api');
// import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
// Import the test keyring (already has dev keys for Alice, Bob, Charlie, Eve & Ferdie)
const testKeyring = require('@polkadot/keyring/testing');
const fs = require('fs');
@@ -12,41 +14,42 @@ async function main () {
// Create the API and wait until ready (optional provider passed through)
const api = await ApiRx.create({ provider }).toPromise();
// retrieve the upgrade key from the chain state
// Retrieve the upgrade key from the chain state
// TODO It seems like this promise doesn't resolve
const adminId = await api.query.sudo.key().toPromise();
// find the actual keypair in the keyring (if this is an changed value, the key
// Find the actual keypair in the keyring (if this is an changed value, the key
// needs to be added to the keyring before - this assumes we have defaults, i.e.
// Alice as the key - and this already exists on the test keyring)
const keyring = testKeyring.default();
const adminPair = keyring.getPair(adminId.toString());
// retrieve the runtime to upgrade to
// Retrieve the runtime to upgrade to
const code = fs.readFileSync('./test.wasm').toString('hex');
const proposal = api.tx.consensus.setCode(`0x${code}`);
console.log(`Upgrading chain runtime from ${adminId}`);
api.tx.sudo
// preform the actual chain upgrade via the sudo module
// Perform the actual chain upgrade via the sudo module
.sudo(proposal)
// sign and send the proposal
// Sign and send the proposal
.signAndSend(adminPair)
// subscribe to overall result
// Subscribe to overall result
.subscribe(({ events = [], status }) => {
// Log transfer events
console.log('Proposal status:', status.type);
if (status.isFinalized) {
if (status.isInBlock) {
console.error('You have just upgraded your chain');
console.log('Completed at block hash', status.asFinalized.toHex());
console.log('Included at block hash', status.asInBlock.toHex());
console.log('Events:');
// Log system events once the chain update is finalised
events.forEach(({ phase, event: { data, method, section } }) => {
console.log('\t', phase.toString(), `: ${section}.${method}`, data.toString());
});
console.log(JSON.stringify(events.toHuman(), null, 2));
} else if (status.isFinalized) {
console.log('Finalized block hash', status.asFinalized.toHex());
process.exit(0);
}
+157
View File
@@ -0,0 +1,157 @@
**NOTE** Removed - in metadata v11 we get the extensions from the chain, we need to be able to specify these. These docs are now outdated.
# Extending extrinsics
On some chains, the need may arise to customize the extrinsic format. In this section we will explain what extrinsics and their payloads contain, explain how signed extensions work and provide a walk through of an advanced use-case where extrinsics are customized for a specific Substrate chain.
## Extensions
In Substrate (which forms the base of Polkadot and a number of custom chains), an extrinsic has a specific version, flag to indicating if it has been signed, the address, signature, extra data as well as the actual method with params. In addition, the signature is generated over the call and may include values that are not encoded into the final extrinsic.
For instance, with version 3 extrinsics, the signature payload contains the runtime spec version as well as the `genesisHash` and `blockHash` (the latter being equivalent to the `genesisHash` in case of immortal transactions), however while these 3 fields are signed together with the method data, they do not actually appear in the extrinsic itself. Rather the chain executing the transaction will retrieve this information, add it to the method data and compare the signatures thereof.
So in both the cases of the `genesisHash` and `specVersion`, if these do not match the signer version, the transaction won't be accepted - however the extrinsic doesn't explicitly carry this information in the data being transmitted, rather only implicitly as part of the signature. And it always forms part of the validation.
## Default extrinsics
With the above in-mind, the extrinsic format is explicitly defined as having the following structure in Substrate -
```rust
pub struct UncheckedExtrinsic<Address, Call, Signature, Extra>
where Extra: SignedExtension
{
pub signature: Option<(Address, Signature, Extra)>,
pub function: Call,
}
```
The `Option` is here encoded such that is conveys both the extrinsic version `0x03` for Substrate 2.x chains (`0x01` for Substrate 1.x chains) as well as a high-bit that indicates if the transaction is signed or unsigned. (For unsigned the `signature` details therefore does not appear). The `SignedExtension` part defined both the data in the actual extrinsic as well as data, i.e. `AdditionalSigned`, that appears in the payload for the signature, but is not explicitly contained in the extrinsic.
The default `SignedExtension` for Substrate 2.x with extrinsic version 3 is defined as follow -
```rust
pub type SignedExtra = (
system::CheckVersion<Runtime>,
system::CheckGenesis<Runtime>,
system::CheckEra<Runtime>,
system::CheckNonce<Runtime>,
system::CheckWeight<Runtime>,
balances::TakeFees<Runtime>,
contracts::CheckBlockGasLimit<Runtime>,
);
```
Some of these are only checks, requiring no additional data in the payload or extrinsic itself, i.e. the contracts checks do exactly that. It only applies checks and invalidates when those checks are invalid. This is a powerful concept, for instance on the [initial Kusama chain this was used to limit the types of calls allowed](https://github.com/paritytech/polkadot/blob/f52c714ec3411eea58647d0f5176f4eb81660188/runtime/src/lib.rs#L117-L139).
## Extension deep-dive
For each of the default extensions, we will take a look through to understand the implications of the specific extension and how it relates to both the data contained in the extrinsic as well as the signature payload.
- `system::CheckVersion` - This checks that the spec version matches between the extrinsic and the chain. It takes no parameters which means that these is no explicit data in the extrinsic format for this field, however it has `type AdditionalSigned = u32` which means that a `u32` containing the runtime spec version is part of the signature payload.
- `system::CheckGenesis` - This checks that the `genesisHash` matches between extrinsic and chain. Like the previous check, no additional data is added to the extrinsic, however with `type AdditionalSigned = T::Hash`, the `genesisHash` is part of the signature payload.
- `system::CheckEra` - This checks the era (mortal or immortal) for the transaction being sent. It checks both the `era: Era` as part of the actual extrinsic and the `blockHash` via the `type AdditionalSigned = T::Hash`. This means that the extrinsic era is both in the data being signed and the extrinsic itself, while the `blockHash` the era applies to is only available in the signature payload.
- `system::CheckNonce` - This checks the nonce for the sending account. Unlike the preceding checks, it has no payload-specific data, however the `nonce: Compact<T::Index>` (`Index` is default `u32`) is applicable to both the extrinsic and, therefore, the actual signature payload as well.
- `system::CheckWeight` - This checks the weight and length of the block and ensure that it does not exceed the limits. It does not have any specific data attached to either the extrinsic nor payload, but rather just does calculations based on the weights and type of transaction received.
- `balances::TakeFees` - Consumes fees proportional to the length and weight of the transaction. It operates on the `fee: Compact<T::Balance>`, which means this value is included in both the extrinsic and subsequent payload being signed.
- `contracts::CheckBlockGasLimit` - As explained briefly above, this extension does not add data to the extrinsic, or the signature payload, however it ensures that the transaction does not exceeds the block gas limit.
## Extrinsic and signature payloads
With the above extension, the following formats for the extrinsic and payloads are the outcome of the application of the signed extension. For the extrinsic the following data is [always encoded for v3 extrinsics](https://github.com/polkadot-js/api/blob/8b0ef159c05bcb5d9b664546d0e7289e79b5c9d5/packages/types/src/primitive/Extrinsic/v3/Extrinsic.ts#L27) -
```js
class ExtrinsicV3 extends Struct {
constructor (value) {
super({
signer: 'Address',
signature: 'Signature',
era: 'ExtrinsicEra', // extra via system::CheckEra
nonce: 'Compact<Index>', // extra via system::CheckNonce
tip: 'Compact<Balance>', // extra via balances::TakeFees
method: 'Call'
}, value);
}
...
```
The signature payload will contain the same information as the extrinsic, with the following [additional information](https://github.com/polkadot-js/api/blob/8b0ef159c05bcb5d9b664546d0e7289e79b5c9d5/packages/types/src/primitive/Extrinsic/v3/ExtrinsicPayload.ts#L33) as expected by the `AdditionalSigned` portions of the extensions -
```js
class ExtrinsicPayloadV3 extends Struct {
constructor (value) {
super({
method: 'Bytes',
era: 'ExtrinsicEra', // extra via system::CheckEra
nonce: 'Compact<Index>', // extra via system::CheckNonce
tip: 'Compact<Balance>', // extra via balances::TakeFees
specVersion: 'u32', // additional via system::CheckVersion
genesisHash: 'Hash', // additional via system::CheckGenesis
blockHash: 'Hash' // additional via system::CheckEra
}, value);
}
...
```
As per the above structures, it means that both the extrinsic sent on-chain as well as the data being signed to generate the signature is tied by the hip based on the logic the chain expects via `SignedExtension`. The API is only aware of the version of the extrinsic being used on-chain (it determines this on connection) and therefore only knows about the specific logic that has been coded for the extrinsic version.
## Extending existing or implementing new
When the API encodes or decodes an extrinsic, it uses the first `Option` byte to determine the version. Once it has this value, it will create a specific extrinsic via `createType('ExtrinsicV3', value)`. This means that at any point, you can supply your own version of either the `Extrinsic` or `ExtrinsicPayload` and you can do so via 2 avenues -
- If you are extending/replacing the existing version, you can inject your own types for both `ExtrinsicV3` and `ExtrinsicV3Payload` (assuming you are replacing v3)
- If you are adding a new version, you can add a handler for both `ExtrinsicUnknown` and `ExtrinsicPayloadUnknown`. These will be constructed when the version the API is aware of does not match with the on-chain version.
While we will not provide a full example of all the code here, the above links will show the existing implementations. However, assuming we have a chain where neither the nonce or tip is applicable (or we just don't care) and we are ignoring the check to the runtime versioning.
Additionally assuming that we have made the required `SignedExtension` updates by removing `system::CheckVersion`, `system::CheckNonce` and `balances::TakeFees`, we can do the following -
```js
...
class OwnExtrinsic extends Struct {
constructor (value) {
super({
signer: 'Address',
signature: 'Signature',
era: 'ExtrinsicEra', // extra via system::CheckEra
method: 'Call'
}, value);
}
...
}
class OwnExtrinsicPayload extends Struct {
constructor (value) {
super({
method: 'Bytes',
era: 'ExtrinsicEra', // extra via system::CheckEra
genesisHash: 'Hash', // additional via system::CheckGenesis
blockHash: 'Hash' // additional via system::CheckEra
}, value);
}
...
// signing logic needs to be included, as per existing
}
...
// inject our types at API construction
const api = ApiPromise.create({
types: {
'ExtrinsicV3': OwnExtrinsic,
'ExtrinsicV3Payload': OwnExtrinsicPayload,
}
})
```
The above example is certainly an advanced example, but it shows that all data types in the API can be adjusted and these adjustment can be provided to the API. In all cases, if you made updates to the formats and types of the actual runtime, you need to ensure that the API is aware of these changes.
In the above example, should these updates only be made on the node side, without the required API adjustments, the API will generate invalid transactions for the node since it is unaware of the changes and adjusted formats. Making the adjustments on only one side will mean that the signature verification can fail and that the format will not be decodable via the node.
(These extensions are not exposed via metadata at all, and would be quite difficult to do as well - since each of these have specific logic as well as data types assigned.)
+5
View File
@@ -0,0 +1,5 @@
... somewhere also need a signer injection section, something along the lines of the singlesigner or this https://github.com/polkadot-js/tools/blob/master/packages/signer-cli/src/cmdSubmit.ts#L12
... DoubleMap & LinkedMap examples
... api.derive
+51
View File
@@ -0,0 +1,51 @@
# FAQ
The list will be updated/expanded as questions come up, dealing with some common issues that API users find.
## I am getting a "Unknown types found, no types for ..." error
There are 2 causes for this, both related to the version of the API that you are using and the support of types. As explained in the elsewhere, types on Polkadot/Substrate are continuously evolving - the latest version of the API always tries to support types for the latest Polkadot networks, such as [Kusama](https://kusama.network/). So for Polkadot public chains, ensure that you are using the latest released API version.
If however you are running against a master branch of either Polkadot or Substrate, you may well be better suited running [a beta version, tracking master](install.md#betas). If you are connected to a customized chain, you would rather want to [register the types](types.extend.md) either on your own, or via packages that the chain vendor provides.
## I am getting a "Metadata:: failed on MagicNumber" error
Update your version of the API to the [latest version](install.md). Like types, the [metadata interfaces](basics.md) are continuously evolving. For instance with the Polkadot Alexander network, only metadata v3 is available. By the time Kusama launched, this has been bumped to v7. As these versions are added to the Polkadot/Substrate codebase, they are added to the API.
## The node returns a "Could not convert" error on send
The typical error that you would see is `Verification Error: Execution(ApiError("Could not convert parameter 'tx' between node and runtime`. This means that the transaction data serialized from the API cannot be deserialized on the node.
All data transferred between the API and the Node is in a SCALE-encoded binary format, so the [definition of the types](types.extend.md) between the API and the node needs to match 100%. When you find the above, it would mean the definition of the types on the API side does not match what is on the node. Specifically the API encodes against the definition, but since there is a mismatch the Node cannot parse the data correctly.
To fix this, you should look at the specific `api.tx.*` params and adjust the type definitions for those param types to match what is found on the node side. In some rare cases the cause could be extrinsic formatting related, to track these make an `api.tx.system.remark(data: Bytes)` call, if it fails, the API and node cannot agree on [an extrinsic format and adjustments are required](types.extend.md#impact-on-extrinsics).
## I would like to sign transactions offline
The API itself is independent on where the signature comes from and how it is injected. Additionally it implements a signer interface, that can be used for external signing - an example of this is the [polkadot-js/apps](https://github.com/polkadot-js/apps) support for signing via extensions and even the [polkadot-js/extension](https://github.com/polkadot-js/extension) support for tools such as the [Parity Signer](https://github.com/paritytech/parity-signer).
As of this writing we don't have an explicit example of implementing the signer interface in these docs, although we do use one in [our tests](https://github.com/polkadot-js/api/blob/master/packages/api/test/util/SingleAccountSigner.ts). Additionally, the [polkadot-js/tools](https://github.com/polkadot-js/tools) has an implementation of [a very basic offline signer](https://github.com/polkadot-js/tools/tree/master/packages/signer-cli) where transactions are generated in one process and signatures in another non-connected process.
## I would like to send a root transaction
Some calls in Polkadot/Substrate can only be submitted as root, these are indicated by `ensure_root(origin)` in the Rust codebase. Root here does not refer to the actual account, i.e. `//Alice` on a `--dev` chain, but rather that it cannot be submitted as a bare user transaction. This restriction applies to chain upgrades, changing balances or anything that modifies the state and/or chain operation.
To submit these transactions, it needs to be send as a [wrapped transaction](api.tx.wrap.md#sudo-use) via either `sudo.sudo` (assuming you have access on your chain) or `democracy.proposal` (which would allow users of the chain to vote on it).
## How do I call a function with a Tuple input
Tuples, as defined in the Polkadot/Substrate types appear as `(TypeA, TypeB)`. For instance we may have an `(AccountId, u64)` input as defined in the metadata or as part of the user types. To specify a Tuple as an input, wrap it is an array format, for instance to call `query.module.get((u32, u64))` where a `(u32, u64)` Tuple input is expected, you would do `query.module.get([123, 456])`
## How long do transactions live
Polkadot/Substrate supports both immortal and mortal transactions. For immortal, this means that the transaction has an infinite lifetime, for mortals, the transactions expire after a defined period. By default the API sends mortal transactions when no explicit extrinsic era has been specified. This means that all transaction has a limited lifetime and will expire if not included in the period set.
The length for this transaction validity is set to 50 blocks, which translates to 5 minutes assuming a default of 6 second blocktimes. (10 blocks per minute in this default configuration).
## My chain does not support system.account queries
The API always tracks the latest Substrate master in terms of examples. This means that nonce & balance queries are done via the `api.query.system.account(<account>)` which returns a struct `{ nonce: Index, data: AccountData }` where the `data` is struct containing the free and reserved balances. As with all `api.query.*` endpoints, this is decorated based on what the chain you connect to support, via the metadata exchange.
It is possible that you are connecting to an older chain that has not been upgraded yet. For these chains, this storage entry won't be available (yet). To query the nonce on older chains, you can do a query to `api.query.system.accountNonce(<account>)` and balances can be retrieved via `api.query.balances.freeBalance(<account>)`.
Likewise, if your chain has been upgraded recently and you are still using the old `system.accountNonce` or `balances.freeBalance` queries in your code (which is now not available in the chain metadata), you need to update it to query the new location.
+15
View File
@@ -0,0 +1,15 @@
# Getting started
These sections should provide you with all the information needed to install the `@polkadot/api` package, understand the structure of the interfaces and allow you to start using it. For existing users this really should be titled "Things I wish I knew before I started using the api" - it really aims to close the gap to allow anybody to get to grips with using the packages.
## What this is not
This is not line-by-line documentation of all the existing function calls available, nor it is tied to a specific chain. (Although the examples do refer to the base Polkadot & Substrate chains). There will be some things in the API that are probably not covered, which brings us to the next point...
## Help us help others
If you spot gaps in the information provided, or are uncertain about any specific area, please do [log an issue](https://github.com/polkadot-js/api/issues) or if you are that way inclined, make a pull-request. We really want to have good documentation in these areas and allow people to be productive right from the start.
## Ready? Steady? Go!
If you already have a good grasp on the API and are just looking for a specific answer, you may want to take a look at the [Frequently Asked Questions](FAQ.md). With all that said, let's get started... [What should be installed, and how should we do it?](install.md)
+34
View File
@@ -0,0 +1,34 @@
# Runtime Constants
Constant queries will introduce you to the concepts behind the types and the interaction of the API with those types. The same concepts are implemented in the remainder of the API - the runtime constants is just the simplest starting point.
For some background: constants are values that are defined in the runtime and used as part of chain operations. These constants can be changed as part of an upgrade.
```js
// Initialize the API as per previous sections
...
// The length of an epoch (session) in Babe
console.log(api.consts.babe.epochDuration.toNumber());
// The amount required to create a new account
console.log(api.consts.balances.creationFee.toNumber());
// The amount required per byte on an extrinsic
console.log(api.consts.balances.transactionByteFee.toNumber());
```
Since these are constants and defined by the metadata, it is not a call, but rather the values immediately available - as you'll see in subsequent sections, there is no need for `await` on these, it immediately returns the type and value for you to work with.
## The API and types
There is some magic applied by the API. For instance as the `createFee` result is returned, the API knows the expected type and makes a `Balance` object available, hence the `toNumber`. This result mapping is consistent in retrieving constants, making queries or even sending transactions:
- when values are passed to the API, the API will convert whatever is provided into the correct type as required by the call
- when a value is retrieved, the API will provide an object of the correct type that wraps this value
From the last point, this means that a `Balance` will be returned as a number object extending [bn.js](https://github.com/indutny/bn.js/). In a later section we will go through a breakdown of all the commonly-used types and all [the basics available on types](types.basics.md).
## Making queries
In the next section we will take an initial dive into [chain state and state queries](api.query.md), allowing the use of the API to retrieve information contained in the chain state.
+44
View File
@@ -0,0 +1,44 @@
# State queries
In previous sections, we initialized the API and retrieved runtime constants. This section will walk through the concepts behind making queries to the chain to retrieve current state. The `api.query.<module>.<method>` interfaces, as already described earlier, is populated from the metadata. The API uses the metadata information provided to construct queries based on the location and parameters provided to generate state keys, and then queries these via RPC.
## Basic queries
Let's dive right in, connect to a general chain and retrieve some information on the current state. Of interest may be retrieving the nonce of a particular account as well as the current balance, this can be achieved via -
```js
// Initialize the API as in previous sections
...
// The actual address that we will use
const ADDR = '5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE';
// Retrieve the last timestamp
const now = await api.query.timestamp.now();
// Retrieve the account balance & nonce via the system module
const { nonce, data: balance } = await api.query.system.account(ADDR);
console.log(`${now}: balance of ${balance.free} and a nonce of ${nonce}`);
```
There have been some additions in the code above comparing with retrieving runtime constants. In these cases, since we are making a query to the actual chain, we use the `await` syntax to retrieve the information. Since the API is Promise-based, this means we can also rewrite the above to follow a Promise pattern,
```js
...
// Retrieve last block timestamp, account nonce & balances
const [now, { nonce, data: balances }] = await Promise.all([
api.query.timestamp.now(),
api.query.system.account(ADDR)
]);
```
## Parameters & return values
As indicated in previous sections, any return value is always an object with a consistent interface that reflects the type being returned. In the above example, the timestamp is a `Moment` (a `u64` value), the nonce is an `Index` (a `u32` value) and the `Balance` is an underlying `u128`.
Additionally we have provided some parameters for the query calls, specifically for the retrieval of the nonce and balance. It is important to note that the API will automatically convert any parameters into the correct type for encoding and making calls, in this case the `AccountId` parameter could be specified as a ss58 address (as it was), an actual `AccountId` (retrieved via another call) or just a plain `Uint8Array` (or even hex-string representation) for a publicKey.
## Exploring RPCs
Where all query functions use the underlying RPCs, together with metadata, to construct and retrieve information, the direct node RPCs can be seen as raw calls that enable these (slightly) higher-level operations. Next up we will take a dive into [making RPC calls via the API](api.rpc.md).
+59
View File
@@ -0,0 +1,59 @@
# Multi queries
In a number of applications, it is useful to monitor a number of like-queries at the same time. For instance, we may want to track the balances for a list of accounts we have. The `api.query` interfaces allows this via the `.multi` subscription call.
## Multi queries, same type
Where possible, the use of multi queries are encouraged since it tracks a number of state entries over a single RPC call, instead of making a call for each single item. In addition it allows you to have a single callback to track changes. For queries of the same type we can use `.multi`, for example to retrieve the balances of a number of accounts at once -
```js
...
// Subscribe to balance changes for 2 accounts, ADDR1 & ADDR2 (already defined)
const unsub = await api.query.system.account.multi([ADDR1, ADDR2], (balances) => {
const [{ data: balance1 }, { data: balance2 }] = balances;
console.log(`The balances are ${balance1.free} and ${balance2.free}`);
});
```
A couple of items to note in the example above: we don't call `account` directly, but rather `account.multi`. We pass the addresses we want to query as an array, and the length thereof would depend on the number of addresses we want to query. As an extended example, we can track the balances of a list of validators,
```js
...
// Retrieve a snapshot of the validators
const validators = await api.query.session.validators();
// Subscribe to the balances for these accounts
const unsub = await api.query.balances.account.multi(validators, (balances) => {
console.log(`The nonce and free balances are: ${balances.map(([nonce, { free }]) => [nonce, free])}`);
});
```
The above example does not subscribe to the validators explicitly, but only gets a snapshot and uses this into the future. It should be trivially extendable to subscribe to the validators, track which one have entered or left and then subscribe to balances as they change through the next blocks.
## Multi queries, distinct types
The previous `.multi` examples assumes that we do queries for the same types, i.e. we retrieve the balances for a number of accounts. However, there is also a need to retrieve various distinct types, as an example we would like to track the block timestamp in addition to the nonce and balance of a specific account. To cater for this, the api has a specific `api.queryMulti` interface that can be used to perform this query -
```js
...
// Subscribe to the timestamp, our index and balance
const unsub = await api.queryMulti([
api.query.timestamp.now,
[api.query.system.account, ADDR]
], ([now, { nonce, data: balance }]) => {
console.log(`${now}: balance of ${balance.free} and a nonce of ${nonce}`);
});
```
The above example certainly does not quite look as ergonomic and clean, but the API needs to understand (a) which are all the calls we need to make and (b) the calls and their params (if required). So breaking it down -
- `api.query.timestamp.now` - the timestamp is passed naked without any params. Also note that we do not call it while passing, but rather only provides a reference to the function, i.e. we do not have the expected `()` at the end. (This could also be of the form `[api.query.timestamp.now]`, aligning with subsequent entries)
- `[api.query.system.account, ADDR]` - the nonce & balance query is passed as an array containing the function (once again naked), followed by the parameters that apply.
## Rounding out queries
To round out our query introduction, there are a [number of other utilities and calls available](api.query.other.md) that allows the `api.query` user to perform certain tasks, such as querying state at a specific block. These are covered in the next section.
+76
View File
@@ -0,0 +1,76 @@
# Query extras
In previous sections we took a walk through queries, showing how to use one-shot queries, how to subscribe to results and how to combine multiple queries into one. This section will aim to extend that knowledge showing some other features and utilities that are available on the `api.query` interfaces.
## State at a specific block
Quite often is is useful (taking pruning into account, more on this later) to retrieve the state at a specific block. For instance we may wish to retrieve the current balance as well as the balance at a previous block for a specific account -
```js
...
// Retrieve the current block header
const lastHdr = await api.rpc.chain.getHeader();
// Retrieve the balance at both the current and the parent hashes
const [{ data: balanceNow }, { data: balancePrev }] = await Promise.all([
api.query.system.account.at(lastHdr.hash, ADDR),
api.query.system.account.at(lastHdr.parentHash, ADDR)
]);
// Display the difference
console.log(`The delta was ${balanceNow.free.sub(balancePrev.free)}`);
```
In the above example, we introduce the `.at(<hash>[, ...params])` query. For all `.at` queries, the first parameter is always the block hash at which we want to make the query, in our example we use both the last retrieved block and the parent thereof. The params are optional as per the type of query made, for instance to retrieve the timestamp for a previous block, it would be -
```js
...
// Retrieve the timestamp for the previous block
const momentPrev = await api.query.timestamp.now.at(lastHdr.parentHash);
```
The `.at` queries are all single-shot, i.e. there are no subscription option to these, since the state for a previous block should be static. (This is true to a certain extent, i.e. when blocks have been finalized).
An additional point to take care of (briefly mentioned above), is state pruning. By default a Polkadot/Substrate node will only keep state for the last 256 blocks, unless it is explicitly run in archive mode. This means that querying state further back than the pruning period will result in an error returned from the Node. (Generally most public RPC nodes only run with default settings, which includes aggressive state pruning)
## State entries
In addition to using `api.query` to make actual on-chain queries, it can also be used to retrieve some information on the state entries. For instance to retrieve both the hash and size of an existing entry, we can make the following calls -
```js
...
// Retrieve the hash & size of the entry as stored on-chain
const [entryHash, entrySize] = await Promise.all([
api.query.system.account.hash(ADDR),
api.query.system.account.size(ADDR)
]);
// Output the info
console.log(`The current size is ${entrySize} bytes with a hash of ${entryHash}`);
```
As per the previous examples, the params here apply explicitly to the actual needed values to identify an entry. As with `.at` queries, there are no subscription versions for these queries, rather they are seen as one-shot values at a specific point in time.
## Entry metadata
It has been explained that the `api.query` interfaces are decorated from the metadata. This also means that there is some information that we can gather from the entry, as decorated -
```js
// Extract the info
const { meta, method, section } = api.query.system.account;
// Display some info on a specific entry
console.log(`${section}.${method}: ${meta.documentation.join(' ')}`);
console.log(`query key: ${api.query.system.account.key(ADDR)}`);
```
The `section` & `method` is an indication of where it is exposed on the API. In addition the `meta` holds an array with the metadata documentation for the entry.
The `key` endpoint requires some explanation. In the chain state, the key values (identified by the module, method & params) are hashed and this is used as a lookup. So underlying a single-shot query would utilize the `api.rpc.state.getStorage` entry, passing the output of `key` (which is a hashed representation of the values). Apart from the hashing, the API also takes care of type formatting, handling optional values and merging results across multiple subscriptions.
## Let's transact already!
At this point you are already burning to actually make some transactions. Making queries is cool, but just how do [you actually submit transactions on-chain](api.tx.md).
+37
View File
@@ -0,0 +1,37 @@
# Query subscriptions
Previously we explained the concepts between `api.query`. In this section we will expand on that knowledge to introduce subscriptions (akin to what we found in `api.rpc`) to stream results from the state, as it changes between blocks.
## Subscriptions
As in the case with `api.rpc` subscriptions, query subscriptions follow exactly the same form - an actual call is augmented with a callback to return the current state value that is updated as the underlying value changes. As an example, we can extend on what we had previously -
```js
...
// Retrieve the current timestamp via subscription
const unsub = await api.query.timestamp.now((moment) => {
console.log(`The last block has a timestamp of ${moment}`);
});
```
The form is exactly the same as the subscriptions we have seen previously, instead of the `await` returning the actual once-off value, it returns a subscription `unsub()` function that can be used to stop the subscription and clear up any underlying RPC connections. The supplied callback will contain the value as it changes, streamed from the node.
## Subscriptions with params
If we had a query with parameters, i.e. where we wish to perform a query for a specific account, the form is exactly the same - the last parameter contains the actual callback, after all other parameters. To retrieve the balances for an account as it changes, we could do the following -
```js
...
// Subscribe to balance changes for our account
const unsub = await api.query.system.account(ADDR, ({ nonce, data: balance }) => {
console.log(`free balance is ${balance.freee} with ${balance.reserved} reserved and a nonce of ${nonce}`);
});
```
By now this subscription form should be familiar to you, including the usage of `unsub`.
## Multiple queries
In most non-trivial applications, it is useful to optimize both our code in terms of callbacks as well as node resources, for instance by [performing multiple queries at once, over the same RPC call](api.query.multi.md).
+70
View File
@@ -0,0 +1,70 @@
# RPC queries
The RPC calls provide the backbone for the transmission of data to and from the node. This means that all API endpoints such as `api.query`, `api.tx` or `api.derive` just wrap RPC calls, providing information in the encoded format as expected by the node.
Since you are already familiar with the `api.query` interface, the `api.rpc` interface follows the same format, for instance -
```js
...
// Retrieve the chain name
const chain = await api.rpc.system.chain();
// Retrieve the latest header
const lastHeader = await api.rpc.chain.getHeader();
// Log the information
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
```
In this example, you will see the same pattern as with queries: each result is a promise and a simple `await` makes the query and resolves with the result.
## Subscriptions
The RPCs lend themselves to using subscriptions, for instance in the above case you would assume that once connected, the chain won't change, however new blocks will come in at intervals and we probably want to keep track of those. We can adapt the previous example to start using subscriptions -
```js
...
// Subscribe to the new headers
await api.rpc.chain.subscribeNewHeads((lastHeader) => {
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
});
```
Since we are dealing with a subscription, we now pass a callback into the `subscribeNewHeads` function, and this will be triggered on each header, as they are imported. The same pattern would apply to each of the `api.rpc.subscribe*` functions - as a last parameter a callback is to be provided that streams the latest data, as it becomes available.
In general, whenever we create a subscription, we would like to cleanup after ourselves and unsubscribe, so assuming we only want to log the first 10 headers, the above example can be adjusted in the following manner -
```js
...
let count = 0;
// Subscribe to the new headers
const unsubHeads = await api.rpc.chain.subscribeNewHeads((lastHeader) => {
console.log(`${chain}: last block #${lastHeader.number} has hash ${lastHeader.hash}`);
if (++count === 10) {
unsubHeads();
}
});
```
Unlike single-shot queries, for subscriptions we are `await`-ing a function, taking no parameters (that also returns nothing) that can be used to unsubscribe for the subscription and clear the underlying RPC connection. So in the above example we set `unsubHeads` and then call it when we wish to cancel the subscription.
## Detour into derives
The `api.derive` interfaces will be covered in a follow-up section, but since the above example deals with new head subscriptions, a quick detour is warranted. The derives are just helpers that define certain functions and combine results from multiple sources. For new headers, the following information is useful in certain scenarios -
```js
...
const unsub = await api.derive.chain.subscribeNewHeads((lastHeader) => {
console.log(`#${lastHeader.number} was authored by ${lastHeader.author}`);
});
```
In the above case the `subscribeNewHeads` derive augments the header retrieved with an `.author` getter. This is done by parsing the actual header and logs received and filling in the author from the `api.query.session.validators` call.
## Extended Queries
As a next step, now that we have understood subscription and RPC basics, we will circle back to the `api.query` interface, [extending our queries with subscriptions](api.query.subs.md).
+40
View File
@@ -0,0 +1,40 @@
# Transactions
Transaction endpoints are exposed, as determined by the metadata, on the `api.tx` endpoint. These allow you to submit transactions for inclusion in blocks, be it transfers, setting information or anything else your chain supports.
## Simple transactions
To start off, let's make a balance transfer from Alice to Bob.
```js
...
// Sign and send a transfer from Alice to Bob
const txHash = await api.tx.balances
.transfer(BOB, 12345)
.signAndSend(alice);
// Show the hash
console.log(`Submitted with hash ${txHash}`);
```
We have already become familiar with the `Promise` syntax that is used throughout the API, in this case it is no different. We construct a transaction by calling `balances.transfer(<accountId>, <value>)` with the required params and then as a next step we submit it to the node.
As with all other API operations, the `to` params just needs to be "account-like" and the value params needs to be "number-like", the API will take care of encoding and conversion into the correct format.
The result for this call (we will deal with subscriptions in a short while), is the transaction hash. This is a hash of the data and receiving this does not mean that transaction has been included, but rather only that it has been accepted for propagation by the node. (It can still fail on execution, we will handle this in some of our follow-up sections.)
## Under the hood
Despite the single-line format of `signAndSend`, there is a lot happening under the hood (and all of this can be manually provided) -
- Based on the sender, the API will query `system.account` (or `system.accountNonce` on older chains) to determine the next nonce to use
- The API will retrieve the current block hash and use it to create a mortal transaction, i.e. the transaction will only be valid for a limited number of blocks (by default this is 5 mins at 6s block times)
- It will construct a payload and sign this, this includes the `genesisHash`, the `blockHash` for the start of the mortal era as well as the current chain `specVersion`
- The transaction is submitted to the node
As suggested, you can override all of this, i.e. by retrieving the nonce yourself and passing that as an option, i.e. `signAndSend(alice, { nonce: aliceNonce })`, this could be useful when manually tracking and submitting transactions in bulk.
## Into the keyring we go
With the examples above, the variable `alice` seems to have appeared from thin air. To understand how transactions are signed, we will take a [brief diversion into the keyring](keyring.md) before returning to our regularly scheduled program.
+67
View File
@@ -0,0 +1,67 @@
# Transaction subscriptions
Previously we sent simple transactions using the `api.tx` endpoints, in this section we will extend that to monitor the actual transactions for inclusion and also extend the monitoring for transaction events.
## Transaction inclusion
To send a transaction and then waiting until it has been included in a block, we will use a subscription interface instead of just waiting for the transaction pool addition to yield the extrinsic hash. For the simplest form, we can do the following -
```js
...
// Create alice (carry-over from the keyring section)
const alice = keyring.addFromUri('//Alice');
// Make a transfer from Alice to BOB, waiting for inclusion
const unsub = await api.tx.balances
.transfer(BOB, 12345)
.signAndSend(alice, (result) => {
console.log(`Current status is ${result.status}`);
if (result.status.isInBlock) {
console.log(`Transaction included at blockHash ${result.status.asInBlock}`);
} else if (result.status.isFinalized) {
console.log(`Transaction finalized at blockHash ${result.status.asFinalized}`);
unsub();
}
});
```
As per all previous subscriptions, the transaction subscription returns in `unsub()` and the actual method has a subscription callback. The `result` object has 2 parts, `events` (to to covered in the next section) and the `status` enum.
When the `status` enum is in `Finalized` state (checked via `isFinalized`), the underlying value contains the block hash of the block where the transaction has been finalized. `Finalized` will follow `InBlock`, which is the block where the transaction has been included. `InBlock` does not mean the block is finalized, but rather applies to the transaction state, where `Finalized` means that the transaction cannot be forked off the chain.
## Transaction events
Any transaction will emit events, as a bare minimum this will always be either a `system.ExtrinsicSuccess` or `system.ExtrinsicFailed` event for the specific transaction. These provide the overall execution result for the transaction, i.e. execution has succeeded or failed.
Depending on the transaction sent, some other events may however be emitted, for instance for a `balances.transfer` this could include one or more of `Transfer`, `NewAccount` or `ReapedAccount`, as defined in the [substrate balances event defaults](../substrate/events.md#balances).
To display or act on these events, we can do the following -
```js
...
// Make a transfer from Alice to BOB, waiting for inclusion
const unsub = await api.tx.balances
.transfer(BOB, 12345)
.signAndSend(alice, ({ events = [], status }) => {
console.log(`Current status is ${status.type}`);
if (status.isFinalized) {
console.log(`Transaction included at blockHash ${status.asFinalized}`);
// Loop through Vec<EventRecord> to display all events
events.forEach(({ phase, event: { data, method, section } }) => {
console.log(`\t' ${phase}: ${section}.${method}:: ${data}`);
});
unsub();
}
});
```
Be aware that when a transaction status is `isFinalized`, it means it is included, but it may still have failed - for instance if you try to send a larger amount that you have free, the transaction is included in a block, however from a end-user perspective the transaction failed since the transfer did not occur. In these cases a `system.ExtrinsicFailed` event will be available in the events array.
## Complex transactions
In many cases transactions can carry quite complex information, be it for passing objects or proposing changes. In the next section we will take a dive [into complex transactions, including those wrapped for sudo](api.tx.wrap.md).
+44
View File
@@ -0,0 +1,44 @@
# Complex transactions
Up till now we have focussed on the base operation of transactions. There are however some more complex operations that deserve some more information, for instance when doing either democracy proposals or executing sudo calls, in both these cases the transaction wraps a call or proposal to be evaluated.
## Sudo use
When running a development chain (Polkadot/Substrate with a `--dev` flag), or in certain testnets a sudo module is available - just like the sudo command found on some systems, it allows root-level access to perform actions. For instance, we can perform a `setBalance(<accountId>, <free>, <reserved>)` on an account -
```js
...
// Get the current sudo key in the system
const sudoKey = await api.query.sudo.key();
// Lookup from keyring (assuming we have added all, on --dev this would be `//Alice`)
const sudoPair = keyring.getPair(sudoKey);
// Send the actual sudo transaction
const unsub = await api.tx.sudo
.sudo(
api.tx.balances.setBalance(ADDR, 12345, 678)
)
.signAndSend(sudoPair, (result) => { ... });
```
The above is really quite straight-forward, the `sudo.sudo(<call>)` call takes 1 parameter, which is a `Call`. We construct this via the `api.tx` and pass it through. The only difference is that the nested call has no actual `.signAndSend` on it, rather it is only used as a container for data.
Exactly the same would apply to the standard `democracy.propose(<proposal>, <value>)`, for instance we can just swap the above sudo wrapper with a proposal and add the correct fees for the proposal.
## Complex types
As indicated in previous sections (we will cover types in more detail next), the API will format the inputs into the actual type required for submission. For primitives such as numbers, this is quite understandable, but it is worth spending at least one example on cases where an object is provided as an input. For instance, making a call to validate -
```js
...
const txHash = await api.tx.staking.validate({
validatorPayment: 12345
});
```
In the above example, all we need to provide is a the fields for the `ValidatorPrefs` object. (Any fields not defined will be set to the default for that type, i.e. all zero). This object maps through to what is defined on the Polkadot/Substrate side, with the [@polkadot/types version](https://github.com/polkadot-js/api/blob/master/packages/types/src/interfaces/staking/definitions.ts) mapping all fields.
## Understanding types
As has been very apparent in all the preceding sections, the management of types is what allows the API to communicate with the node. Most values are in a [binary SCALE-encoded format](https://github.com/paritytech/parity-scale-codec) and it is the responsibility of the API is to encode and decode these. In the next section we will [take a look at what interfaces the API provides around types](types.basics.md).
+36
View File
@@ -0,0 +1,36 @@
# Basics & Metadata
One of the most important things to understand about the `@polkadot/api` is that most interfaces are actually generated automatically when it connects to a running node. This is quite a departure from other APIs in projects where the interfaces are static. While sounding quite scary, it actually is a powerful concept that exists in both Polkadot and Substrate chains, and allows the API to be used in environments where the chain is customized.
To unpack this, we will start with the Metadata and explain what it actually provides, since it is critical for understanding how to interact with the API and any underlying chain.
## Metadata
When the API connects to a node, one of the first things it does is to retrieve the metadata and decorate the API based on the metadata information. The metadata effectively provides data in the form of `api.<type>.<module>.<section>` that fits into one of the following categories -
- [consts](../substrate/constants.md) - All runtime constants, e.g. `api.consts.balances.existentialDeposit`. These are not functions, rather accessing the endpoint immediately yields the result as defined.
- [query](../substrate/storage.md) - All chain state, e.g. `api.query.system.account(<accountId>)`.
- [tx](../substrate/extrinsics.md) - All extrinsics, e.g. `api.tx.balances.transfer(<accountId>, <value>)`.
Additionally the metadata also provides information on [events](../substrate/events.md), these are query-able via the `api.query.system.events()` interface and also appear on transactions... both these cases are detailed later.
None of the information contained within the `api.{consts, query, tx}.<module>.<method>` endpoints are hard coded in the API. Rather everything is fully decorated by what the metadata exposes and is therefore completely dynamic. This means that when you connect to different chains, the metadata and API decoration will change and the API interfaces will reflect what is available on the chain you are connected to.
## Types
The metadata defines the calls with all the type names used in the various interfaces. At the moment (this is undergoing investigations and could improve in future versions of metadata), this also means that the types between the API and the node need to be aligned. For instance, by default Substrate defines a `BlockNumber` type as a `u32` and the API follows the Substrate defaults - if a chain has a different definitions, the API needs to be aware of this so it can actually decode (and encode) the type.
At this point just be aware of it, we will touch on types, custom chains and their impacts in a later section.
## Chain Defaults
In addition to the `api.[consts | query | tx]` detailed above, the API, upon connecting to a chain, fills in some information and makes it available directly on the API interface. These include -
- `api.genesisHash` - The genesisHash of the connected chain
- `api.runtimeMetadata` - The metadata as retrieved from the chain
- `api.runtimeVersion` - The chain runtime version (including spec/impl. versions and types)
- `api.libraryInfo` - The version of the API, i.e. `@polkadot/api v0.90.1`
## Let's do something!
Now that we have covered what the API actually exposes, it is time to [dive in and actually use what we installed earlier](create.md).
+85
View File
@@ -0,0 +1,85 @@
# Create an instance
We have the API installed, we have an understanding of what will actually be exposed and how the API knows what to expose. So down the rabbit hole we go - let's create an actual API instance, and then take it from there -
```js
// Import
import { ApiPromise, WsProvider } from '@polkadot/api';
...
// Construct
const wsProvider = new WsProvider('wss://poc-3.polkadot.io');
const api = await ApiPromise.create({ provider: wsProvider });
// Do something
console.log(api.genesisHash.toHex());
```
We will have some explanation on the ES2015 syntax used next, but just a small note on the above - where other code is included (or just some previous boilerplate is used), you will see `...` in most of the examples. This is not due to laziness, but rather just to keep things straight and to the point.
## ES2015 Usage and examples
Before we jump into an explanation of the above example, be aware that in all cases we are using ES2015, including using things like `async`/`await`, `import` and others. Depending on your environment, this may require some adjustments.
While we are using the `await` naked in all examples (this removes boilerplate), it will need to be wrapped in an `async` block, for we could warp all samples inside a `async function main () { ... }` and then just call `main()`.
In the case of Node.js you would change the `import` into `require`, i.e.
```js
// Import
const { ApiPromise, WsProvider } = require('@polkadot/api');
...
```
We are basing all our examples on the [ApiPromise](../examples/promise/README.md) version of the API, however there is also an RxJS version available. Since Promises are a part of the ES2015 specification, it covers the greater amount of use and is the one that will be used in 95% of the cases and should be familiar to 100% of all developers. However if you are in an environment where RxJs is recommended or your have a great affinity ot it, you could take a look at the [RxJS examples](../examples/rx/README.md) once you are familiar with the base concepts introduced here.
For now... just ignore the various flavors and focus on understanding the concepts.
## Providers
Focusing on the construction, any API requires a provider and we create one via the `const wsProvider = new WsProvider(...)`. By default, if none is provided to the API it will construct a default `WsProvider` instance to connect to `ws://127.0.0.1:9944`.
We generally recommend always specifying the endpoint since in most cases we want to connect to an external node and even for local nodes, it is always better being explicit, less magic that can make you wonder in the future.
At this time the only provider type that is fully supported by the API is the WebSocket version. Polkadot/Substrate really comes alive with possibilities once you have access to bi-directional RPCs such as what WebSockets provide. (It is technically possible to have some limited capability via bare-HTTP, but at this point WebSockets is the only fully-operational and supported version - always remember that it is just "upgraded HTTP".)
## API Instance
The API creation is done via the `ApiPromise.create` interface which is a shortcut version for calling `new` and then waiting until the API is connected. Without the `async` syntax, this would be,
```js
ApiPromise
.create({ provider: wsProvider })
.then((api) =>
console.log(api.genesisHash.toHex())
);
```
In most cases we would suggest using the `.create` shortcut, which really just takes care of the following boilerplate that otherwise needs to be provided -
```js
// Create the instance
const api = new ApiPromise({ provider: wsProvider });
// Wait until we are ready and connected
await api.isReady;
// Do something
console.log(api.genesisHash.toHex());
```
## Failures
In all cases the API will handle reconnections automatically. This means that when you connect and the endpoint is not (yet) ready, the promise will not resolve immediately, but rather when connected. The same applies to when connection is lost, the API will manage re-connections.
In cases where the API does not support the chain being connected to, such as it using an unknown metadata version, the ready promise will fail to resolve and instead reject.
## Advanced creation
There are more advanced cases where you would prefer to use the longer version, for instance: if you want to explicitly listen to events emitted, you probably want to attach to the API even before connecting to the chain. All API instances implement an `EventEmitter` interface, with `on` handlers, which emit `connected`, `disconnected`, `ready` and `error` events, allowing you to listen to events on the transport layer.
In these cases, create via `new`, attach listeners and then wait for the `isReady`.
## Do something
Now that we have the API initialized, the next step would be to start using it to interact and extract data [starting with chain constants](api.consts.md).
+27
View File
@@ -0,0 +1,27 @@
# Installation
Yes, it really is as simple as [installing from npm](https://www.npmjs.com/package/@polkadot/api), so we are not going to waste too much time with the bare basics, just install the API via
`yarn add @polkadot/api`
And it will be added and ready for use. The above will always install the latest stable release, which should allow you to connect to test networks and local nodes that are tracking versioned releases for [Polkadot](https://github.com/paritytech/polkadot) and [Substrate](https://github.com/paritytech/substrate).
## Betas
For users who have a slightly higher appetite for risk, or are using bleeding-edge master branches of either Polkadot/Substrate, we also publish a beta version as soon as anything is merged into the API master branch. This version really contains all the latest fixes and features and is the version we actually use inside the polkadot-js projects - eating our own dog food.
To install a beta version, either to test or for support of a feature that is available in Substrate master (and has not yet made it to a stable api release), you can install it via the `@beta` tag, i.e.
`yarn add @polkadot/api@beta`
## Other dependencies
In most cases, you don't need to do anything else apart from just installing `@polkadot/api` above. It has dependencies such as `@polkadot/types` which are installed automatically alongside. When using `yarn` the dependencies are installed, flattened, available for use and you will never run into issues with mismatched versions.
This means that by simply installing `@polkadot/api`, you will have access to utilities (crypto and normal), types, providers and even higher-order (derived) API functions. (We will get to all of these in follow-up sections)
If you do however decide to explicitly install other packages (even though they are dependencies), please make sure that the versions inside the api package always match with your versions, i.e. if you installed `@polkadot/api` `0.91.0-beta.22` and you have your own version of `@polkadot/types`, ensure that it is also `0.91.0-beta.22`.
## API basics
So we have it installed. Before we jump into actual real-world usage, [let's understand what the API gives us](basics.md).
+119
View File
@@ -0,0 +1,119 @@
# Keyring
This section will give a quick introduction into the Keyring, including the addition of accounts, retrieving pairs and the signing of any data. Unlike the rest of the API, only the core concepts will be covered with the most-used-functions. However, what is covered is enough for 99.9 of the use-cases ... or rather, that is the aim.
## Installation
They [@polkadot/keyring](https://github.com/polkadot-js/common/tree/master/packages/keyring) keyring is included directly with the API as a dependency, so it is directly importable (since the 0.92 version) alongside the API.
If you do opt to install it separately, ensure that the version of `@polkadot/util-crypto` that is included with the API matches with the version of `@polkadot/keyring` installed. So if the API depends on `util-crypto 1.4.1`, it would make sense to include `keyring 1.4.1` as the installed version. (This helps in making sure extra versions of the libraries are not included as duplicates, especially in the case where bundles are created. Additionally, this makes sure that weird side-effects in the WASM initialization is avoided.)
## Creating a keyring instance
Once installed, you can create an instance by just creating an instance of the `Keyring` class -
```js
// Import the keyring as required
import { Keyring } from '@polkadot/api';
// Initialize the API as we would normally do
...
// Create a keyring instance
const keyring = new Keyring({ type: 'sr25519' });
```
In the above example, the import is self-explanatory. Upon creation we pass through a `type` which can have a value of either `ed25519` or `sr25519`, when not specified this would default to `ed25519`. This type parameter only applies to the default type of account created when no type is specified, it does not mean that the keyring can only store that type of account.
So effectively, when creating an account and not specifying a type, it will be `sr25519` by default based on the above construction params, however we can also add an `ed25519` account and use it transparently in the same keyring.
One "trick" that is done implicitly in the above sample is that that keyring is only initialized after the API. In the case of `sr25519` the keyring relies on a [WASM build](https://github.com/polkadot-js/wasm) of the [schnorrkel libraries](https://github.com/w3f/schnorrkel). Since the API inlitialization is already async, it initializes the WASM libraries are part of the setup.
However, this initialization can also be done explicitly, mostly for more advances use-cases, or in cases where the API won't be attached until much later -
```js
// Crypto promise, package used by keyring internally
import { cryptoWaitReady } from '@polkadot/util-crypto';
// Wait for the promise to resolve, async WASM or `cryptoWaitReady().then(() => { ... })`
await cryptoWaitReady();
// Create a keyring instance
const keyring = new Keyring({ type: 'sr25519' });
```
## Adding accounts
The recommended catch-all approach to adding accounts is via `.addFromUri(<suri>, [meta], [type])` function, where only the `suri` param is required. For instance to add an account via mnemonic, you would do the following -
```js
...
// Some mnemonic phrase
const PHRASE = 'entire material egg meadow latin bargain dutch coral blood melt acoustic thought';
// Add an account, straight mnemonic
const newPair = keyring.addFromUri(PHRASE);
// (Advanced) add an account with a derivation path (hard & soft)
const newDeri = keyring.addFromUri(`${PHRASE}//hard-derived/soft-derived`);
// (Advanced, development-only) add with an implied dev seed and hard derivation
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
```
The above additions cater for most of the use cases and aligns with the you would find in the Substrate `subkey`. Be very wary of the last "dev-seed" option, it is explicitly added for `subkey` compatibility and implies using the "known-everywhere" dev seed. It is however useful when running Polkadot/Substrate with a `--dev` flag.
## Adding accounts with raw seeds
Since mnemonics are recommended and the defacto standard for current Polkadot/Substrate generations, the only mentioned way of adding keys thus far has been via mnemonic. However, the `addFromUri` method on the keyring is intelligent enough to detect and add from inputs specified as mnemonics, hex seeds and string seeds (appropriately padded).
With the above in mind, we could extend our examples above for custom raw seed. For instance to add both a hex and string seed, we can follow the following approach -
```js
...
// add a hex seed, 32-characters in length
const hexPair = keyring.addFromUri('0x1234567890123456789012345678901234567890123456789012345678901234');
// add a string seed, internally this is padded with ' ' to 32-bytes in length
const strPair = keyring.addFromUri('Janice');
```
You could extend derivation from these specified seeds with derivation paths if applicable, i.e. `Janice//hard` will perform a hard derivation with the path `hard` on the pair that is generated from the `Janice` seed. As far as possible, try to stick with mnemonics in your applications, unless you have a good reason to not do so. Humans are generally bad at generating their own entropy and mnemonics has additional properties such as built-in checksums.
## Working with pairs
In the previous examples we added a pair to the keyring (and we actually immediately got access to the pair). From this pair there is some information we can retrieve -
```js
...
// Add our Alice dev account
const alice = keyring.addFromUri('//Alice', { name: 'Alice default' });
// Log some info
console.log(`${alice.meta.name}: has address ${alice.address} with publicKey [${alice.publicKey}]`);
```
Additionally you can sign and verify using the pairs. This is the same internally to the API when constructing transactions -
```js
// Some helper functions used here
import { stringToU8a, u8aToHex } from '@polkadot/util';
...
// Convert message, sign and then verify
const message = stringToU8a('this is our message');
const signature = alice.sign(message);
const isValid = alice.verify(message, signature);
// Log info
console.log(`The signature ${u8aToHex(signature)}, is ${isValid ? '' : 'in'}valid`);
```
This covers the keyring basics, however there are two additional functions here of interest, `keyring.getPairs()` to retrieve a list of all pairs in the keyring and `keyring.getPair(<address or publicKey>)` to retrieve a pair where we have an identifier.
## Back to transactions
Now that we have short introduction to the keyring, we can move back to API transactions and find out [how to subscribe and track events](api.tx.subs.md), taking our management of transactions to the next level.
+86
View File
@@ -0,0 +1,86 @@
# Type basics
We've touched upon types in most previous sections, i.e. that these are driven by metadata and that they are created and converted to/from automatically by the API. Since they appear in all results, we will divert a bit from the regularly scheduled program in explaining the API interfaces to giving some info on the base types.
## Everything is a type
Just to re-iterate from the above. Everything returned by the API is a type and has a consistent interface. This means that a `Vec<u32>` (an array of `u32` values) as well as a `Struct` (an pre-defined object) or an `Enum` has the same consistent base interface. Specific types types will have values, based on the type - decorated and available.
As a minimum, anything returned by the API, be it a `Vec<...>`, `Option<...>`, `Struct` or any normal type will always have the following methods -
- `.eq(<other value>)` - checks for equality against the other value. In all cases, it will accept "like" values, i.e. in the case of a number you can pass a primitive (such as `1`), a hex value (such as `0x01`) or even an `Unit8Array`
- `toHex()` - returns a hex-base representation of the value, always prefixed by `0x`
- `toJSON()` - returns a JSON-like representation of the value, this is generally used when calling `JSON.stringify(...)` on the value
- `toString()` - returns a string representation, in some cases this performs additional encoding, i.e. for `Address`, `AccountId` and `AccountIndex` it will encode to the ss58 address
- `.toU8a()` - returns a `Uint8Array` representation of the encoded value (generally exactly as passed to the node, where values are SCALE encoded)
Additionally, the following getters and utilities are available -
- `.isEmpty` - `true` if the value is an all-empty value, i.e. `0` in for numbers, all-zero for Arrays (or anything `Uint8Array`), `false` is non-zero
- `.hash` - a `Hash` (once again with all the methods above) that is a `blake2-256` representation of the contained value
## Comparing types
To reiterate the above API, the `.eq` method is the preferred means of comparing base types, rather than the JavaScript equality operator (`===`).
For example:
```js
const { metadata } = await api.rpc.state.getMetadata();
const modules = metadata.asLatest.modules;
// This will not work, because `name` is an instance of `Text`, not a string
// const system = modules.find(m => m.name === 'system');
// This will work, because `Text.eq()` can compare against a string
const system = modules.find(m => m.name.eq('system'));
```
## Working with numbers
All numbers wrap and extend an instance of [bn.js](https://github.com/indutny/bn.js/). This means that in addition to the interfaces defined above, they have some additional methods -
- `.toNumber()` - a JS number (limited to 2^53 - 1). This does mean that for large values, e.g. `Balance` (a `u128` extension), this can cause overflows
- `.add(...)`, `.sub(...)`, ... - all the base methods available on the `BN` object
In cases where a `Compact` is returned, i.e. `Compact<Balance>`, the value is wrapped. This object should be `.unwrap()`-ed first to gain access to the underlying `Balance` object.
## Working with structures
All structures, a wrapping of an object containing a number of member variables, is an implementation of a standard JS `Map` object, so all the functions available on a `Map` such as `.entries()` are available. Additionally it is decorated with actual getters for the fields.
As an example, a `Header` will have getters for the `.parentHash`, `.number`, `.stateRoot`, `.extrinsicsRoot` and `.digest` fields. The same applies for all structures, as they are returned, each member will have an associated getter.
Be aware that in the JS version naming defaults to `camelCase` where names of fields in Substrate defaults to `snake_case`. (Each version aligning with conventions in the respective languages)
## Working with enums
Each enum has additional getters which are injected based on the fields wrapped. These take the form of `.is<Name>` and `.as<Name>` to allow you to check is the enum is a certain value or to retrieve the underlying value as a specific type.
As a real-world example, when an extrinsic is applied, the `Phase` enum has one of two states, `ApplyExtrinsic(u32)` or `Finalization`. In this case `.isApplyExtrinsic` would be `true` when an extrinsic is being applied, and `.asApplyExtrinsic` would return the value as a `u32` (which is the index of the extrinsic in the block, as it is being applied). When `isisApplyExtrinsic` is `false` and `asApplyExtrinsic` is called, the getter will throw.
## Working with Option&lt;Type&gt;
An `Option<Type>` attempts to mimic the Rust approach of having `None` and `Some` available. This means the following getters & methods are available on an `Option` -
- `.isNone` - is `true` if no underlying values is wrapped, effectively the same as `.isEmpty`
- `.isSome` - this is `true` is a value is wrapped, i.e. if a `Option<u32>` has an actual underlying `u32`
- `.unwrap()` - when `isSome`, this will return the wrapped value, i.e. for `Option<u32>`, this would return the `u32`. When the value is `isNone`, this call will throw an exception.
- `.unwrapOr(<default value>)` - this extends `unwrap()`, returning the wrapped value when `isSome` and in the case of `isNone` it will return the `<default value>` passed.
## Working with Tuples
A tuple is defined in the form of `(u32, AccountId)`. To access the individual values, you can access t via the index, i.e.
```js
// Assuming a tuple defined as `(32, AccountId)`
const [count, accountId] = tuple;
console.log(`${accountId} has ${count.toNumber()} values`);
```
When making a call that expect a `Tuple` input, pass it as an array, so to pass the example above into a call, it would be `.call([123, '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'])`
## Extending types
For customized chains, the need exists to register types so the API is aware of how to decode values for those types. The next section will provide a [walk-through for the definition of custom types](types.extend.md) allowing the definition or re-definition of any type the API is aware of.
+56
View File
@@ -0,0 +1,56 @@
# Type creation
Circling back to metadata. There are two important things to remember when using the API to make queries or send transactions.
1. The functionality available, e.g. exposed on `api.query.*` is not hard-coded in the API, rather this is decorated from the chain metadata. So the metadata lets the API know which endpoints are available and what the type for those endpoints are.
2. When you supply a value to the API, internally it will convert that value to the correct type as expected by the chain, i.e. as determined by the metadata. This means that a function such as `balances.transfer(address: Address, value: Balance)` can take at least the following inputs, which are all converted to the correct types -
- `address` can be an `Address`, an `AccountId`, an `Uint8Array` publicKey, a hex publicKey or an ss58 formatted address;
- `value` can be a `Balance`, a value encoded in hex, a `BN` object, a base-10 string, a JS `number`, a JS `BigInt` or even a SCALE-encoded `Uint8Array`
In cases where a value is returned such as storage queries, the response from the chain is always encoded into the correct `Codec` type. This means that while the node may return an encoded block (with encoded extrinsics) via `api.rpc.chain.getBlock()`, this is decoded into a proper `SignedBlock` by the API. Outputting this value via `.toJSON()` will yield an encoding for RPC, so if you are not using TypeScript (which adds code helpers on decoded objects), a representation via `.toHuman()` will be more representative of the actual object fields, re-formatted for human consumption.
## Why create types
With the conversions done in the API, there are limited reasons to create types "manually". However, just because there are not thousands of reasons, does not mean it is not valid. For instance, you may retrieve an `Option` and for the sake of sanity would like to use `.unwrapOr()` on it, returning a `Codec` default value where the value `.isNone`.
```js
// type import for TypeScript
import type { Balance } from '@polkadot/types/interfaces';
...
// unwrap out option into a zero Balance whn not found
// (This can be done via `.unwrapOrDefault()`, which does the same underlying)
const balance: Balance = balanceOpt.unwrapOr(api.createType('Balance'));
```
In the example above, we introduced the `api.createType(<typeName>, [<value>])`. The same format is also exposed by the `TypeRegistry` (more on this in a short while) as well as `createType(...)` from the actual `@polkadot/types` package. All doing exactly the same.
## Choosing how to create
In most cases, you would always want to use the `api.createType` helper. What this does is call the underlying `@polkadot/types` `createType`, passing through the registry that is attached to the API. Registry? Yes, registry.
The registry contains a listing of all internal types and their classes that have been registered. So upon creation of an API instance, a `registry` object is attached to the API and this is passed through to all created types. This allows the type definitions to not pollute the global namespace, but rather be contained and able to reference one another.
As mentioned, the `createType` functions all do exactly the same, and it 99.99% of the cases you would be recommended to just forget about everything and use `api.createType` if and when required. In some cases, you may just have a type object and from that want to create another type instance. For that you can access the `registry` on the type object and call `createType` on it. (If this type object was created from an API instance, the registry on the type and on the API will point to the same instance.)
Basically, this means that we have equivalency in creation for all the items below, all creating on the same registry (containing all injected types), and all wrapping the same value -
```js
import { createType } from '@polkadot/types';
// via API (recommended)
api.createType('Balance', 123);
// via registry (`.registry` is on all API and Codec objects)
api.registry.createType('Balance', 123n);
// via the low-level approach (not recommended)
createType(api.registry, 'Balance', '123');
```
## Using with TypeScript
The API is built with TypeScript (as are all projects in the [polkadot-js organization](https://github.com/polkadot-js/)) and as such allows developers using TS to have access to all the type interfaces defined on the chain, as well as having access to typings on interacting with the `api.*` namespaces. In the next section we will provide an overview of [what is available in terms of types and TypeScript](typescript.md).
+206
View File
@@ -0,0 +1,206 @@
# Extending types
Circling back to metadata, by default the metadata information (at this point in time), only returns the type names as they apply to any section, be it a call, event or query. As an example, this means that transfers are defined as `balances.transfer(AccountId, Balance)` with no details as to the mapping of the `Balance` type to a `u128`. (The underlying Polkadot/Substrate default)
Therefore to cater for all types, a mapping in done on the [@polkadot/types library](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces) to define each of the types and align with their underlying structures as it maps to a default Polkadot or Substrate chain.
Additionally, the API contains some logic for chain type detection, for instance in the case of Substrate 1.x based chains, it will define `BlockNumber` & `Index` (nonce) as a `u64`, while for current-generation chains, these will be defined as `u32`. Some of the work in maintaining the API for Polkadot/Substrate is the addition of types as they appear and gets used in the Rust codebase.
There is a the [recommendation](install.md#betas) to use a `@polkadot/api@beta` should you wish to track the master branches of Polkadot or Substrate, since master changes for the addition of new types do not make it into a stable release immediately.
## Extension
As a blockchain toolkit, Substrate makes it easy to add your own modules and types. In most non-trivial implementations, this would mean that developers are adding specific types for their implementation as well. The API will get to know the names of these types via the metadata, however it won't understand what they are, which means it cannot encode or decode them. Additionally, when a type is mismatched between the node and the API, the decoding can fail, yielding issues such as [Could not convert errors](FAQ.md#the-node-returns-a-could-not-convert-error-on-send) when submitting transactions.
To close this gap, the API allows for the injection of types, i.e. you can explicitly define (or override) types for the node/chain you are connecting to. In the simplest example, assuming you have a chain where your `Balance` type is a `u64` (as opposed to the default `u128`), you need to let the API know -
```js
...
const api = await ApiPromise.create({
provider: wsProvider,
types: {
Balance: 'u64'
}
});
```
The above introduces the `types` registry, effectively allowing overrides and the definition of new types. The override above would mean that immediately the API will treat all occurrences of `Balance` not as the default, but rather as the defined size.
## User-defined structs
Registration also applies to any type that can be found on a specific chain, i.e. we can add any types that is available on a specific node -
```js
...
const api = await ApiPromise.create({
...,
types: {
TransactionInput: {
parentOutput: 'Hash',
signature: 'Signature'
},
TransactionOutput: {
value: 'u128',
pubkey: 'Hash',
sale: 'u32'
},
Transaction: {
inputs: 'Vec<TransactionInput>',
outputs: 'Vec<TransactionOutput>'
}
}
})
```
The example above defines non-primitive types (as found in the specific implementation) as structures. Additionally it also shows the user-defined types can depend on other user-defined types with `Transaction` referencing both `TransactionInput` and `TransactionOutput`. Here you can reference any known types, i.e. in the above we have referenced primitives such as `u32` and `Signature` (itself an alias for `H512`).
## Definition clashes
As explained in a previous section, the underlying API Codec types have a [number of built-in properties](type.basics.md) and in some cases it could be that your struct has a field that conflicts. These should be minimal, however it can happen. Take the following example where a defined `hash` property clashes with the same-name Codec property -
```js
Document: {
name: 'Text',
uri: 'Text',
hash: 'Text'
}
```
For this struct the `hash` will not be exposed, but rather be kept as the built-in `hash`. At this point it is important to know that the values "over-the-wire" for calls, queries, events and consts is in binary form, i.e. it is an encoding of the values only. So on the JS side you can apply a rename with no ill-effects. Here we rename the `hash` to `docHash`, which mean the value will be available on `<instance>.docHash`.
```js
Document: {
name: 'Text',
uri: 'Text',
docHash: 'Text'
}
```
## User-defined enum
One form of types that appear regularly is enums, these can be defined as follow -
```js
...
const api = await ApiPromise.create({
...,
types: {
CLikeEnum: {
_enum: ['One', 'Two', 'Three']
},
TypedEnum: {
_enum: {
One: 'Compact<u32>',
Two: 'u64',
Three: 'Option<Balance>',
Four: null
}
}
}
});
```
As seen in these examples, types are built up in terms of primitives and aligns with the Rust-type definition model with `Compact`, `Option` and `Vec`.
## Node and chain-specific types
There are cases where a single API object can be used to connect to different types of nodes or chains, each including their own specific types. For these cases the `typesChain` and `typesSpec` injectors are made available.
As a real-world example, the [polkadot-js/apps UI](https://github.com/polkadot-js/apps) can connect to a variety of chains. To support [Edgeware](https://edgewa.re/) by default, the following node-type (`specName` as per the runtime version) overrides are made -
```js
import { IdentityTypes } from 'edgeware-node-types/dist/identity';
import { SignalingTypes } from 'edgeware-node-types/dist/signaling';
import { VotingTypes } from 'edgeware-node-types/dist/voting';
...
const api = await ApiPromise.create({
...,
typesSpec: {
edgeware: {
...IdentityTypes,
...SignalingTypes,
...VotingTypes
}
}
});
```
In the same way `typesChain` can be used to match on the actual chain name, i.e. for a chain such as Kusama, the following overrides can be made (as per example only - Kusama uses the Polkadot defaults, so no overrides are needed) -
```js
...
const api = await ApiPromise.create({
...,
typesChain: {
Kusama: {
BlockNumber: 'u32',
Index: 'u32'
}
}
});
```
The `types`, `typesChain` and `typesSpec` overrides are all optional and all are applied, as applicable to a specific connection. From the options `types` are registered first, followed by `typesSpec` for node-specific overrides and finally `typesChain` for chain-specific overrides. The would mean is you have the following (contrived) example,
```js
...
const api = await ApiPromise.create({
...,
types: {
Balance: 'u32',
}
typesChain: {
Balance: 'u128'
},
typesSpec: {
Balance: 'u64',
}
});
```
`Balance` would be defined as an `u128` at the end. Effectively based on the flow it is first registered as a `u32`, then overridden as a `u64` and finally overridden once more as a `u128` by the chain types.
## Impact on extrinsics
When configuring your chain, be cognizant of the types you are using, and always ensure that any changes are replicated back to the API. In an earlier example we configured `Balance` as `u64`, in this case the same changes needs to be applied on the API, especially when there are mismatches compared to Substrate master. Not doing so means that failures will occur. The same would happen when your own types have mismatched fields or types are lacking fields on structs or enums.
Mismatches also applies to any other chain-specific configured types and can have impacts on transactions. For instance you can customize `Lookup` and `Address` on your chain, changing the default lookup behavior. A real example of this is the Substrate master node vs the Substrate master node-template -
```rust
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = Indices;
...
/// The address format for describing accounts.
pub type Address = <Indices as StaticLookup>::Source;
```
And this is what is defined on the node-template -
```rust
/// The lookup mechanism to get account ID from whatever is passed in dispatchers.
type Lookup = IdentityLookup<AccountId>;
...
/// The address format for describing accounts.
pub type Address = AccountId;
```
Here the template was customized from the Substrate node defaults and the API needs to know how to map these types. Failure to make adjustments means transactions will fail. With this in mind the correct types that needs to be added here would be -
```js
const api = await ApiPromise.create({
...,
types: {
// mapping the actual specified address format
Address: 'AccountId',
// mapping the lookup
LookupSource: 'AccountId'
}
});
```
Always look at customization and understand the impacts, replicating these changes between the node and the API. For the above the `Address` type is used in the construction of the `UncheckedExtrinsic` type, while the lookup type is applicable on transactions such as `balances.transfer(to: LookupSource, value: Balance)`
## Type creation
While the API always converts all the inputs into the underlying type required by the operation, in some cases you may want to [create an instance of a type](types.create.md) yourself.
+45
View File
@@ -0,0 +1,45 @@
# TypeScript interfaces
The API is written in TypeScript, and as such definitions for all actual exposed interfaces are available. In general terms, care has been taken to expose types via a `@polkadot/<package>/types` interface, for instance the `ApiOptions` type which is passed through on the `.create` interface is available under `@polkadot/api/types`.
## RPC interfaces
Before getting to the "hard things", i.e. methods as decorated based on metadata interfaces, let's take a look at more "static" interfaces such as RPC. (Be aware though that these can be customized on a per-chain basis as well - for now this functionality is not reflected in the API itself).
```js
import { Header } from '@polkadot/types/interfaces';
...
const firstHead = api.rpc.chain.getHeader();
api.rpc.chain.subscribeNewHeads((lastHead: Header): void => {
console.log('current header:', JSON.stringify(lastHead));
});
```
In the above example a couple of things are introduced - most of the chain definitions (the default types for both Polkadot & Substrate) can be imported as interfaces from the `@polkadot/types/interfaces` endpoint. These are not classes (since they are [generated from definitions](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces)) but rather a combination of TypeScript `interfaces` (where structures are involved) and `type`, i.e. `type Balance = u128`.
In the subscription example, we explicitly define `lastHead: Header`, although the same definition is missing for `firstHead`. However, in both these cases the definitions for the `api.rpc` sections are such that TypeScript understands that `firstHead` and `lastHead` are of type `Header`. The `: Header` here is rather for our own understanding (and could be needed based on your eslint/tslint config).
As indicated, most of the Polkadot/Substrate default types are available via `types/interfaces`. However, for primitives types where there is an actual implementation, these are made available via `@polkadot/types` directly. For instance, `import { u32 } from '@polkadot/types` is valid in this context.
## Storage generics
For any interface injected by metadata, the types are not fully described but rather names and the API will decode all these into an instance that complies with the `Codec` interface. (The base of all our types)
However, this does allow you to perform overrides via generics, making the following possible -
```js
import { Balance } from '@polkadot/types/interfaces';
type Balance2 = Balance;
...
const total = await api.query.balances.totalIssuance<Balance2>();
```
In this example (although the query does indeed return a `Balance`) we can instruct the TypeScript compiler that we are expecting a `Balance2`, not just the interface as generated. This means that functions like `.toNumber()` is available on both these types - as opposed to just the [general type defaults](types.basics.md#everything-is-a-type) with `.toHex()` and friends.
## Adding user types
In addition to the generated and available interfaces, there is also the ability to [create TypeScript interfaces from your own definitions and well as your on-chain modules](typescript.user.md).
+30
View File
@@ -0,0 +1,30 @@
# TypeScript user generated
In the previous section we looked at the TypeScript definitions that are available and is generated from both the chain and definitions. Here we will expand upon the use of the infrastructure created to define types as part of the `@polkadot/types` library and see how to use them to generate your onw definitions and chain types.
## Definitions
A large part of the type definitions are defined not as classes, but rather as structures from which type definitions are extracted and that can be used as-is to let the API know how to decode a type. By now you should be familiar with [type extensions](types.extend.md), but effectively the [types library does exactly the same](https://github.com/polkadot-js/api/tree/master/packages/types/src/interfaces).
To create TypeScript-aware definitions and keep your files in a single place, you can follow the same approach. Assuming you have a package named `@MeInc/stuff` where you have the definitions in an `stuff/interfaces` folder. Each sub-folder would indicate a runtime module, e.g.
- `stuff/interfaces/<module>/definitions.ts` for each module (`types.ts` & `index.ts` will be generated)
- `stuff/interfaces/definitions.ts` importing all sub-definitions`
With this structure setup, you can generate TypeScript definitions.
In the root of your project (with the `@polkadot/typegen` package installed), you can run `yarn polkadot-types-from-defs --input ./stuff/interfaces --package @MeInc/stuff/interfaces` which will create `types.ts` and `index.ts` files with the generated types. You can use these in exactly the same way as you would use your types from `@polkadot/types/interfaces`.
## Chain modules
In the same way as the type library provides defaults from a substrate-base chain, you can also, directly from chain from metadata, generate a complete `api.{consts,query}.*` definition for your specific chain. The command will create 2 files, `{consts, query}.types.ts` which you can either use to augment the TypeScript definitions, or replace those in `@polkadot/api/*` with your versions (copy, TypeScript replacement or browser/node aliasing).
In the root of your project, you can run `yarn polkadot-types-from-chain --endpoint wss://<url> --output ./stuff` and it will create the required output. (Here you can specify an optional `--package @MeInc/stuff` to read definitions for the targeted output folder with the specified package name.)
## Example of actual use
The [TypeScript augmentation example](../examples/promise/90_typegen/) example provides a full real-world example of these scripts in action. Additionally it shows all the configurations from a TypeScript as well as an in-use perspective, showing how the types and interfaces are fully augmented based on the provided metadata.
## And that's a wrap
This brings us to the end of our overview and jump through the API. While the documentation is still very much and ever evolving item, we can encourage you to try out what you have learned with some [examples](../examples). As we [indicated right at the start of this journey](README.md#help-us-help-others), if there are areas for improvement, let us know.
+3
View File
@@ -0,0 +1,3 @@
# Substrate
As part of a running node, some information is exposed as part of the metadata.
+26
View File
@@ -0,0 +1,26 @@
{
"name": "substrate",
"description": "These are keys that are always available to the runtime implementation",
"items": [
{
"name": "changesTrieConfig(): `u32`",
"summary": "Changes trie configuration is stored under this key."
},
{
"name": "childStorageKeyPrefix(): `u32`",
"summary": "Prefix of child storage keys."
},
{
"name": "code(): `Bytes`",
"summary": "Wasm code of the runtime."
},
{
"name": "extrinsicIndex(): `u32`",
"summary": "Current extrinsic index (u32) is stored under this key."
},
{
"name": "heapPages(): `u64`",
"summary": "Number of wasm linear memory pages required for execution of the runtime."
}
]
}
+6 -5
View File
@@ -6,20 +6,20 @@ module.exports = Object.assign({}, config, {
moduleNameMapper: {
'@polkadot/api-contract(.*)$': '<rootDir>/packages/api-contract/src/$1',
'@polkadot/api-derive(.*)$': '<rootDir>/packages/api-derive/src/$1',
'@polkadot/api-metadata(.*)$': '<rootDir>/packages/api-metadata/src/$1',
'@polkadot/api(.*)$': '<rootDir>/packages/api/src/$1',
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/jsonrpc/src/$1',
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
'@polkadot/jsonrpc(.*)$': '<rootDir>/packages/type-jsonrpc/src/$1',
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
},
modulePathIgnorePatterns: [
'<rootDir>/packages/api/build',
'<rootDir>/packages/api-derive/build',
'<rootDir>/packages/api-contract/build',
'<rootDir>/packages/api-metadata/build',
'<rootDir>/packages/jsonrpc/build',
'<rootDir>/packages/metadata/build',
'<rootDir>/packages/rpc-core/build',
'<rootDir>/packages/rpc-provider/build',
'<rootDir>/packages/type-jsonrpc/build',
'<rootDir>/packages/types/build'
],
globals: {
@@ -31,5 +31,6 @@ module.exports = Object.assign({}, config, {
ws_local_polkadot_alex: 'ws://127.0.0.1:9949/',
ws_substrate_1: 'wss://substrate-rpc.parity.io/',
ws_polkadot_alex: 'wss://poc3-rpc.polkadot.io/'
}
},
resolver: './jest.resolver.js'
});
+14
View File
@@ -0,0 +1,14 @@
// Copyright 2017-2020 @polkadot/util authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
module.exports = function resolver (file, config) {
if (file.includes('package.json')) {
return path.join(config.basedir.replace('/src', '/'), file);
}
return config.defaultResolver(file, config);
};
+1 -1
View File
@@ -9,5 +9,5 @@
"packages": [
"packages/*"
],
"version": "0.90.1"
"version": "1.5.1"
}
+19 -25
View File
@@ -1,39 +1,33 @@
{
"version": "0.90.1",
"repository": "https://github.com/polkadot-js/api",
"author": "Jaco Greeff <jacogr@gmail.com>",
"license": "Apache-2",
"private": true,
"engines": {
"yarn": "^1.10.1"
},
"workspaces": [
"packages/*"
],
"resolutions": {
"babel-core": "^7.0.0-bridge.0",
"typescript": "^3.5.3"
"typescript": "^3.8.3"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts && yarn run build:methodsdoc && polkadot-dev-build-docs",
"build:htmldoc": "yarn clean && typedoc --theme default --out docs/html",
"build:interfaces": "node packages/types/src/scripts/interfacesTsWrapper.js",
"build:methodsdoc": "node packages/types/src/scripts/MetadataMdWrapper.js",
"check": "yarn lint",
"lint": "eslint --ext .js,.jsx,.ts,.tsx . && tsc --noEmit --pretty",
"build": "yarn build:interfaces && polkadot-dev-build-ts && (cd packages/typegen && copyfiles scripts/* build)",
"build:interfaces": "polkadot-types-internal-interfaces",
"docs": "polkadot-types-internal-metadata && polkadot-dev-build-docs",
"chain:info": "polkadot-types-chain-info",
"lint": "polkadot-dev-run-lint",
"clean": "polkadot-dev-clean-build",
"postinstall": "polkadot-dev-yarn-only",
"test": "jest --coverage --runInBand --testPathIgnorePatterns e2e",
"test:all": "jest",
"test:e2e": "jest packages/api/test/e2e",
"test:e2e-docker": "TEST_DOCKER=1 jest packages/api/test/e2e",
"test:e2e-remote": "TEST_REMOTE=1 jest packages/api/test/e2e",
"test:one": "jest",
"test:watch": "jest --coverage --watch"
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns e2e",
"test:one": "polkadot-dev-run-test",
"test:watch": "polkadot-dev-run-test --watch"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"@babel/register": "^7.5.5",
"@babel/runtime": "^7.5.5",
"@polkadot/dev": "^0.31.0-beta.3",
"@polkadot/ts": "^0.1.64",
"gh-pages": "^2.1.1"
"@babel/core": "^7.8.4",
"@babel/register": "^7.8.3",
"@babel/runtime": "^7.8.4",
"@polkadot/dev": "^0.50.27",
"@polkadot/ts": "^0.3.7",
"@polkadot/typegen": "workspace:packages/typegen",
"copyfiles": "^2.2.0"
}
}

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