wasm-runtime

A wasm runtime
git clone https://git.parazyd.org/wasm-runtime
Log | Files | Refs | README | LICENSE

commit 7d37935a6ed58a5a4ebba68ff4fc2881ee6b88ae
parent 50353e36fa0c557b852b2502e22360f40e3e1390
Author: parazyd <parazyd@dyne.org>
Date:   Wed,  9 Mar 2022 16:48:31 +0100

sdk: Automatically set up wee_alloc as the global allocator on wasm32.

Diffstat:
Mdrk-sdk/Cargo.toml | 1+
Mdrk-sdk/src/lib.rs | 5+++++
Msmart-contract/src/lib.rs | 2+-
3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drk-sdk/Cargo.toml b/drk-sdk/Cargo.toml @@ -6,3 +6,4 @@ edition = "2021" [dependencies] borsh = "0.9.3" thiserror = "1.0.30" +wee_alloc = "0.4.5" diff --git a/drk-sdk/src/lib.rs b/drk-sdk/src/lib.rs @@ -1,3 +1,8 @@ pub mod entrypoint; pub mod error; pub mod log; + +// Set up global allocator by default +#[cfg(target_arch = "wasm32")] +#[global_allocator] +static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; diff --git a/smart-contract/src/lib.rs b/smart-contract/src/lib.rs @@ -19,7 +19,7 @@ fn process_instruction(ix: &[u8]) -> ContractResult { if args.a < args.b { return Err(ContractError::Custom(69)) } - + let sum = args.a + args.b; msg!("Hello from the VM runtime! Sum: {:?}", sum);