* 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
838 B
838 B
@polkadot/jsonrpc
A definition of all the methods exposed in a general Polkadot client application. These are used not only to provide a comprehensive code-generated document of the available methods, but are also used in the API to auto-generate endpoints with the required type-checking.
For a list of currently exposed methods, see the method documentation.
Usage
Installation -
yarn add @polkadot/jsonrpc
Adding methods
As methods are added, simply adding the name, inputs & output will prepare it for use.
- Add the method to the correct file in src/rpc/ (Input/Output types as cross-referenced from the canonical implementation and match one-to-one)
- Should a new type be required, add it to the type list, src/types.js (Required for TSLint type checking)