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

Generate clients for services using imported interface definition #141

Merged
merged 46 commits into from Jul 4, 2019

Conversation

@nhynes
Copy link
Collaborator

commented Jun 29, 2019

resolves #92
resolves #48
resolves #63
resolves #140
unblocks oasislabs/oasis-cli#20

Unresolved: clients for non-services (i.e. Rust version of oasis-client)]

  • convince self that design will permit dependency resolution
  • make payloads arrays instead of structs
  • test typedefs from imports
  • ui test for multiple defaults
  • ui test for invalid default fn
  • ui test for misspelled name in mantle::service!
  • ui test for interface type from non-interface

@nhynes nhynes changed the title Importer Generate clients for services using imported interface definition Jun 29, 2019

// Use the HIR type parameter, if it exists.
// Otherwise, the TyS has extra generics that were defined
// in the alias as concrete types (and will be present in the
// TyS substs).

This comment has been minimized.

Copy link
@nhynes

nhynes Jun 29, 2019

Author Collaborator

example:

type Result<T> = std::result::Result<T, String>;

the type of T must come from the HIR since the AdtDef only knows about placeholder T. The AdtDef does have the String, though, since it's part of the typedef.

@nhynes nhynes force-pushed the importer branch from cd6b990 to e0e11d1 Jul 2, 2019

nhynes added some commits Jun 28, 2019

@nhynes nhynes force-pushed the importer branch 2 times, most recently from 1150bb9 to 965216b Jul 2, 2019

nhynes added some commits Jul 2, 2019

@nhynes nhynes force-pushed the importer branch from 0859b08 to dbf7030 Jul 2, 2019

nhynes added some commits Jul 3, 2019

nhynes added some commits Jul 2, 2019

@nhynes nhynes force-pushed the importer branch from 0262764 to 6e1c8eb Jul 3, 2019

nhynes added some commits Jul 3, 2019

@nhynes nhynes force-pushed the importer branch from 6f64197 to 4c9bfa6 Jul 3, 2019

nhynes added some commits Jul 4, 2019

@nhynes nhynes requested review from armaniferrante and willscott Jul 4, 2019

@nhynes nhynes marked this pull request as ready for review Jul 4, 2019

@willscott
Copy link
Collaborator

left a comment

Can you add documentation of how the references get used? (and ideally how a dep on a binary .wasm works)

docker:
- image: oasislabs/rust:latest
environment:
PATH: /root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

This comment has been minimized.

Copy link
@willscott

willscott Jul 4, 2019

Collaborator

is all of this needed?

This comment has been minimized.

Copy link
@nhynes

nhynes Jul 4, 2019

Author Collaborator

circleci requires a new top-level definition for each parallel task. the PATH stuff is because I couldn't figure out how to get it to source bashrc. I'm not a huge fan, but it works. Feel free to push back and ask me to change it.

)
} else {
String::new()
};

let ctor_stmt = if crate::utils::unpack_syntax_ret(&ctor.decl.output).is_result {
format!(

This comment has been minimized.

Copy link
@willscott

willscott Jul 4, 2019

Collaborator

i don't suppose there's a way to not have this template as a string?

This comment has been minimized.

Copy link
@nhynes

nhynes Jul 4, 2019

Author Collaborator

Yes unless you want to re-parse the token stream using syn just so that you can quote it using quote and then re-parse the proc_macro2::TokenStream into rustc's TokenStream. You'd think otherwise, but quasi-quoting using quote is only slightly more ergonomic (repeat patterns and inline quotes) than string formatting.

Maybe someday I'll write a quote for rustc TokenStream, but not today.

@@ -208,7 +208,7 @@ impl ERC20Token {
if !self.admins.contains(&ctx.sender()) {
return Err(Error::AdminPrivilegesRequired);
}
self.total_supply += self.total_supply;
self.total_supply += amount;

This comment has been minimized.

Copy link
@nhynes

nhynes Jul 4, 2019

Author Collaborator

nhynes added some commits Jul 4, 2019

@nhynes nhynes merged commit 7ca5467 into master Jul 4, 2019

8 checks passed

ci/circleci: init Your tests passed on CircleCI!
Details
ci/circleci: test_auctions_example Your tests passed on CircleCI!
Details
ci/circleci: test_ballot_example Your tests passed on CircleCI!
Details
ci/circleci: test_idl Your tests passed on CircleCI!
Details
ci/circleci: test_imports Your tests passed on CircleCI!
Details
ci/circleci: test_messaging_example Your tests passed on CircleCI!
Details
ci/circleci: unit_test Your tests passed on CircleCI!
Details
ci/circleci: wasm_build Your tests passed on CircleCI!
Details

@nhynes nhynes deleted the importer branch Jul 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.