Skip to content

Commit

Permalink
clean up warnings, move modules
Browse files Browse the repository at this point in the history
  • Loading branch information
lastmjs committed Aug 20, 2024
1 parent e160719 commit 9cbafcb
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 52 deletions.
Binary file modified canister_templates/experimental.wasm
Binary file not shown.
Binary file modified canister_templates/stable.wasm
Binary file not shown.
8 changes: 3 additions & 5 deletions src/compiler/file_watcher/file_watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ok } from '../utils/result';
type ActorReloadJs = ActorSubclass<_SERVICE>;
interface _SERVICE {
_azle_reload_js: ActorMethod<
[bigint, bigint, Uint8Array, bigint, number, boolean],
[bigint, bigint, Uint8Array, bigint, number],
void
>;
}
Expand Down Expand Up @@ -105,8 +105,7 @@ async function reloadJs(
chunkNumber,
chunk,
BigInt(reloadedJs.length),
postUpgradeIndex,
experimental
postUpgradeIndex
)
.catch((error) => {
if (process.env.AZLE_VERBOSE === 'true') {
Expand Down Expand Up @@ -139,8 +138,7 @@ async function createActorReloadJs(
IDL.Nat64,
IDL.Vec(IDL.Nat8),
IDL.Nat64,
IDL.Int32,
IDL.Bool
IDL.Int32
],
[],
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn reload_js(
js_bytes: Vec<u8>,
total_len: u64,
function_index: i32,
experimental: bool,
) {
RELOADED_JS_TIMESTAMP.with(|reloaded_js_timestamp| {
let mut reloaded_js_timestamp_mut = reloaded_js_timestamp.borrow_mut();
Expand All @@ -37,7 +36,7 @@ pub fn reload_js(

if reloaded_js_complete_bytes.len() as u64 == total_len {
let js_string = String::from_utf8_lossy(&reloaded_js_complete_bytes);
initialize_js(&js_string, false, function_index, 1, experimental); // TODO should the last arg be 0?
initialize_js(&js_string, false, function_index, 1, true); // TODO should the last arg be 0?
ic_cdk::println!("Azle: Reloaded canister JavaScript");
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/rust/canister/src/candid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub fn get_candid_pointer(experimental: i32) -> *mut std::os::raw::c_char {
ic_cdk::println!("{}", message);
}));

RUNTIME.with(|runtime| {
RUNTIME.with(|_| {
let mut runtime = wasmedge_quickjs::Runtime::new();

runtime.run_with_context(|context| {
Expand Down
1 change: 1 addition & 0 deletions src/compiler/rust/canister/src/chunk.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(unused)]
pub async fn chunk() {
let id = ic_cdk::id();
let method = "_azle_chunk";
Expand Down
1 change: 1 addition & 0 deletions src/compiler/rust/canister/src/guards.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(unused)]
pub fn guard_against_non_controllers() -> Result<(), String> {
if ic_cdk::api::is_controller(&ic_cdk::api::caller()) {
return Ok(());
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/rust/canister/src/init_and_post_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub fn initialize_js(
) {
let mut rt = wasmedge_quickjs::Runtime::new();

let r = rt.run_with_context(|context| {
rt.run_with_context(|context| {
ic::register(context);

#[cfg(feature = "experimental")]
Expand Down
28 changes: 5 additions & 23 deletions src/compiler/rust/canister/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
use std::{
cell::RefCell,
collections::{BTreeMap, HashMap},
convert::TryInto,
env::args,
};
use std::cell::RefCell;

#[allow(unused)]
use guards::guard_against_non_controllers;
use ic_stable_structures::{
memory_manager::{MemoryId, MemoryManager, VirtualMemory},
storable::Bound,
DefaultMemoryImpl, StableBTreeMap, Storable,
memory_manager::{MemoryManager, VirtualMemory},
DefaultMemoryImpl,
};
use std::fs;
use wasmedge_quickjs::AsObject;

#[cfg(feature = "experimental")]
mod autoreload;
Expand All @@ -29,9 +22,6 @@ mod wasm_binary_manipulation;
#[cfg(feature = "experimental")]
mod web_assembly;

#[cfg(feature = "experimental")]
use open_value_sharing::{PeriodicBatch, PERIODIC_BATCHES};

#[allow(unused)]
type Memory = VirtualMemory<DefaultMemoryImpl>;

Expand Down Expand Up @@ -65,16 +55,8 @@ fn _azle_reload_js(
js_bytes: Vec<u8>,
total_len: u64,
function_index: i32,
experimental: bool, // TODO we should be able to get rid of this parameter
) {
autoreload::reload_js(
timestamp,
chunk_number,
js_bytes,
total_len,
function_index,
experimental, // TODO we should be able to get rid of this argument
);
autoreload::reload_js(timestamp, chunk_number, js_bytes, total_len, function_index);
}

#[cfg(feature = "experimental")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
use std::{
cell::RefCell,
collections::{BTreeMap, HashMap},
convert::TryInto,
env::args,
};

use ic_stable_structures::{
memory_manager::{MemoryId, MemoryManager, VirtualMemory},
storable::Bound,
DefaultMemoryImpl, StableBTreeMap, Storable,
};
use std::{cell::RefCell, collections::BTreeMap};

use ic_stable_structures::{storable::Bound, StableBTreeMap, Storable};

use crate::Memory;

Expand Down
13 changes: 5 additions & 8 deletions src/compiler/rust/canister/src/wasm_binary_manipulation.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[allow(unused)]
use open_value_sharing::Consumer;
use serde::{Deserialize, Serialize};

Expand Down Expand Up @@ -26,13 +27,11 @@ extern "C" fn js_passive_data_size() -> usize {

// TODO waiting on license inspired from https://github.com/adambratschikaye/wasm-inject-data/blob/main/src/static_wasm.rs
pub fn get_js_code() -> Vec<u8> {
let size = unsafe { js_passive_data_size() };
let size = js_passive_data_size();
let mut js_vec = vec![243; size];
let js_vec_location = js_vec.as_mut_ptr() as i32;

unsafe {
init_js_passive_data(js_vec_location);
}
init_js_passive_data(js_vec_location);

js_vec
}
Expand All @@ -53,13 +52,11 @@ extern "C" fn wasm_data_passive_data_size() -> usize {

// TODO waiting on license inspired from https://github.com/adambratschikaye/wasm-inject-data/blob/main/src/static_wasm.rs
pub fn get_wasm_data() -> WasmData {
let size = unsafe { wasm_data_passive_data_size() };
let size = wasm_data_passive_data_size();
let mut wasm_data_vec = vec![243; size];
let wasm_data_vec_location = wasm_data_vec.as_mut_ptr() as i32;

unsafe {
init_wasm_data_passive_data(wasm_data_vec_location);
}
init_wasm_data_passive_data(wasm_data_vec_location);

serde_json::from_str(std::str::from_utf8(&wasm_data_vec).unwrap()).unwrap()
}

0 comments on commit 9cbafcb

Please sign in to comment.