Skip to content
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

Provide implementations of Permill, Perbill etc in Subxt? #1170

Open
jsdw opened this issue Sep 23, 2023 · 2 comments
Open

Provide implementations of Permill, Perbill etc in Subxt? #1170

jsdw opened this issue Sep 23, 2023 · 2 comments
Labels
needs thought We need to resolve some questions before we can work on this

Comments

@jsdw
Copy link
Collaborator

jsdw commented Sep 23, 2023

We fixed decoding into the generated Permill etc types a short while ago, but the types also have a bunch of custom logic and such. Currently, to work with them properly, one would have to pull in sp_arithmetic and convert the decoded parts into the proper types manually.

Perhaps we could either:

  • Pull in sp-arithmetic and just substitute for the "proper" types. (sp-arithmetic doesn't look like it depends on much, so I think this would be fairly doable), or
  • Make some concise implementations of the types ourselves in Subxt if pulling in the above is a pain for some reason. (I think we'd rather not do this)
  • Leave things as they are and people will have to manually convert the types to use them.

Types are defined here: https://github.com/paritytech/polkadot-sdk/blob/master/substrate/primitives/arithmetic/src/per_things.rs#L1864

@tadeohepperle
Copy link
Contributor

I figured out that pulling in sp-arithmetic if the substrate-compat feature flag is enabled and exposing it as subxt::ext::sp-arithmetic does not cost us much, because sp-arithmetic is already a dependency to sp-runtime.

Regarding substitutes in the codegen, I would like to have the substrate-compat feature propagate through subxt-macro to subxt-codegen. Then in the codegen, we can replace all type paths that start with sp_arithmetic::, sp_runtime:: or sp_core:: by subxt::ext::sp_arithmetic::..., subxt::ext::sp_runtime::... and subxt::ext::sp_core::....

@jsdw
Copy link
Collaborator Author

jsdw commented Sep 29, 2023

I'd rather avoid spreading the "substrate-compat" feature flag myself; ideally I'd like to get rid of it altogether eventually, rather than adding more things which can vary depending on it.

@tadeohepperle tadeohepperle added the needs thought We need to resolve some questions before we can work on this label Nov 21, 2023
@tadeohepperle tadeohepperle removed their assignment Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs thought We need to resolve some questions before we can work on this
Projects
None yet
2 participants