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

ast generation code for the new helper functions [WIP] #671

Draft
wants to merge 13 commits into
base: feat/helper-func
Choose a base branch
from

Conversation

j-yw
Copy link
Contributor

@j-yw j-yw commented Oct 14, 2024

This PR adds functionality to generate MsgHelpers, MsgHooks, QueryHelpers, QueryHooks

TODOS

  • Update Docs

TESTING

  • enabled: generate helper functions as expected.
  • genCustomHooks: generate hooks as expected.
  • include.serviceTypes: see if 'Query' | 'Msg' | 'All' working or not(to include expect results).
  • include.patterns: see if patterns working or not, e.g. : "**", "cosmos.bank.v1beta1.bala*", "cosmos.bank.v1beta1.allBalances", or any other patterns.(only generate method names that match the patterns)
  • nameMappers: to test preset mappers ("get", "unchanged") working or not.
  • nameMappers: to test a customized mapper for funcBody working or not.(like: (name: string) => "acquire"+ name )
  • nameMappers: to test prefixes working or not for creatorPrefix and hookPrefix with sth different than the default.

@j-yw j-yw requested a review from Zetazzz October 15, 2024 04:05
@Zetazzz
Copy link
Collaborator

Zetazzz commented Oct 16, 2024

For type names like: MsgSend, you can get it like this:

const requestType = svc.requestType;

@Zetazzz
Copy link
Collaborator

Zetazzz commented Oct 16, 2024

The problem with func type of "() => ISigningClient | undefined;"

I just reconsidered this, even though there's a way to generate the function type, but I think there's an approch that makes more sense.

There're this function type at several places, so better define it as a type. I've made the change in cca:

export type SigningClientResolver = () => ISigningClient | undefined;

https://github.com/cosmology-tech/create-cosmos-app/blob/35a286a1d2be2ac939b5449c08ff61efd8d7f872/examples/interchainjs/src/codegen/helper-func-types.ts#L163

please help make the change according to cca:
Helper files:
packages/telescope/src/helpers/helper-func-types.ts
packages/telescope/src/helpers/react-query-hooks.ts

Then you can use the type after context.addUtil(make sure the type is added to the map in utils/index.ts)

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 this pull request may close these issues.

2 participants