mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-22 09:08:06 +00:00
b413e5e84e94c10fb406468e27e5d6a03df99d34
59 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
b413e5e84e |
Codegen for custom values in metadata (#1117)
* work in progress * add custom types access * nit * custom values client * adjust light client * adjust doc comments * adjust book for custom values in code gen * format and check docs * work in progress * add custom types access * nit * custom values client * adjust light client * codegen and validation * adjust docs * use ignore in docs in book * change iter implementation * use validation hash and other codegen changes * add ui test for custom values codegen * allow 'latest' metadata to be returned from the fallback code (#1127) * nits * fix validation check * fix comments * nits --------- Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
8b4fea0b07 |
refactor(rpc): support default port in URL (#1122)
* refactor: support default port in URL Update jsonrpsee to v0.20 to support the default port number in URLs. * fix nit, revert web feature * fix lightclient code |
||
|
|
c6e4c7294d |
codegen: Fetch and decode metadata version then fallback (#1092)
* codegen: Fetch and decode metadata version then fallback Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Add `unstable-metadata` attribute to the subxt macro Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * docs: Add missing comma Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * macro: Add `GenerateRuntimeApi` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update subxt/src/lib.rs Co-authored-by: James Wilson <james@jsdw.me> * Update macro/src/lib.rs Co-authored-by: James Wilson <james@jsdw.me> * subxt: Adjust docs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Import `GenerateRuntimeApi` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
78a106f059 |
Utilize Metadata V15 (#1041)
* Update frame-metadata to the latest branch Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Add outer enum types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Extend the extrinsic with address,call,sign,extra types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Codegen test Event, Error and Call for outer enums Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "Codegen test Event, Error and Call for outer enums" This reverts commit db542dca0369eedd257a7ec031d5b5549bc46a88. * Update frame-metadata from the latest release Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update scale-info Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen/error: Support v15 message Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/retain: Adjust to extrinsic type for V15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/validation: Adjust hashing for extrinsic types V15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * scripts: Fetch V15 and output codegen for full_client only Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/blocks: Use extrinsic types directly Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Fetch V15 for build script Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * artifacts: Generate from latest polkadot version Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Fetch legacy with old API for v14 only Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Fetch metadata versions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client: Fetch latest unstable then V15 then V14 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Adjust testing API to latest interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Generate the `RuntimeError` type for V14 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Remove testing files Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing/staking: Remove controller account from bond Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/validation: Use specific variants for hashing RuntimeCall Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * XXX: Custom Substrate binary: must revert with next release Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * XXX: To revert: CI use hardcoded substrate Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use v15 outer enum types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Retain outer enum types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use outer enum types instead of generating them Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update artifacts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "XXX: Custom Substrate binary: must revert with next release" This reverts commit e9705298661919f5769720b35030759fb8a7b01d. Revert "XXX: To revert: CI use hardcoded substrate" This reverts commit b18a5a0985a56ee4ad99bc9a1c0f9cd733cf4271. * testing: Include env for dummy wat contracts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjsut clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * ci: Use new link for fetching latest substrate binary Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Include dummy RuntimeEvent into test metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * ci: Bump light-client timeout tests to 25min Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/validation: Use specific pallets as provided Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Rename metadata constant Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Use call_ty instead of signature_ty Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Rename retaining variant function Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Use Option<&[&str]> Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * online_client: Fetch V15 metadata explicitely Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/validation: Include the hash of the outer enum types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Fix sign typo Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * artifacts: Update the artifacts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Remove RootError RootEvent and RootExtrinsic traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Ensure outer enum variants are retained Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * scripts: Include multiple pallets for our decoding purposes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Apply clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * artifacts: Update small metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * error: Keep raw bytes for the ModuleError representation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * error: Modify docs to not include links Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/tests: Propagate `RuntimeCall` to outer enums Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Provide proper byte slice for decoding Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update artifacts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli/tests: Adjust expected pallets message Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Test conversion from v14 to v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Fix typo Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update subxt/src/blocks/extrinsic_types.rs Co-authored-by: James Wilson <james@jsdw.me> * metadata: Simplify type path for RuntimeError Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/validation: Use visited ids per outer enum Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * error: Remove RawModuleError Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix new clippy error from updated rust version Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
992ec9ab9b |
Fix codegen validation when Runtime APIs are stripped (#1000)
* modify code gen * cargo fmt * fix return * move the runtime_apis static * small layout change * tidy up metadata UI testing and test validation function too * fix validation tests to point to metadata * update codegen * fix clippy and tests * tweak a comment * rename validate_codegen => is_codegen_valid_for --------- Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
1ad9a20ce2 |
add #[allow(rustdoc::broken_intra_doc_links)] to subxt-codegen (#998)
* add `#[allow(rustdoc::broken_intra_doc_links)]` to subxt-codegen * Add for "main" codegen path too --------- Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
b9f5419095 |
Introduce Metadata type (#974)
* WIP new Metadata type * Finish basic Metadata impl inc hashing and validation * remove caching from metadata; can add that higher up * remove caches * update retain to use Metadata * clippy fixes * update codegen to use Metadata * clippy * WIP fixing subxt lib * WIP fixing tests, rebuild artifacts, fix OrderedMap::retain * get --all-targets compiling * move DispatchError type lookup back to being optional * cargo clippy * fix docs * re-use VariantIndex to get variants * add docs and enforce docs on metadata crate * fix docs * add test and fix docs * cargo fmt * address review comments * update lockfiles * ExactSizeIter so we can ask for len() of things (and hopefully soon is_empty() |
||
|
|
5960cd2ac8 |
Ensure unique types in codegen (#967)
* Ensure unique types in codegen * tweak comment * Test the duplicate type codegen stuff * appease clippy * fix import * add another test for generics being de-duplicated * cargo fmt --------- Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> |
||
|
|
81494027c8 |
Have a pass over metadata validation (#959)
* Have a pass over metadata validation * trait metadata; fold instead of map+for * remove a couple of other XORs, so all uses of it are now commented * appease clippy |
||
|
|
3f16bb8d52 |
extrinsics: Decode extrinsics from blocks (#929)
* Update polkadot.scale Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics: Add extrinsics client Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics: Decode extrinsics Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add extrinsic error Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * blocks: Expose extrinsics Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Fetch and decode block extrinsics Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics: Fetch pallet and variant index Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Move extrinsics on the subxt::blocks Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * example: Adjust example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Collect ExtrinsicMetadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Implement StaticExtrinsic for the calls Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust examples Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add root level Call enum Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add new decode interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Merge ExtrinsicError with BlockError Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Find first extrinsic Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Move code to extrinsic_types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Add Extrinsic struct Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust examples Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * test: Decode extinsics Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics/test: Add fake metadata for static decoding Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics/test: Decode from insufficient bytes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics/test: Check unsupported versions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics/test: Statically decode to root and pallet enums Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics/tests: Remove clones Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * blocks: Fetch block body inline Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * blocks: Rename ExtrinsicIds to ExtrinsicPartTypeIds Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics/test: Check decode as_extrinsic Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * blocks: Remove InsufficientData error Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * blocks: Return error from extrinsic_metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * extrinsics: Postpone decoding of call bytes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata_type: Rename variables Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust calls path for example and tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Remove traces Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * book: Add extrinsics documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * book: Improve extrinsics docs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
562f12cd9b |
Subxt Guide (#890)
* WIP Starting to write book; extrinsics first pass done * cargo fmt * Ongoing work; events, constants, wip blocks * at_latest() and wip blocks * remove need to import parity-scale-codec crate with Subxt for macro to work * More docs; expanding on setup guide and finish pass of main sections * Tidy and remove example section for now * format book lines to 100chars * Fix example code * cargo fmt * cargo fmt * fix example * Fix typos * fix broken doc links, pub mods * Update Subxt macro docs * can't link to Subxt here * move macro docs to Subxt to make linking better and fix example code * note on macro about docs * cargo fmt * document the no_default_derives macro feature * Address feedback and remove redundant text * address review comments; minor tweaks * WIP add Runtime calls to book * Improve Runtime API docs * expose thing we forgot to expose and doc link fixes |
||
|
|
432e856c37 |
Metadata V15: Generate Runtime APIs (#918)
* Update frame-metadata to v15.1.0 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Enable V15 unstable metadata in frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Move validation hashing to dedicated file Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Use sp-metadata-ir from substrate to work with metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert using sp-metadata-ir in favor of conversion to v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Use v15 for validation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use v15 for codegen Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/bench: Use v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust to v15 metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Improve documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * force CI Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Fetch metadata at version Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * artifacts: Update polkadot.scale from commit 6dc9e84dde2 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Fetch V15 using the new API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add runtime API interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Hash runtime API metadata for validation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Extract runtime API metadata wrapper from subxt::Metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Adjust hashing cache to reflect root+item keys Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * rpc: Add raw state_call API method Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * runtime_api: Add payload with static and dynamic variants Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Allow payloads to call into the runtime Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Add example to make a runtime API call both static and dynamic Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Simplify client fetching Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Address feedback and fallback to old API if needed Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * runtime_api: Make mutability conditional on input params Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Regenerate polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Retain only pallets without runtime API info Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Retry via `Metadata_metadata` without conversion Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * payload: Remove `Decode` and change validation fn Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Retain runtime API types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Runtime APIs documentation based on flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update examples/examples/custom_metadata_url.rs Co-authored-by: James Wilson <james@jsdw.me> * Update artifacts from polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs with polkadot-a6cfdb16e9 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Generate input structures for runtime API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * runtime_api: Remove the static paylaod and use single impl Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Fetch account nonce Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Adjust build script to fetch latest metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Check account nonce from runtime API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Fix doc generation for runtime types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Rename `inputs` runtime calls module to `types` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Generate Calls structs inside the types module Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Check Alice account nonce before submitting the tx Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Add metadata version option flag supporting v14 and unstable Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Specify version to fetch Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Fallback to fetching latest stable metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add unstable-metadata feature to fetch the latest Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * RuntimeVersion with Latest and Version(u32) Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Adjust fetch_metadata to inspect version list Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Adjust metadata to metadata_legacy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * events: Adjust docs to use metadata_legacy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * have a pass over fetch_metadata * cargo fmt * Option<String> when fetch metadata via latest API * clippy * fmt * cli: Use the MetadataVersion from codegen Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Specify latest as default for MetadataVersion Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Remove version from metadata and use the one from file_or_url Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Decode metadata independently for different RPC calls Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
265f16fdec |
codegen for root level error (#930)
* code gen for root error * cargo fmt * polkadot.rs regenerated * use pallet name and decode with metadata * remove pallet by name fn * test that we can decode a ModuleError via as_root_error * nits --------- Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
59d195d4ad |
metadata: Use v15 internally (#912)
* Update frame-metadata to v15.1.0 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Enable V15 unstable metadata in frame-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Move validation hashing to dedicated file Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Use sp-metadata-ir from substrate to work with metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert using sp-metadata-ir in favor of conversion to v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Convert v14 to v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Use v15 for validation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use v15 for codegen Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/bench: Use v15 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust to v15 metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust testing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Improve documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * force CI Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Address feedback Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Use HASH_LEN Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadta: Remove `LatestRuntimeMetadata` type alias Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Remove `metadata_to_latest` to avoid pancis Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> |
||
|
|
8a7c17289a |
Metadata: Retain a subset of metadata pallets (#879)
* Update cargo.lock to use scale-info v2.4.0 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Retain only a subset of the metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Generate top level Event Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Only retain DispatchError Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Export just the retain method Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Retain pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Do not include extrinsic metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * retain: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * test-runtime: Generate per pallet metadata and rs file Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * ui-tests: Check per metadata generated files Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "test-runtime: Generate per pallet metadata and rs file" This reverts commit 725a2e5f8339a795892dbbd2df19e49330ae3a9b. Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * ui-tests: Adjust path to metadata file Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * ui-tests: Change drop order to keep `PalletMetadata` around Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update metadata/src/retain.rs Co-authored-by: James Wilson <james@jsdw.me> * Address feedback Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * retain: Keep extrinsic type Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Introduce `MetadataSource` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Use `MetadataSource` helper Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Use `FileOrUrl` flatten command argument Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * retain: Do not include generic type params in retained metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Adjust subxt to scale-info v2.5.0 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update scaleinfo to v2.5.0 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Remove deprecated fn Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * benches: Use inner fields of scale info Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * address nits, and strip RuntimeCall type instead of trying to filter out use of it for better overall wins/clarity * fix UI test * move utils out of commands folder and fix clippy etc * address nits --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
c08eb6c8f1 |
Update scale-info to 2.5.0 (#896)
* Upodate scale-info to 2.5.0 * A couple more clippy fixes * more deprecation things that appeared |
||
|
|
a2b8dde5e6 |
Add 'Static' type and improve type substitution codegen to accept it (#886)
* Add Static type which defers to Encode/Decode and impls EncodeAsType/DecodeAsType * rename to static_type and impl Deref/Mut * Improve type substitution in codegen so that concrete types can be swapped in * A couple of comment tweaks and no need for a macro export * Extend type substitution logic to work recursively on destination type * cargo fmt * Fix a couple of comments * update ui test outpuot * Add docs and missing_docs lint * Add test for replacing multiple of Ident * Update codegen/src/error.rs Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * update copyright year and fix ui test * simplify another error --------- Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> |
||
|
|
7c252fccf7 | cargo fmt with stable defaults (#876) | ||
|
|
c63ff6ec6d |
Use scale-encode and scale-decode to encode and decode based on metadata (#842)
* WIP EncodeAsType and DecodeAsType * remove silly cli experiment code * Get things finally compiling with EncodeAsType and DecodeAsType * update codegen test and WrapperKeepOpaque proper impl (in case it shows up in codegen) * fix tests * accomodate scale-value changes * starting to migrate to EncodeAsType/DecodeAsType * static event decoding and tx encoding to use DecodeAsFields/EncodeAsFields * some tidy up and add decode(skip) attrs where needed * fix root event decoding * #[codec(skip)] will do, and combine map_key stuff into storage_address since it's all specific to that * fmt and clippy * update Cargo.lock * remove patched scale-encode * bump scale-encode to 0.1 and remove unused dep in testing crate * update deps and use released scale-decode * update scale-value to latest to remove git branch * Apply suggestions from code review Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> * remove sorting in derives/attr generation; spit them out in order given * re-add derive sorting; it's a hashmap * StaticTxPayload and DynamicTxPayload rolled into single Payload struct * StaticStorageAddress and DynamicStorageAddress into single Address struct * Fix storage address byte retrieval * StaticConstantAddress and DynamicConstantAddress => Address * Simplify storage codegen to fix test * Add comments * Alias to RuntimeEvent rather than making another, and prep for substituting call type * remove unnecessary clone * Fix docs and failing UI test * root_bytes -> to_root_bytes * document error case in StorageClient::address_bytes() --------- Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> |
||
|
|
c9527abaa8 |
Generate only runtime types (#845)
* Typos * Add new macro parameter. Refactor. * Code generation * Inline `runtime_types` module * Documentation * Can't inline so easily * Example * Remove leftover * Improve clarity of the example |
||
|
|
a7b45ef1d1 |
codegen: Add codegen error (#841)
* codegen: Add codegen error Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use codegen error instead of aborts Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Remove `proc-macro-error` dependency Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * macro/subxt: Transform codegen error into compile_error! Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Pretty printing for `CodegenError` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Adjust testing for codegen error Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Fix documentation example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Export `CodegenError` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use collect::<Result<_>, _>() Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Adjust comment regarding error printing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Improve error messages Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> |
||
|
|
5320ca9d55 |
codegen: Opt out of documentation (#843)
* codegen: Opt-out for API documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Add `--no-docs` flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Check no documentation was generated Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Adjust testing for the new codegen API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * macro: Ensure `subxt` macro does not contain documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * macro: Expose documentation flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * expose_documentation => generate_docs --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
ce0a82e322 |
Remove unneeded Config bounds and BlockNumber associated type (#804)
* remove unneeded Config bounds and BlockNumber associated type * clippy and fmt |
||
|
|
977f2a3333 |
Allow for remapping type parameters in type substitutions (#735)
* feat!: Allow for remapping type parameters in type substitutions * chore: cargo fmt * chore: cargo clippy * chore: Remove some old code * a little tidy * address comment nit Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
26b8a81c17 |
Codegen: Preserve attrs and add #[allow(clippy::all)] (#784)
* Preserve attrs on codegen and ignore all clippy on generated code * tweak and test attr preservation |
||
|
|
b316301d61 |
Make sp_core and sp_runtime dependencies optional, and bump to latest (#760)
* begin porting over traits; remove Config use of Hash * port over the Header bits that we need * sp_core_hashing where possible, move Verify to PairSigner, remove unused errors * tidy up Config things and move related bits into one place * fix codegen * copy Era over * move AccountId, Address, Signer to Signer trait and a pass over fixing examples * impl MultiAddress, MultiSignature, AccountId32 and add back to Config (for decoding later) * Copy over StorageKey, StorageData, StorageChangeSet * subxt core compiling with no sp_core or sp_runtime * Get examples compiling * pass over fixing tests * cargo fmt * clippy tweaks and update polkadot.rs * fix codegen docs * port over special DigestItem encoding/decoding * clippy and doc fixes * cargo fmt and example fix * more cargo fmt-ing... * substrate-extra to substrate-compat * cargo.toml comments * simplify PairSigner trait bounds * move RPC types to a separate file * fix docs * Add some tests for things and other PR feedback * bump to latest sp deps * avoid needing substrate-compat feature in a test |
||
|
|
f0ce26db7b |
Add bitvec-like generic support to the scale-bits type for use in codegen (#718)
* Add bitvec-like generic support to the scale-bits type for use in codegen * Use nightly 1.66 formatting * Fix reading input while decoding bit sequences * Add tests for our DecodedBits wrapper * Add convenience DecodedBits::(in)to_bits functions * Don't expose DecodedBits::bit_format * Re-export scale_bits as peer dependency * Move subxt::utils into a separate file * Hide DecodedBits internals * Don't re-export types from the `bits` module * Update subxt/src/utils/bits.rs Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Update subxt/src/utils/bits.rs Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> * Address review feedback * Clarify the byte needed calculation in DecodedBits encoding * Remove remaining dbg! invocations Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com> |
||
|
|
8b46f5c786 |
Retain Rust code items from mod decorated with subxt attribute (#721)
* refactor: Simplify collecting type substitutes * Simplify ItemMod::from * Preserve inner Rust items when expanding the subxt::subxt macro * No named lifetimes * Update codegen/src/api/mod.rs Co-authored-by: Andrew Jones <ascjones@gmail.com> * Move passing UI tests under `ui_tests` Co-authored-by: Andrew Jones <ascjones@gmail.com> |
||
|
|
d03e599684 |
Add runtime_metadata_url to pull metadata directly from a node (#689)
* Allow metadata to be pulled directly from a node with runtime_metadata_url * Update docs * https too, and abstract out block_on fn * tweak a comment in the example |
||
|
|
f115ff975c |
Allow specifying the subxt crate path for generated code (#664)
* Allow specifying the `subxt` crate path for generated code * Make `clippy` happy * Add documentation * Improve optics * Remove custom crate path test * Implement comments * Update comment * Make `crate_path` property instead of argument * Remove unnecessary derives * Remove `Default` impls in favor of explicit constructors * Remove unnecessary `into` * Update codegen/src/types/mod.rs Co-authored-by: Andrew Jones <ascjones@gmail.com> Co-authored-by: Andrew Jones <ascjones@gmail.com> |
||
|
|
f48a5df2ca |
Fix history_depth testing (#662)
* testing/staking: `history_depth` storage is now a constant Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * artifacts: Update metadata from `9ffe6e9e3da` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * testing: Update `polkadot.rs` from `9ffe6e9e3da` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Update comment wrt polkadot version Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> |
||
|
|
4f39f6f8fc | use 'sp_core::Hxxx' for all hash types (#623) | ||
|
|
e48f0e3b1d |
Rework Subxt API to support offline and dynamic transactions (#593)
* WIP API changes * debug impls * Get main crate compiling with first round of changes * Some tidy up * Add WithExtrinsicParams, and have SubstrateConfig + PolkadotConfig, not DefaultConfig * move transaction into extrinsic folder * Add runtime updates back to OnlineClient * rework to be 'client first' to fit better with storage + events * add support for events to Client * tidy dupe trait bound * Wire storage into client, but need to remove static reliance * various tidy up and start stripping codegen to remove bits we dont need now * First pass updating calls and constants codegen * WIP storage client updates * First pass migrated runtime storage over to new format * pass over codegen to generate StorageAddresses and throw other stuff out * don't need a Call trait any more * shuffle things around a bit * Various proc_macro fixes to get 'cargo check' working * organise what's exposed from subxt * Get first example working; balance_transfer_with_params * get balance_transfer example compiling * get concurrent_storage_requests.rs example compiling * get fetch_all_accounts example compiling * get a bunch more of the examples compiling * almost get final example working; type mismatch to look into * wee tweaks * move StorageAddress to separate file * pass Defaultable/Iterable info to StorageAddress in codegen * fix storage validation ne, and partial run through example code * Remove static iteration and strip a generic param from everything * fix doc tests in subxt crate * update test utils and start fixing frame tests * fix frame staking tests * fix the rest of the test compile issues, Borrow on storage values * cargo fmt * remove extra logging during tests * Appease clippy and no more need for into_iter on events * cargo fmt * fix dryRun tests by waiting for blocks * wait for blocks instead of sleeping or other test hacks * cargo fmt * Fix doc links * Traitify StorageAddress * remove out-of-date doc comments * optimise decoding storage a little * cleanup tx stuff, trait for TxPayload, remove Err type param and decode at runtime * clippy fixes * fix doc links * fix doc example * constant address trait for consistency * fix a typo and remove EncodeWithMetadata stuff * Put EventDetails behind a proper interface and allow decoding into top level event, too * fix docs * tweak StorageAddress docs * re-export StorageAddress at root for consistency * fix clippy things * Add support for dynamic values * fix double encoding of storage map key after refactor * clippy fix * Fixes and add a dynamic usage example (needs new scale_value release) * bump scale_value version * cargo fmt * Tweak event bits * cargo fmt * Add a test and bump scale-value to 0.4.0 to support this * remove unnecessary vec from dynamic example * Various typo/grammar fixes Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> * Address PR nits * Undo accidental rename in changelog * Small PR nits/tidyups * fix tests; codegen change against latest substrate * tweak storage address util names * move error decoding to DecodeError and expose * impl some basic traits on the extrinsic param builder Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> |
||
|
|
c55b7ba3e3 | dual license (#590) | ||
|
|
e3732e354f |
Add subxt documentation (#546)
* Documentation for cli crate Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add documentation and simplify calls generation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add documentation and simplify events generation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add documentation and simplify constants generation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add documentation and simplify storage generation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add lib documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * macro: Remove `-f bytes` as this is the default Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/client: Add examples Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * lib_doc: Add documentation to dedicated file Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Link documentation from file Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add more documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add Storage example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Add rpc documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Add documentation for errors Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Add documentation for the `extrinsic` module Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Add documentation for `events` module Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add `Static Metadata Validation` section Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add `Runtime Updates` section Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix link to documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * readme: Remove hardcoded versions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Move documentation to dedicated folder Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Spaces between examples Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * More details for `types_mod_ident` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Add note for RuntimeGenerator Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Address feedback Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update codegen/src/api/constants.rs Co-authored-by: James Wilson <james@jsdw.me> * Update subxt/src/lib.rs Co-authored-by: James Wilson <james@jsdw.me> * Update subxt/src/metadata/metadata_type.rs Co-authored-by: James Wilson <james@jsdw.me> * Update subxt/src/storage.rs Co-authored-by: James Wilson <james@jsdw.me> * Address feedback Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix cargo clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update call example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Add example for fetching constants Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Link to examples in subxt.md Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update codegen/src/api/calls.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update codegen/src/api/calls.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update codegen/src/api/calls.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update codegen/src/api/constants.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update codegen/src/api/constants.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update codegen/src/api/storage.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update codegen/src/api/storage.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update codegen/src/api/storage.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update docs/subxt.md Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update docs/subxt.md Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update docs/subxt.md Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update docs/subxt.md Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update docs/subxt.md Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update subxt/src/extrinsic/mod.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update subxt/src/storage.rs Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> * Update documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update examples/examples/balance_transfer.rs Co-authored-by: James Wilson <james@jsdw.me> * Update subxt/src/extrinsic/mod.rs Co-authored-by: James Wilson <james@jsdw.me> * Update subxt/src/rpc.rs Co-authored-by: James Wilson <james@jsdw.me> * Update subxt/src/updates.rs Co-authored-by: James Wilson <james@jsdw.me> * Update docs example with `PolkadotExtrinsicParams` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Remove extrinsic extra documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Remove similar transfer example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Apply cargo fmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> Co-authored-by: Tarik Gul <47201679+TarikGul@users.noreply.github.com> |
||
|
|
fc19f881e3 |
Implement Clone for the generated RuntimeApi (#544)
* Implement Clone for the generated `RuntimeApi` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Don't reexport Derivative Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Implement `Clone` manually Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update `polkadot.rs` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> |
||
|
|
115073a33d |
Subscribe to Runtime upgrades for proper extrinsic construction (#513)
* subxt: Add subscription to runtime upgrades Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Synchronize and expose inner `RuntimeVersion` of the `Client` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Add runtime update example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Expose `RuntimeVersion` as locked Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Expose `Metadata` as locked Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/storage: Use locked metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Use parking lot RwLock variant for locked metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Utilize locked metadata variant Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/transaction: Use locked metadata variant Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update subxt to use locked version of the Metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add runtime update client wrapper Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Modify runtime update example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix cargo check Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Keep consistency with cargo check fix Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Remove unnecessary Arc Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Remove MetadataInner and use parking_lot::RwLock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs generation comment Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Switch to async::Mutex Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Block executor while decoding dynamic events Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use async API to handle async locking Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Remove unused dependencies Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update examples and integration-tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix test deadlock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert back to sync lock Revert "Fix test deadlock" This reverts commit 4a79933df23e81573611cb14be6c5b5b2b56d4df. Revert "Update examples and integration-tests" This reverts commit 5423f6eb4131582909d5a4ca70adff75e27cdd0e. Revert "Remove unused dependencies" This reverts commit e8ecbabb5b01a7ba4ae83b8bde36295a3f64daf7. Revert "codegen: Use async API to handle async locking" This reverts commit ced4646541c431adcb973369b1061b7b3cbfaae1. Revert "subxt: Block executor while decoding dynamic events" This reverts commit 8b3ba4a5eabb29f77ac1ca671450956fc479a33d. Revert "subxt: Switch to async::Mutex" This reverts commit f5bde9b79394a6bf61b6b9daefc36ceaa84b82be. * subxt: Perform RuntimeVersion update before fetching metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Reintroduce MetadataInner * Use parking lot instead of std::RwLock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Reduce lock metadata time when decoding events Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update `validate_metdata` locking pattern Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/examples: Update polkadot download link Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Wrap metadata in a helper function Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update examples/examples/subscribe_runtime_updates.rs Co-authored-by: James Wilson <james@jsdw.me> * subxt/updates: Update runtime if version is different Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
24317b4311 |
Add custom derives for specific generated types (#520)
* WIP implement custom derives per type * WIP wiring up specific type derives * Fmt * Rename GeneratedTypeDerives to Derives * Fmt * Fix errors * Fix test runtime * Make derives appear in alphabetic order * Clippy * Add derive_for_type attribute to example * Add docs to example * Rename GeneratedTypeDerive * Rename ty to type in attribute * Update darling * Update codegen/src/types/derives.rs Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> * Update codegen/src/types/mod.rs Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> * Update codegen/src/types/mod.rs Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> * review: update method name * Add unit tests for combined derives * Remove out of date docs * Add macro usage docs Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> |
||
|
|
1fd1eee72a |
Static Metadata Validation (#478)
* metadata: Implement MetadataHashable for deterministic hashing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Hash `scale_info::Field` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Hash `scale_info::Variant` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Hash `scale_info::TypeDef` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Hash pallet metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Avoid data representation collision via unique identifiers Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Finalize hashing on recursive types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Cache recursive calls Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Move `MetadataHashable` to codegen to avoid cyclic dependency Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add pallet unique hash Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Wrap metadata as owned Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Use MetadataHashable wrapper for clients Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Generate runtime pallet uid from metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Validate metadata compatibility at the pallet level Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Modify examples and tests for the new API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Implement metadata uid Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot with TryFrom implementation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client: Change `to_runtime_api` to reflect TryFrom changes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * client: Skip full metadata validation option Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add option to skip pallet validation for TransactionApi Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add option to skip pallet validation for StorageApi Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs with ability to skip pallet validation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Change `MetadataHashable` to per function implementation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use metadata hashes functions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Use metadata hashes functions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Make `get_type_uid` private Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen, subxt: Rename metadata functions `*_uid` to `*_hash` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update `get_field_hash` to use `codec::Encode` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen, subxt: Move metadata check from client to subxt::Metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen, subxt: Rename metadata check functions to follow `*_hash` naming Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs to reflect naming changes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use `encode_to` for metadata generation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs to reflect `encode_to` changes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Specific name for visited set Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Provide cache to hashing functions Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Compute metadata hash by sorted pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Get extrinsic hash Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Extend metadata hash with extrinsic and metadata type Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Add cache as metadata parameter Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen, subxt: Update metadata hash to use cache Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Implement Default trait for MetadataHasherCache Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Add cache for pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Move functionality to metadata crate Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen, subxt: Use subxt-metadata crate Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Remove metdata hashing functionality Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Add documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Fix vector capacity to include extrinisc and type hash Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Add empty CLI Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-cli: Fetch metadata from substrate nodes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-cli: Log metadata hashes of provided nodes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-cli: Group compatible nodes by metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-cli: Simplify hash map insertion Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-cli: Move full metadata check to function Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-cli: Group metadata validation at the pallet level Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Persist metadata cache Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Move compatibility cli from subxt-metadata to subxt-cli Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Remove cli from subxt-metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Fix compatible metadata when pallets are registered in different order Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Handle result of pallet hashing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Remove type cache for deterministic hashing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Add test assets from `substrate-node-template` tag `polkadot-v0.9.17` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-tests: Check cache hashing for Balances pallet Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Fix `get_type_hash` clippy issue Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-tests: Compare one time cache with persistent cache Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-test: Check metadata hash populates cache for pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-tests: Simplify `cache_deterministic_hash` test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata-tests: Check deterministic metadata for different order pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Implement TransactionApiUnchecked for skipping pallet validation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Implement StorageApiUnchecked for skipping pallet validation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Remove skip_pallet_validation boolean Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Implement ClientUnchecked for skipping metadata validation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update examples of rpc_call to skip metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Remove heck dependency Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add pallet name as an identifier for pallet hashing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Implement MetadataHashDetails Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Adjust testing to `MetadataHashDetails` interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Remove extra `pallet_name` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Fix clippy issue Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Change StorageApi to support `_unchecked` methods Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Change TransactionApi to support `_unchecked` methods Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Switch back from `TryFrom` to `From` for `subxt::Client` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen, subxt: Remove `ClientUnchecked` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Expose `validate_metadata` as validation of compatibility method Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Update to the new interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Update test integration to latest interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Check different pallet index order Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Check recursive type hashing Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Check recursive types registered in different order Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Fix recursive types warning Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Remove test assets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Extend tests to verify cached pallet values Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Add metadata compatiblity example Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Revert balance_transfer to initial form Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add ConstantsApi metadata check Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Modify tests to accomodate ConstantsApi changes Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Modify verified version Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Generate polkadot.rs from `0.9.18-4542a603cc-aarch64-macos` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Update polkadot_metadata.scale from `0.9.18-4542a603cc-aarch64-macos` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Update documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Modify default pallet usage Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Remove hex dependency Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Add MetadataTestType to capture complex types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Update tests to use complex types Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Check metadata correctness via extending pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Extend pallet hash with Events Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Extend pallet hash with constants Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Extend pallet hash with error Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Extend metadata compatibiliy with StorageApi and ConstantsApi Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Modify comments and documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Benchmarks for full validation and pallet validation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/benches: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Hash metadata just by inspecting the provided pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Make pallets generic over T for `AsRef<str>` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Expose the name of the pallets composing the metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/tests: Update polkadot.rs with pallets name Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Obtain metadata hash only by inspecting pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen,subxt: Extend the metadata hash to utilize just pallets Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/tests: Update polkadot.rs with client metadata has per pallet Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Test `get_metadata_per_pallet_hash` correctness Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/benches: Fix decode of metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * [static metadata] validate storage, calls and constants per call (#507) * validate storage, calls and constants per call * fix typo * cache per-thing hashing, move an Arc, remove some unused bits * create hash_cache to simplify metadata call/constant/storage caching * simplify/robustify the caching logic to help prevent mismatch between get and set * cargo fmt * Fix clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * bench the per-call metadata functions * metadata: Add test for `node_template_runtime_variant` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * ensure criteron cli opts work * group benchmarks and avoid unwrap issues * metadata: Check template runtime for handling the pallet swap order case Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Remove debug logs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Optimise by removing field's name and type_name and type's path Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Refactor `get_type_hash` to break recursion earlier Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add tests for `hash_cache` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add tests for checking Metadata Inner cache Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Check semantic changes inside enum and struct fields Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Add enums named differently with compatible semantic meaning Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Guard testing of release versions for `node_template_runtime` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Improve documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata/tests: Manually construct type of `node_template_runtimeL::Call` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * no more special Call handling, avoid a little cloning, and actually sort by name * remove unused deps and fmt * RuntimeMetadataLastVersion => RuntimeMetadataV14 * remove a bunch of allocations in the metadata hashing, speed up from ~17ms to ~5ms * update release docs to release metadata crate too * subxt: Remove codegen dependency Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Replace std RwLock with parking_lot Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/tests: Add ws address to `TestNodeProcess` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/tests: Add metadata validation integration test Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Allow setting metadata on the ClientBuilder Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/tests: Check incompatible metadatas Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Fix constant hashing for deterministic output Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/tests: Check metadata validation for constants Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/tests: Test validation for calls Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/tests: Test validation for storage Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Expose `set_metadata` for testing only Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Guard metadata tests under integration-tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: James Wilson <james@jsdw.me> |
||
|
|
698f0242f3 |
Propagate documentation to runtime API (#511)
* codegen: Propagate documentation for Constants Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Propagate documentation for `CompositeDef` wrapper Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Propagate docs for enum variant of `CompositeDef` wrapper Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Propagate docs for Storage entries Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Move docs from internal structs to methods of StorageApi Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Propagate the same docs for storage iter variants Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Move docs from call structs to methods of TransactionApi Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> |
||
|
|
cc0b1ec84a |
Read constants from metadata at runtime (#494)
* Read constants from metadata at runtime * Update polkadot codegen * Update polkadot.rs * Update polkadot.rs |
||
|
|
3d669f97c6 |
Simplify creating and signing extrinsics (#490)
* WIP extrinsic api updates * First pass done; now to get things compiling again * document and tweak new structs/traits * cargo check --all-targets now compiles without issue * Polkadot and Substrate take different extra params; support both * Fix transaction format (missing byte from AccountId -> Address) and fmt * Tweak Signer trait * Tweak comments and such in extrinsic params * check all examples against newer polkadot, add new one with params, import path tweaks * clippy fix, and save an allocation when signing * Remove unnecessary Default clauses * Tidy up and fix comments. Panic if payload size >4GB * fix typo |
||
|
|
8b19549560 |
Use RPC call to get account nonce (#476)
* remove code related to getting nonce from storage and use RPC call instead * cargo fmt * move nonce fetching into Rpc, since it's just an RPC call * clippy |
||
|
|
4144a769d5 |
Return events from blocks skipped over during Finalization, too (#473)
* make subscription stream generic in EventSubscription * rename to EventSub/FinalizedEventSub * wip fix some lifetimes so that event sub can depend on client in stream * Cargo fmt + comment tweaks * Add another comment * factor out prev block header fetching into a separate function to tidy * add a comment * remove ListOrValue as it's unused * Into<u128> on BlockNumber to simplify things * clippy * Fix an example and clippy * simplify iterator now we are Into<u128> * Into<u64> instead because it needs serializing, and test core logic * Tweak missing block test to fill in >=2 holes * tweak a comment |
||
|
|
08369f3e43 |
Reference key storage api (#447)
* codegen: Update polkadot.rs polkadot commit-hash: d96d3bea85 polkadot tag: v0.9.16-rc2 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Reference key storage api Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Regenerate polkadot.rs with reference api Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Update tests with reference interface Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cli: Fix polkadot.rs license check Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs with copyright Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "codegen: Update polkadot.rs with copyright" This reverts commit 2970d0573dc0b11d01072b270a525ad497992ddf. Revert "cli: Fix polkadot.rs license check" This reverts commit 6fe8818582ae39669c059c1ed0424b6606620295. * codegen: Implement AccountData trait in the expected order Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Store implementation of StorageEntry Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Generate AccountDefaultData wrapper struct Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Allow `Account` references Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Utilize AccountDefaultData instead of Account Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Update tests to utilize `Account` reference Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Rename AccountDefaultData to AccountOwned Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Add comments for wrapper account Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Obtain vector type parameter for TypePath::Type Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Use slices instead of `& std::vec` in storage API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Fix documentation Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Remove extra reference Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Add staking example to exercise storage API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Update polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Update storage tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Fix cargo clippy Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Simplify vec_type_param Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Rename staking_details.rs to fetch_staking_details.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * tests: Remove dummy variable Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Update polkadot version Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Apply rust-fmt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * codegen: Regenerate polkadot.rs Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Remove comment Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> |
||
|
|
d01fdd70d2 |
Substitute BTreeMap/BTreeSet generated types for Vec (#459)
* Substitute BTreeMap/BTreeSet for Vec * regen code * cargo fmt * undo test tweak since not substituting bounded things at the mo * add a couple of comments |
||
|
|
e866d744de |
Obtain DispatchError::Module info dynamically (#453)
* Add error information back into metadata to roll back removal in #394 * Go back to obtaining runtime error info * re-do codegen too to check that it's all gravy * Convert DispatchError module errors into a module variant to make them easier to work with * Fix broken doc link |
||
|
|
eeb8b4b741 |
Add hardcoded override to ElectionScore (#455)
* Add hardcoded override to ElectionScore so that we can give it the traits it needs * cargo fmt + another comment * copy over custom trait impls too |
||
|
|
cb9177aaa9 |
DispatchError::Module is now a tuple variant in latest Substrate (#439)
* ModuleError is now a tuple variant * more robust pointer to DispatchError * backward compat * clippy * cargo fmt * abort_call_site and simplify path comparison * clippy |
||
|
|
b1b717332e |
New Event Subscription API (#442)
* Add reworked event types * first pass implementing event subscriptions * make clear that some methods are private * comment tidy * use Events in transaction stuff * align transaction and event APIs * remove __private_ prefixes; they are ugly * fix examples and remove old events and subscription code * better comments on hidden event functions * re-add find_first_event; it's used a bunch in tests and examples * cargo check --all-targets now passes * Fix up existing event tests * cargo fmt * change todo to note * clippy and doc niggles * revert to find_first_event * Add specific subscription related tests * cargo fmt * Update tests and add/fix examples * cargo fmt * add a little to subscribe_all_events example * cargo fmt * move an example comment * easy access to root mod for more clarity * add a couple of tests to ensure that events properly decoded until naff bytes * Simplify EventSubscription Stream impl a little * Address some PR feedback |