Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,23 @@ impl {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} {
{{/isInterface}}
{{#isInterface}}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}<'a> {
{{#isInterface}}uri: &'a str{{/isInterface}}
pub struct {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} {
{{#isInterface}}uri: String{{/isInterface}}
}

impl<'a> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}<'a> {
impl {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} {
pub const INTERFACE_URI: &'static str = "{{uri}}";

pub fn new(uri: &'a str) -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}}<'a> {
{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { uri: uri }
pub fn new(uri: String) -> {{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} {
{{#detectKeyword}}{{#toUpper}}{{type}}{{/toUpper}}{{/detectKeyword}} { uri }
}

{{#methods}}
pub fn {{#toLower}}{{name}}{{/toLower}}(&self, args: &Args{{#toUpper}}{{name}}{{/toUpper}}) -> Result<{{#return}}{{#toWasm}}{{toGraphQLType}}{{/toWasm}}{{/return}}, String> {
let uri = self.uri;
let ref uri = self.uri;
let args = serialize_{{#toLower}}{{name}}{{/toLower}}_args(args).map_err(|e| e.to_string())?;
let result = subinvoke::wrap_subinvoke(
uri,
uri.as_str(),
"{{name}}",
args,
)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,44 @@ use crate::TestImportEnum;
use crate::TestImportEnumReturn;

#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct TestImportModule<'a> {
uri: &'a str
pub struct TestImportModule {
uri: String
}

impl<'a> TestImportModule<'a> {
impl TestImportModule {
pub const INTERFACE_URI: &'static str = "testimport.uri.eth";

pub fn new(uri: &'a str) -> TestImportModule<'a> {
TestImportModule { uri: uri }
pub fn new(uri: String) -> TestImportModule {
TestImportModule { uri }
}

pub fn imported_method(&self, args: &ArgsImportedMethod) -> Result<Option<TestImportObject>, String> {
let uri = self.uri;
let ref uri = self.uri;
let args = serialize_imported_method_args(args).map_err(|e| e.to_string())?;
let result = subinvoke::wrap_subinvoke(
uri,
uri.as_str(),
"importedMethod",
args,
)?;
deserialize_imported_method_result(result.as_slice()).map_err(|e| e.to_string())
}

pub fn another_method(&self, args: &ArgsAnotherMethod) -> Result<i32, String> {
let uri = self.uri;
let ref uri = self.uri;
let args = serialize_another_method_args(args).map_err(|e| e.to_string())?;
let result = subinvoke::wrap_subinvoke(
uri,
uri.as_str(),
"anotherMethod",
args,
)?;
deserialize_another_method_result(result.as_slice()).map_err(|e| e.to_string())
}

pub fn returns_array_of_enums(&self, args: &ArgsReturnsArrayOfEnums) -> Result<Vec<Option<TestImportEnumReturn>>, String> {
let uri = self.uri;
let ref uri = self.uri;
let args = serialize_returns_array_of_enums_args(args).map_err(|e| e.to_string())?;
let result = subinvoke::wrap_subinvoke(
uri,
uri.as_str(),
"returnsArrayOfEnums",
args,
)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ pub fn module_method(args: ArgsModuleMethod) -> ImplementationType {

pub fn abstract_module_method(args: ArgsAbstractModuleMethod) -> String {
let impls = Interface::get_implementations();
let uri: String = impls[0].to_owned();
let module = InterfaceModule::new(&uri);
let module = InterfaceModule::new(impls[0].clone());
let method_args = interface_module::serialization::ArgsAbstractModuleMethod {
arg: interface_argument::InterfaceArgument {
str: args.arg.str
Expand Down