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

Aether Features #350

Closed
wants to merge 7 commits into from
Closed

Aether Features #350

wants to merge 7 commits into from

Conversation

CyberHoward
Copy link
Contributor

Features required for the Abstract GraphQL Rust API.

  • Async query fn generation
  • Loosen trait bounds where applicable

Copy link

cloudflare-pages bot commented Mar 21, 2024

Deploying cw-orchestrator with  Cloudflare Pages  Cloudflare Pages

Latest commit: 908e430
Status: ✅  Deploy successful!
Preview URL: https://d0e1b657.cw-orchestrator.pages.dev
Branch Preview URL: https://aether-changes.cw-orchestrator.pages.dev

View logs

@@ -127,6 +127,23 @@ impl DaemonAsync {
Ok(result)
}

/// Query a contract.
pub async fn query<Q: Serialize + Debug, T: Serialize + DeserializeOwned>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is copy-pasting the smart_query from the AsyncWasmQuerier trait. Implement just once please

@@ -250,22 +250,19 @@ pub fn interface(attrs: TokenStream, input: TokenStream) -> TokenStream {
}

#[cfg(not(target_arch = "wasm32"))]
impl<Chain: ::cw_orch::prelude::CwEnv, #all_generics> ::cw_orch::prelude::InstantiableContract for #name<Chain, #all_generics> #all_debug_serialize {
type InstantiateMsg = #init;
impl<Chain, #all_generics> ::cw_orch::prelude::QueryableContract for #name<Chain, #all_generics> #all_debug_serialize {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the order of functions here ?

@@ -48,3 +48,11 @@ pub trait WasmQuerier: Querier {
salt: cosmwasm_std::Binary,
) -> Result<String, Self::Error>;
}

pub trait AsyncWasmQuerier: Querier {
async fn smart_query<Q: Serialize, T: DeserializeOwned>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about those clippy warnings ? Can we use async traits fn in traits now ? Nice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so we should add send bound for sure (as that enables multi-threaded application)

Also we can use this crate mentioned in that post to create a variant with / without the Send constraint: https://crates.io/crates/trait-variant

We might need this for the async -> sync wrapping that we do (i.e. use the non-send trait in that context). But the compiler will help us figure that out.

expand
}

pub fn async_query_fns_derive(input: ItemEnum) -> proc_macro2::TokenStream {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we have a common function with query_fns_derive, with only some differences (for maintainability) because this seems very close to the sync one

let expand = quote!(
#derived_trait

#derived_trait_impl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For instance here you need to target-flag this derive_trait_impl just like for the sync case. Better merge those into a common function

@CyberHoward
Copy link
Contributor Author

This is a very rough draft. We should sync on what we can cherry pick from this to include in cw-orch.

@Kayanski
Copy link
Contributor

Closing in favor of #413

@Kayanski Kayanski closed this Jun 11, 2024
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.

None yet

2 participants