Skip to content

Commit

Permalink
cleaning up a few ic object things
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Oct 28, 2024
1 parent 8128e89 commit 2da8c34
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 18 deletions.
Binary file modified canister_templates/stable.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rquickjs::{Ctx, Function};
use rquickjs::{Ctx, Function, Result};

pub fn get_function(context: Ctx) -> Result<Function, rquickjs::Error> {
Function::new(context, || {
pub fn get_function(ctx: Ctx) -> Result<Function> {
Function::new(ctx, || {
ic_cdk::api::call::accept_message();
})
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use rquickjs::{Ctx, Function, TypedArray};
use rquickjs::{Ctx, Function, Result};

pub fn get_function(context: Ctx) -> Result<Function, rquickjs::Error> {
Function::new(context.clone(), move || {
TypedArray::<u8>::new(context.clone(), ic_cdk::api::call::arg_data_raw())
})
pub fn get_function(ctx: Ctx) -> Result<Function> {
Function::new(ctx, || ic_cdk::api::call::arg_data_raw())
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rquickjs::{Ctx, Function, Result, TypedArray};

pub fn get_function(context: Ctx) -> Result<Function> {
Function::new(context.clone(), move || {
TypedArray::<u8>::new(context.clone(), ic_cdk::api::caller().as_slice())
pub fn get_function(ctx: Ctx) -> Result<Function> {
Function::new(ctx.clone(), move || {
TypedArray::<u8>::new(ctx.clone(), ic_cdk::api::caller().as_slice())
})
}
Original file line number Diff line number Diff line change
@@ -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> {
Function::new(ctx, |candid_path: String| {
let (env, actor) = pretty_check_file(Path::new(&candid_path)).unwrap();

compile(&env, &actor)
})
.unwrap()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2da8c34

Please sign in to comment.