diff --git a/canister_templates/stable.wasm b/canister_templates/stable.wasm index 5407a7a94e..8533b7fe64 100644 Binary files a/canister_templates/stable.wasm and b/canister_templates/stable.wasm differ diff --git a/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/accept_message.rs b/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/accept_message.rs index 397d574334..5805c0fe53 100644 --- a/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/accept_message.rs +++ b/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/accept_message.rs @@ -1,7 +1,7 @@ -use rquickjs::{Ctx, Function}; +use rquickjs::{Ctx, Function, Result}; -pub fn get_function(context: Ctx) -> Result { - Function::new(context, || { +pub fn get_function(ctx: Ctx) -> Result { + Function::new(ctx, || { ic_cdk::api::call::accept_message(); }) } diff --git a/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/arg_data_raw.rs b/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/arg_data_raw.rs index cbf16b11a2..f9745cd383 100644 --- a/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/arg_data_raw.rs +++ b/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/arg_data_raw.rs @@ -1,7 +1,5 @@ -use rquickjs::{Ctx, Function, TypedArray}; +use rquickjs::{Ctx, Function, Result}; -pub fn get_function(context: Ctx) -> Result { - Function::new(context.clone(), move || { - TypedArray::::new(context.clone(), ic_cdk::api::call::arg_data_raw()) - }) +pub fn get_function(ctx: Ctx) -> Result { + Function::new(ctx, || ic_cdk::api::call::arg_data_raw()) } diff --git a/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/caller.rs b/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/caller.rs index 31fe0bae5c..98e8246c48 100644 --- a/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/caller.rs +++ b/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/caller.rs @@ -1,7 +1,7 @@ use rquickjs::{Ctx, Function, Result, TypedArray}; -pub fn get_function(context: Ctx) -> Result { - Function::new(context.clone(), move || { - TypedArray::::new(context.clone(), ic_cdk::api::caller().as_slice()) +pub fn get_function(ctx: Ctx) -> Result { + Function::new(ctx.clone(), move || { + TypedArray::::new(ctx.clone(), ic_cdk::api::caller().as_slice()) }) } diff --git a/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/candid_compiler.rs b/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/candid_compiler.rs index 2fec0196bb..e23599f6ab 100644 --- a/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/candid_compiler.rs +++ b/src/build/stable/commands/compile/wasm_binary/rust/stable_canister_template/src/ic/candid_compiler.rs @@ -1,11 +1,12 @@ -use rquickjs::{Ctx, Function}; use std::path::Path; -pub fn get_function(context: Ctx) -> Function { - Function::new(context, |candid_path: String| { - let (env, actor) = candid_parser::pretty_check_file(Path::new(&candid_path)).unwrap(); +use candid_parser::{bindings::javascript::compile, pretty_check_file}; +use rquickjs::{Ctx, Function, Result}; - candid_parser::bindings::javascript::compile(&env, &actor) +pub fn get_function(ctx: Ctx) -> Result { + Function::new(ctx, |candid_path: String| { + let (env, actor) = pretty_check_file(Path::new(&candid_path)).unwrap(); + + compile(&env, &actor) }) - .unwrap() } diff --git a/tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls/test/tests.ts b/tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls/test/tests.ts index 61aeaaf8ba..90364cfdb6 100644 --- a/tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls/test/tests.ts +++ b/tests/end_to_end/candid_rpc/functional_syntax/cross_canister_calls/test/tests.ts @@ -103,7 +103,7 @@ export function getTests( const canister1Id = getCanisterId('canister1'); const canister2Id = getCanisterId('canister2'); const partialErrorMessage = new RegExp( - `Error from Canister ${canister1Id}: Canister called \`ic0.trap\` with message: Uncaught Error: Rejection code 5, IC0503: Error from Canister ${canister2Id}: Canister called \`ic0.trap\` with message: hahahaha` + `Error from Canister ${canister1Id}: Canister called \`ic0.trap\` with message: Uncaught Error: Error: Rejection code 5, IC0503: Error from Canister ${canister2Id}: Canister called \`ic0.trap\` with message: hahahaha` ); await expect(canister1.trap()).rejects.toThrow(partialErrorMessage);