Skip to content

Commit

Permalink
Value and object representation overhaul (#879)
Browse files Browse the repository at this point in the history
This is the SDK adaptation of
stellar/rs-soroban-env#682, which we're going to
try writing collaboratively

---------

Co-authored-by: Dmytro Kozhevin <[email protected]>
Co-authored-by: Jay Geng <[email protected]>
  • Loading branch information
3 people authored Mar 9, 2023
1 parent 4fdb7e9 commit 754c43b
Show file tree
Hide file tree
Showing 41 changed files with 1,578 additions and 874 deletions.
19 changes: 13 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ soroban-token-spec = { version = "0.6.0", path = "soroban-token-spec" }
[workspace.dependencies.soroban-env-common]
version = "0.0.14"
git = "https://github.com/stellar/rs-soroban-env"
rev = "5695440da452837555d8f7f259cc33341fdf07b0"
rev = "a66f0815ba06a2f5328ac420950690fd1642f887"

[workspace.dependencies.soroban-env-guest]
version = "0.0.14"
git = "https://github.com/stellar/rs-soroban-env"
rev = "5695440da452837555d8f7f259cc33341fdf07b0"
rev = "a66f0815ba06a2f5328ac420950690fd1642f887"

[workspace.dependencies.soroban-env-host]
version = "0.0.14"
git = "https://github.com/stellar/rs-soroban-env"
rev = "5695440da452837555d8f7f259cc33341fdf07b0"
rev = "a66f0815ba06a2f5328ac420950690fd1642f887"

[workspace.dependencies.stellar-strkey]
version = "0.0.7"
Expand All @@ -56,7 +56,7 @@ git = "https://github.com/stellar/rs-stellar-strkey"
[workspace.dependencies.stellar-xdr]
version = "0.0.14"
git = "https://github.com/stellar/rs-stellar-xdr"
rev = "55f47d302a3bbcd34cf32bfcd28abccfaeffc5e0"
rev = "74999cea9be22fe20cb030d6e485795ab2269045"
default-features = false

# [patch."https://github.com/stellar/rs-soroban-env"]
Expand Down
29 changes: 10 additions & 19 deletions soroban-sdk-macros/src/derive_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,21 @@ pub fn derive_client(name: &str, fns: &[ClientFn]) -> TokenStream {
quote! {
#(#fn_attrs)*
pub fn #fn_ident(&self, #(#fn_input_types),*) -> #fn_output {
use soroban_sdk::IntoVal;
self.with_env(|env|
env.invoke_contract(
&self.contract_id,
&soroban_sdk::symbol!(#fn_name),
soroban_sdk::vec![&self.env, #(#fn_input_names.into_val(&self.env)),*],
)
use soroban_sdk::{IntoVal,FromVal};
self.env.invoke_contract(
&self.contract_id,
&soroban_sdk::Symbol::new(&self.env, &#fn_name),
soroban_sdk::vec![&self.env, #(#fn_input_names.into_val(&self.env)),*],
)
}

#(#fn_attrs)*
pub fn #fn_try_ident(&self, #(#fn_input_types),*) -> #fn_try_output {
use soroban_sdk::IntoVal;
self.with_env(|env|
env.try_invoke_contract(
&self.contract_id,
&soroban_sdk::symbol!(#fn_name),
soroban_sdk::vec![&self.env, #(#fn_input_names.into_val(&self.env)),*],
)
use soroban_sdk::{IntoVal,FromVal};
self.env.try_invoke_contract(
&self.contract_id,
&soroban_sdk::Symbol::new(&self.env, &#fn_name),
soroban_sdk::vec![&self.env, #(#fn_input_names.into_val(&self.env)),*],
)
}
}
Expand Down Expand Up @@ -198,11 +194,6 @@ pub fn derive_client(name: &str, fns: &[ClientFn]) -> TokenStream {
}
}

fn with_env<R>(&self, f: impl FnOnce(&soroban_sdk::Env) -> R) -> R {
let env = &self.env;
f(env)
}

#(#fns)*
}
}
Expand Down
Loading

0 comments on commit 754c43b

Please sign in to comment.