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

[feature request] Type substitution from CLI for codegen command #851

Closed
deuszx opened this issue Mar 8, 2023 · 1 comment · Fixed by #886
Closed

[feature request] Type substitution from CLI for codegen command #851

deuszx opened this issue Mar 8, 2023 · 1 comment · Fixed by #886

Comments

@deuszx
Copy link

deuszx commented Mar 8, 2023

As in the title - it would be nice to be able to substitute types when generating API via codegen.

0.26.0 release changed, among many things, what AccountId32 type is: previously it was subxt::ext::sp_core::crypto::AccountId32 and now it's subxt::utils::AccountId32. Even when re-exporting sp_core and sp_runtime these types will remain the same - subxt::utils::AccountId32. It would be nice either opt-out from the default substitutions (from the CLI) or override it.

The UX could be:

subxt codegen --url ${NODE_URL} \
	--derive Debug --derive Clone ... \
	--substitute type::from::A:type::into::APrime \
    --substitute type::from::B:type::into::BPrime \
    | rustfmt ... > node_api.rs

EDIT: Alternatively, we could introduce an argument --substrate-impl (to follow the feature from base subxt) that would use sp_core::* types automatically.

@jsdw
Copy link
Collaborator

jsdw commented Mar 14, 2023

Interesting; yeah it def makes sense to expose the substitute type stuff in codegen! Ideally we'd expose the full power of the substitute API also and allow for generics to be substituted too. The --derive-for-type flag accepts something like path::to::TypeName=SomeDerive, so I'd be inclined to go for--substitute-type path::to::TypeName<MaybeGenerics>=MySubstituteType<MaybeGenerics>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants