-
Notifications
You must be signed in to change notification settings - Fork 254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support more types in Storage entry constructors #1105
Support more types in Storage entry constructors #1105
Conversation
CHANGELOG.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Screewed up CHANGELOG here too :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aah this is building off the other storage PR. For now maybe best to base the branch off the other PR so we only see the relevant changes here :)
fn primitive_type_alias(type_path: &TypePath) -> TokenStream { | ||
// Vec<T> is cast to [T] | ||
if let Some(ty) = type_path.vec_type_param() { | ||
return quote!([#ty]); | ||
} | ||
// String is cast to str | ||
if type_path.is_string() { | ||
return quote!(::core::primitive::str); | ||
} | ||
quote!(#type_path) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sensible to me :)
Bumps [serde](https://github.com/serde-rs/serde) from 1.0.179 to 1.0.183. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](serde-rs/serde@v1.0.179...v1.0.183) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [regex](https://github.com/rust-lang/regex) from 1.9.1 to 1.9.3. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](rust-lang/regex@1.9.1...1.9.3) --- updated-dependencies: - dependency-name: regex dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
6ecd755
into
tadeo-hepperle-support-iterating-over-n-maps-with-partial-keys
* implement partial key iters * format * make tests compile * fix docs and try example * 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> * Bump darling from 0.20.1 to 0.20.3 (#1085) Bumps [darling](https://github.com/TedDriggs/darling) from 0.20.1 to 0.20.3. - [Release notes](https://github.com/TedDriggs/darling/releases) - [Changelog](https://github.com/TedDriggs/darling/blob/master/CHANGELOG.md) - [Commits](TedDriggs/darling@v0.20.1...v0.20.3) --- updated-dependencies: - dependency-name: darling dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> * Bump either from 1.8.1 to 1.9.0 (#1084) Bumps [either](https://github.com/bluss/either) from 1.8.1 to 1.9.0. - [Commits](rayon-rs/either@1.8.1...1.9.0) --- updated-dependencies: - dependency-name: either dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> * Bump clap from 4.3.11 to 4.3.19 (#1083) Bumps [clap](https://github.com/clap-rs/clap) from 4.3.11 to 4.3.19. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](clap-rs/clap@v4.3.11...v4.3.19) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> Co-authored-by: Tadeo Hepperle <62739623+tadeohepperle@users.noreply.github.com> * Bump trybuild from 1.0.81 to 1.0.82 (#1082) Bumps [trybuild](https://github.com/dtolnay/trybuild) from 1.0.81 to 1.0.82. - [Release notes](https://github.com/dtolnay/trybuild/releases) - [Commits](dtolnay/trybuild@1.0.81...1.0.82) --- updated-dependencies: - dependency-name: trybuild dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> * Prep for 0.30.1 release (#1094) * Set minimum supported `rust-version` to `1.70` (#1097) * Bump serde_json from 1.0.103 to 1.0.104 (#1100) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.103 to 1.0.104. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](serde-rs/json@v1.0.103...v1.0.104) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump serde from 1.0.175 to 1.0.179 (#1101) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.175 to 1.0.179. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](serde-rs/serde@v1.0.175...v1.0.179) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Tests: support 'substrate-node' too and allow multiple binary paths (#1102) * Support 'substrate-node' too and allow multiple binary paths * fmt * clippy * fix path * adjust book * remove the partial iteration example. there was nothing good to show * revert spaces in changelog * Support more types in Storage entry constructors (#1105) * implement test for type alias being used * Bump serde from 1.0.179 to 1.0.183 (#1112) Bumps [serde](https://github.com/serde-rs/serde) from 1.0.179 to 1.0.183. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](serde-rs/serde@v1.0.179...v1.0.183) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump regex from 1.9.1 to 1.9.3 (#1110) Bumps [regex](https://github.com/rust-lang/regex) from 1.9.1 to 1.9.3. - [Release notes](https://github.com/rust-lang/regex/releases) - [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md) - [Commits](rust-lang/regex@1.9.1...1.9.3) --- updated-dependencies: - dependency-name: regex dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * revert yaml changes --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Update subxt/src/book/usage/storage.rs Co-authored-by: James Wilson <james@jsdw.me> * remove dynamic_iter * fix example * format * add example, adjust book * Update subxt/src/book/usage/storage.rs Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Jones <ascjones@gmail.com>
Fixes #610
This PR adds support for accessing storage items where the keys are of type
String
throughimpl Borrow<str>
to allow more flexibility (before it would have beenimpl Borrow<String>
). In Polkadot no storage item is currently accessed via String though.I added a function that makes it easy to add other rules and a test that validates that the code generation is working correctly. Currently it checks these types:
Vec<u8>
u8
Box<u16>
u16
String
str
&'static str
str
Cow<'_, str>
str