Skip to content

Commit

Permalink
Pass Reference of External Call Context (#1141)
Browse files Browse the repository at this point in the history
* pass reference of external call context

* pass program as ref

* cargo fmt

* must use

* revert borrow
  • Loading branch information
samliok committed Jul 15, 2024
1 parent 8f7baa7 commit 9bda4d7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions x/programs/rust/examples/counter-external/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ use wasmlanche_sdk::{public, types::Address, Context, ExternalCallContext, Progr
#[public]
pub fn inc(_: Context, external: Program, address: Address) {
let ctx = ExternalCallContext::new(external, 1_000_000, 0);
counter::inc(ctx, address, 1);
counter::inc(&ctx, address, 1);
}

#[public]
pub fn get_value(_: Context, external: Program, address: Address) -> u64 {
let ctx = ExternalCallContext::new(external, 1_000_000, 0);
counter::get_value(ctx, address)
counter::get_value(&ctx, address)
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion x/programs/rust/sdk-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ pub fn public(_: TokenStream, item: TokenStream) -> TokenStream {
move |mut arg| {
if first {
first = false;
arg.ty = Box::new(parse_quote!(wasmlanche_sdk::ExternalCallContext));
arg.ty = Box::new(parse_quote!(&wasmlanche_sdk::ExternalCallContext));
}

FnArg::Typed(arg)
Expand Down

0 comments on commit 9bda4d7

Please sign in to comment.