Commit Graph
72 Commits
Author SHA1 Message Date
Jaco Greeff 28fd04c9e9 Add toU8a for EnumType (#362) 2018-10-29 14:51:07 +01:00
Jaco Greeff 96dc7dfd90 Add DigestItem(Seal) for Aura (#361)
* Add DigestItem(Seal) for Aura

* Re-add DigestItem export
2018-10-29 14:15:16 +01:00
Jaco Greeff 22632342c8 Decode meta <T as HasCompact>::Type (#358)
* Decode meta with HasCompact

* Revert saved meta (until create done)

* Construct Compact.with, allow Compact extends Base

* Remove (now invalid) comment

* createType creates Compact<*>

* Allow Compact<Moment>

* Update Type.ts

* Update Type.ts

* Update Type.ts
2018-10-29 11:40:36 +01:00
Jaco Greeff 78f179c09e Remove PairOf, convert to simple Tuple (#360) 2018-10-29 11:29:22 +01:00
Jaco Greeff 822f15e3a2 AccountIndex extends U32 (#355)
* AccountIndex extends U32

* Re-add toU8a with isBare override

* Small clarifications

* case-sensitive import

* Update comment
2018-10-29 11:18:20 +01:00
Jaco Greeff a2b22e3bb8 Allow Block/Header constructor via Uint8Array (client use) (#357) 2018-10-29 10:30:20 +01:00
Jaco Greeff 4997d8fb06 Event definitions (#350)
* Event definitions

* Compact things a bit

* Cleanup AccountIndex decoding, align Address

* Remove stand-alone MethodIndex (declutter)

* Inject metadata into Event from api

* Update API TODOs to reflect current state

* Update & expand comments

* EventData only takes Uint8Array inputs (via EventRecord)

* Remove duplicated toHex

* Add FIXME with link to base issue
2018-10-26 14:24:38 +02:00
Jaco Greeff c42b71a6d8 Add EventRecord & PairOf (#349)
* Fix metadata type output for storage

* Add EventRecord

* Add PairOf, rename .with to .with<Class>

* Revert .with changes, test for EventRecord

* ApplkyExtrinsic extends u32

* Log EnumType errors a tiny bit better
2018-10-25 21:21:19 +02:00
Jaco Greeff 6d3de598de Cleanup type tests (#339)
* Cleanup type tests

* Add Data (as now found as a Rust type)

* Data naming
2018-10-24 11:27:55 +02:00
Jaco Greeff 3ac4a3b5be Address type cleanups (#337)
* AccountIndex allows only <= 0xef for 1 byte

* Max 1-byte constructed from prefix

* Expand Address tests, add ts checks
2018-10-22 19:05:05 +02:00
Jaco Greeff d2eb6e5e5b Expose valueOf on Bool (aligns with Boolean) (#336)
* Expose valueOf on Bool (aligns with Boolean)

* Bool constructor allows Boolean
2018-10-22 15:07:28 +02:00
Jaco Greeff 9f570cbbe9 Make Extrinsic compatible with Method (#335)
* Make Extrinsic compatible with Method

* Remove Method -> methodIndex, only use callIndex
2018-10-22 12:10:39 +02:00
Amaury Martiny 1635638f50 Decode logs, without events (#328)
* Decode logs (without events)

* Put digestItem in digest

* Use spec.ts for signedBlock

* Fix bug type

* Add header

* Remove comment

* Add comment

* Fix bug order
2018-10-19 16:59:58 +02:00
Amaury Martiny 40342c6547 Make jsons readable (#326) 2018-10-19 14:55:42 +02:00
Amaury Martiny f2287f38c5 class Struct extends Map (#321)
* Rename to getAtIndex

* Add codec interface

* Fix stuff

* Fix struct

* Allow ts

* Add useful types

* Fix related types

* Fix test

* Small fix

* Use this.get everywhere

* Fix import

* Typos

* Fix ts ignore

* Add more tests

* Update polkadot dev

* Don't change jest config

* Fix eol
2018-10-19 14:49:09 +02:00
Jaco Greeff 3e79ac57f9 Declutter types root (a bit), move *.rpc.json to json/ (#325)
* Declutter types root (a bit), move *.rpc..json to json/

* Add Metadata.001.json (BBQ)
2018-10-19 13:44:24 +02:00
Jaco Greeff 11058e76cd Ignore log event decoding via Vector<Null> (#322)
* Ignore log event decoding via Struct

* Vecor<Null>

* Comment
2018-10-18 18:47:03 +02:00
Jaco Greeff 1b12c0094b Generate Event metadata docs (#316)
* Generate Event metadata docs

* Update MetadataMd.ts
2018-10-18 16:32:50 +02:00
Jaco Greeff 55ac4626d5 Cleanup imports from @polkadot/util (#315)
* Cleanup imports from @polkadot/util

* Example imports

* Alphabetic imports
2018-10-18 13:30:04 +02:00
Jaco Greeff 290123b85f Cleanup util-crypto & keyring imports (#314)
* Cleanup util-crypto & keyring imports

* Adjust util imports for types

* Bump deps
2018-10-18 11:06:02 +02:00
Amaury Martiny 008c78fe42 Replace byteLength() by get encodedLength() (#313)
* Replace byteLength by encodedLength

* Replace (continued)
2018-10-18 10:23:54 +02:00
Amaury Martiny f25d479bd7 Fix method (#312)
* Fix method

* Fix lint
2018-10-17 15:37:06 +02:00
Amaury Martiny 38e3f8cdb7 Add get argsDef (#311) 2018-10-17 13:41:43 +02:00
Amaury Martiny 94a202f33e Rename Struct.get to .getAtIndex (#310)
* Rename to getAtIndex

* Fix lint
2018-10-17 12:29:53 +02:00
Amaury Martiny 221bfac019 No from* (#309)
* Remove fromJSON/fromU8a

* Remove fromJSONx

* Remove unused import
2018-10-17 11:51:57 +02:00
Amaury Martiny 471bfce769 Rewrite Method (#308)
* Let Method extend Struct

* Fix Method

* Allow to pass array into Struct constructor

* Formatting

* Fix tests

* Add explicit function return type
2018-10-17 10:46:12 +02:00
Luke Schoen e8e92cd0d5 fix: Fixes #288. Alphabetical ordering for Sections and Methods of RPC, Storage, and Extrinsics (#291)
* fix: Manual alphabetical ordering for Storage Substrate methods

* fix: Fixes #288. Alphabetical ordering for Sections and Methds of RPC, Storage, Extrinsics

* refactor: Move alphabetical sorting of Methods in Extrinsics Section into separate function

* refactor: Use localeCompare to sort more concisely
2018-10-17 07:12:43 +02:00
Amaury Martiny 106c59d341 Don't use fromJSON/fromU8a anywhere in code (#298)
* Don't use fromJSON/u8a anywhere

* Remove useless cast

* Nicer formatting
2018-10-16 12:35:40 +02:00
Jaco Greeff ef2b0b4eba Address from ss-58 AccountIndex (#307)
* Address from ss-58 AccountIndex

* Update Address.spec.js
2018-10-16 11:59:01 +02:00
Jaco Greeff f31c35e48e Return array from enumset (#305) 2018-10-15 23:48:00 +02:00
Luke Schoen 99b9332dfb fix: Fixes #289. Add Anchor links to Sections on Node interface pages Rpc, Storage, Extrinsics (#302)
* fix: Fixes #289. Add Anchor links to Sections on Node interfaces pages RPC, Storage, Extrinsics

* refactor: Add reusable functions to generate section links/header. Add constants for back to top link/anchor

* Add function with switch to generate section links to section anchors.

* Add common function to generate section header.

* Reuse common Anchor/Link HTML with constants.

* refactor: Rename generateAnchors to generateSectionLinks. Add reusable function for section link text
2018-10-15 23:35:26 +02:00
Jaco Greeff 1b7640fb9f Create AccountIndex from number (#304) 2018-10-15 22:54:16 +02:00
Jaco Greeff 8f35b763b3 AccountId <-> AccountIndex mappings (#301) 2018-10-15 21:32:41 +02:00
Jaco Greeff 256740ec3b accountIndex.toU8a(true) -> AccountIndexSet (#299)
* accountIndex.toU8a(true) -> AccountIndexSet

* Fix length check
2018-10-15 20:15:25 +02:00
Amaury Martiny 8de9ea8878 Intelligent constructor (Part 3) (#294)
* Fix Metadata

* Fix metadata

* Use constructor type

* Fix EnumType

* Fix EnumType

* Fix Tuple

* Remove some froms

* Fix Struct

* Fix Bft test

* Remove some froms

* Small fixes

* Fix EnumType

* Add blank lines

* Struct allow jsonKey or without

* Add hack

* Update hack test

* Revert some stuff

* Revert to from again

* Fix tests
2018-10-15 14:29:20 +02:00
Jaco Greeff 7a66258ba1 Expand SignedBlock tests (#296)
* Exapnd tests

* Cleanups
2018-10-15 13:54:15 +02:00
Jaco Greeff e8ca742838 SignedBlock extrinsic decoding (era) (#295) 2018-10-15 13:03:02 +02:00
Jaco Greeff 9644daf5eb Fix decoding with eras (#293)
* Fix decoding with eras

* Typo
2018-10-15 11:48:14 +02:00
Jaco Greeff 7bc8386806 AccountIndex encoding updates via util/keyring (#281)
* AccountIndex encoding updates via util/keyring

* Proper ss58 AccountIndex decoding from keyring

* Metadata allows both length and non-length prefixed

* Update doc logo size & relative URL
2018-10-13 17:33:40 +02:00
Luke Schoen 4748e8c87f docs: Relates to #193. Generate Substrate Interface methods in API docs for RPC, Storage, and Extrinsics from Metadata (#265)
* docs: Relates to #193. Generate Methods in API docs to Substrate Interfaces Extrinsics and Storage from Metadata

* Steps to generate Gitbook:
```
yarn run build:methodsdoc;
yarn run build;
yarn gitbook serve;
```

* Allows generating a docs/METHODS_STORAGE.md and docs/METHODS_EXTRINSICS.md files by running `yarn run build:methodsdoc`
  * Note: The script runs `node packages/types/src/MetadataMdWrapper.js`, which uses Babel.js to transpile the TypeScript file MetadataMd.ts into JavaScript as MetadataMd.js by using the babel-plugin-module-resolver dependency that has been added to package.json. It runs MetadataMd.js, which parses a hard-coded copy of a Metadata response from the Substrate Node, and then generates the two aforementioned Markdown files to be included in the Gitbook.
  * Important Note: DO NOT run `./node_modules/.bin/tsc packages/types/src/MetadataMd.ts; node packages/types/src/MetadataMd.js;`, as doing so may incorrectly transpile other TypeScript files, and will give errors like `TypeError: bn_js_1.default is not a constructor` when you run your unit tests.

* Added links that work when you go to http://localhost:4000/api/ and click the "api" link on the side menu
  * Note: This was achieved by first adding the links in packages/api/README.md (i.e. `[Extrinsics (Substrate Interface)](../METHODS_EXTRINSICS.md)`). Note that the links could also be `METHODS_EXTRINSICS.html` and it would still work. It is VERY important to add links to these Markdown files in docs/SUMMARY.md (i.e. `[Storage](METHODS_STORAGE.md)`), as Gitbook generates HTML files in the same docs/ directory (i.e. it generates docs/METHODS_STORAGE.html) for any links provided in that file, and when you run `yarn run build; yarn gitbook serve` it will put a copy of those HTML files in the _book directory so it can be accessed in the browser.

* Replaces PR #249 and #255 from jg-meta-md from jg-meta-md-luke branches

* feat: Add script to generate decoded JSON file of the Metadata. Remove test.

* Summary:
  * Running `yarn run build:decodedjson` will generate packages/types/src/Metadata.decoded.json from the Metadata in the Metadata.rpc.ts file.

* docs: Manually add RPC Substrate Interface API docs including author, chain, state, system

* docs: Append Storage Substrate methods to Storage Methods. Add consistent styling. Add descriptions

* Add Description at top of Substrate Interface page for RPC, Extrinsics, and Storage in API docs

* Add styling to Substrate Interface page for Extrinsics and Storage, including:
  * ▸ symbol before each method
  * bold method names
  * adding Summary label and only showing the summary label if a summary exists
  * adding a horizonal line between each section of methods

* Fix by adding new line after description when there is one in Extrinscis and Storage

* Manually creating a markdown file containing storage.substrate methods METHODS_STORAGE_SUBSTRATE.md, and then reading from the file and appending it to the bottom of the METHODS_STORAGE.md file that is generated, since the storage.substrate methods are not available from the Metadata.

* Fix by reading and writing to file using UTF8 instead of ASCII so symbols appear correctly

* Updating docs/METHODS_RPC.md and adding a horizontal line before the first section of methods

* docs: Fix Readme file step numbering

* docs: Generate the Substrate Interface Markdown files first when run yarn run build

* refactor: Move babel register config into shared file

* refactor: Use shared function to overcome codeclimate error

* fix: Reword description of RPC methodsto address review comment

* docs: Rename to Runtime Node Interfaces to address review comment

* docs: Rename to Runtime Node Interface in api Readme to address review comment

* docs: Fix minor typos

* docs: Fixes #117 providing Readme ref to jsonrpc docs

* fix: Remove preceding whitespace

* docs: Rename so RPC is not referred to as an interface of the runtime

* docs: Refer to Storage Substrate methods as always available to runtime implementation

* test: Restore the test that was unnecessary deleted

* Move scripts into packages/types/src/scripts

* docs: Add script to generate RPC interface docs

* fix: Fix TSlint error where element had any time due to no index signature

* refactor: Restore code back to normal instead of bowing to codeclimate whims

* refactor: Declare meaningful variables to make more readable

* docs: Show .subscribe when it is isSubscription method
2018-10-12 21:15:01 +02:00
Jaco Greeff 2b5169c232 Bump @polkadot/keyring, change package name (#272) 2018-10-12 17:33:29 +02:00
Jaco Greeff f8d9f1c76e Align all RPC methods with Rust (#264)
* Align all RPC methods with Rust

* Adjust tests for extrinsicUpdate (e2e & working)

* Update transfer.spec.js

Auto-complete imports removed
2018-10-12 14:47:22 +02:00
Jaco Greeff a47485c9bf Return value from array on subscription (#262) 2018-10-12 12:33:18 +02:00
Jaco Greeff 5975e237e3 Status type (#256) 2018-10-12 09:35:23 +02:00
Amaury Martiny 5207285b43 Storage key are not length-prefixed anymore (#257)
* Fix lenght prefix

* Put add lenght prefix to compact
2018-10-11 21:28:47 +02:00
Amaury Martiny f5948fee52 Intelligent constructor (Part 2) (#252)
* Fix AccountId

* Fix AccountIndex

* Add Bool

* Fix Address

* Small fixes

* Fix Bytes

* Fix ExtrinsicSignature

* Small fixes

* Sorta fix Method

* Fix Extrinsic

* Fix method

* Fix Bytes and KeyValue

* Fix Moment

* Length-prefix the storage key

* Fix Bytes prefix

* Add comment
2018-10-11 13:39:27 +02:00
Jaco Greeff 27b2885722 Extend ApiRx from abstract Base (prepare for promise) (#243)
* Extend ApiRx from abstract Base (prepare for promise)

* Update Metadata parsing

* Update Base.ts

* Update types.d.ts

* Cleanup base

* Cleanup linting (renamed imports)

* PR comments

* Update decoded Metadata.json
2018-10-11 10:20:54 +02:00
Luke Schoen 267411d778 fix: Fixes #235 TypeDoc updates consistent with renaming (#236)
* fix: Remove docs/api since replaced with docs/rpc-core

* fix: Remove docs/api-provider since replaced with docs/rpc-provider

* fix: Remove docs/api-rx since replaced with docs/rpc-rx

* fix: Remove the guide file that serves no purpose

* fix: Change license from ui-observable to api-observable

* fix: Remove disused mockHttp and mockWs that are duplicates of those in rpc-provider

* fix: Clarifies difference between PropIndex and ProposalIndex from Issue #226

* fix: Update api-observable Readme to refer to rpc-core, previously called api

* misc: Update Readme of rpc-core. See commit message details.

* Update name to be @polkadot/rpc-core instead of @polkadot/api

* Use Yarn instead of NPM for instructions adding dependencies

* Refer to @polkadot/rpc-core as `Rpc`

* Highlight that given block header hash should be a 0x-prefixed hex string with length of 64 (not only length of 10 as shown in the example)

* Showcase more information that you can obtain from the header object (i.e. best block number, parentHash, stateRoot, extrinsicsRoot, and digest)

* Use `header.raw` instead of just `header` to access properties of the header object

* Update the example to console.log the subscription ID

* Add missing semicolon

* fix: Fix name in license header and rename Api to Rpc for rpc-core e2e tests

* fix: Update rpc-provider Readme to use Yarn instead of NPM install

* fix: Fix minor typo

* fix: Rename Api to Rpc for rpc-provider ws

* fix: Refer to rpc-core instead of api in the rpc-rx Readme

* fix: Update rpc-rx files to refer to it as RpcRx instead of RxApi or just Api

* fix: Refer to rpc-core as Rpc instead of Api

* fix: Update type-jsonrpc Readme. Fix typo. Use Yarn not NPM. Refer to TSLint not Flow

* refactor: Move non-type dependency import with non-type dependencies

* docs: Add link to parity-codec repo

* fix: Avoid use of .raw. Fix listen to blocks example

* fix: Add missing error to newHead in listen to blocks example
2018-10-10 20:11:22 +02:00
Jaco Greeff b05429e6e8 Option allows null/undefined as empty (#230) 2018-10-09 16:26:28 +02:00
Amaury Martiny c026ecb1c2 Intelligent constructor (#217)
* Decode Uint8Array to Struct

* Add decode for Text

* Add tests for Text

* Add decode for Struct

* Rename variable

* Add test for struct

* Remove array check

* Remove isTuple

* Remove decode in Struct

* Add encoding tests

* Remove isTuple

* Better error message

* Add isTuple back

* Fix Option

* Fix Metadata test

* Fix Vector

* Fix Enum

* Fix U8a

* Fix imports

* Add tests

* Fix bug new Compact

* Fix lint

* Use specific decode

* Fix Vector

* Fix test

* Remove useless file

* Don't change Vector

* Fix lint
2018-10-09 15:59:45 +02:00