Skip to content

Commit

Permalink
Merge branch 'main' into harmonize_init_and_post_upgrade_1095
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Jan 17, 2025
2 parents c14622b + ef77a8d commit 16078a5
Show file tree
Hide file tree
Showing 37 changed files with 45 additions and 408 deletions.
Binary file modified canister_templates/experimental.wasm
Binary file not shown.
Binary file modified canister_templates/stable.wasm
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ export default Canister({
performanceCounter: query([], nat64, () => {
return ic.performanceCounter(0);
}),
// prints a message through the local replica's output
print: query([text], bool, (message) => {
ic.print(message);

return true;
}),
reject: query(
[text],
Manual(empty),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,6 @@ export function getTests(icApiCanister: ActorSubclass<_SERVICE>): Test {
);
});

// it('calls argData on the ic object with zero params', async () => {
// const result = await icApiCanister.argDataZeroParams();

// expect(Array.isArray(result)).toBe(true);
// expect(result.length).toBe(0);
// });

// it('calls argData on the ic object with a single param', async () => {
// const result = await icApiCanister.argDataOneParam(true);

// expect(result).toBe(true);
// });

// it('calls argData on the ic object with multiple params', async () => {
// const blobString = 'Surprise!';
// const blob = blobString.split('').map((char) => char.charCodeAt(0));
// const int = 127;
// const bool = true;
// const string = 'test';

// const result = await icApiCanister.argDataMultipleParams(
// blob,
// int,
// bool,
// string
// );

// const expected = {
// blob,
// int,
// boolean: bool,
// string
// };

// expect(result).toStrictEqual(expected);
// });

it('calls argDataRaw on the ic object', async () => {
const blobString = 'Surprise!';
const blob = Uint8Array.from(
Expand Down Expand Up @@ -132,12 +95,6 @@ export function getTests(icApiCanister: ActorSubclass<_SERVICE>): Test {
expect(result).toBeGreaterThan(0n);
});

it('calls print on the ic object', async () => {
const result = await icApiCanister.print('Hello World!');

expect(result).toBe(true);
});

it('calls reject on the ic object', async () => {
const rejectionMessage = 'Rejected!';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
Canister,
ic,
int,
Null,
query,
Expand Down Expand Up @@ -31,7 +30,7 @@ export default Canister({
return param;
}),
voidIsNotNull: query([], Void, () => {
ic.print(
console.info(
'Even though they are both None in Python, for Candid null and void are different.'
);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
isController,
performanceCounter,
Principal,
print,
query,
reject,
setCertifiedData,
Expand Down Expand Up @@ -132,14 +131,6 @@ export default class {
return performanceCounter(0);
}

// prints a message through the local replica's output
@query([IDL.Text], IDL.Bool)
print(message: string): boolean {
print(message);

return true;
}

@query([IDL.Text], IDL.Empty, { manual: true })
reject(message: string): void {
reject(message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IDL, print, query, update } from 'azle';
import { IDL, query, update } from 'azle';

const PartiallyNullRecord = IDL.Record({
firstItem: IDL.Int,
Expand Down Expand Up @@ -39,7 +39,7 @@ export default class {

@query
voidIsNotNull(): void {
print(
console.info(
'Even though they are both None in Python, for Candid null and void are different.'
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mod canister_version;
mod clear_timer;
mod cycles_burn;
mod data_certificate;
mod debug_print;
mod id;
mod is_controller;
mod method_name;
Expand All @@ -18,7 +19,6 @@ mod msg_cycles_available;
mod msg_cycles_refunded;
mod notify_raw;
mod performance_counter;
mod print;
mod reject;
mod reject_code;
mod reject_message;
Expand Down Expand Up @@ -125,6 +125,13 @@ pub fn register(context: &mut wasmedge_quickjs::Context) {
.into(),
);

ic.set(
"debugPrint",
context
.new_function::<debug_print::NativeFunction>("")
.into(),
);

ic.set("id", context.new_function::<id::NativeFunction>("").into());

ic.set(
Expand Down Expand Up @@ -176,11 +183,6 @@ pub fn register(context: &mut wasmedge_quickjs::Context) {
.into(),
);

ic.set(
"print",
context.new_function::<print::NativeFunction>("").into(),
);

ic.set(
"reject",
context.new_function::<reject::NativeFunction>("").into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod canister_version;
mod clear_timer;
mod cycles_burn;
mod data_certificate;
mod debug_print;
mod id;
mod is_controller;
mod method_name;
Expand All @@ -21,7 +22,6 @@ mod msg_cycles_available;
mod msg_cycles_refunded;
mod notify_raw;
mod performance_counter;
mod print;
mod reject;
mod reject_code;
mod reject_message;
Expand Down Expand Up @@ -77,6 +77,8 @@ pub fn register(ctx: Ctx) -> Result<()> {
data_certificate::get_function(ctx.clone()),
)?;

ic.set("debugPrint", debug_print::get_function(ctx.clone()))?;

ic.set("id", id::get_function(ctx.clone()))?;

ic.set("isController", is_controller::get_function(ctx.clone()))?;
Expand Down Expand Up @@ -105,8 +107,6 @@ pub fn register(ctx: Ctx) -> Result<()> {
performance_counter::get_function(ctx.clone()),
)?;

ic.set("print", print::get_function(ctx.clone()))?;

ic.set("reject", reject::get_function(ctx.clone()))?;

ic.set("rejectCode", reject_code::get_function(ctx.clone()))?;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/experimental/ic/azle_ic_experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export type AzleIcExperimental = {
// interceptor.
acceptMessage: () => void;
methodName: () => string;
print: (...args: any) => void;
debugPrint: (...args: any) => void;
reject: (message: string) => void;
rejectMessage: () => string;
trap: (message: string) => never;
Expand Down
2 changes: 0 additions & 2 deletions src/lib/experimental/ic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { msgCyclesRefunded } from './msg_cycles_refunded';
import { notify } from './notify';
import { notifyRaw } from './notify_raw';
import { performanceCounter } from './performance_counter';
import { print } from './print';
import { reject } from './reject';
import { rejectCode } from './reject_code';
import { rejectMessage } from './reject_message';
Expand Down Expand Up @@ -60,7 +59,6 @@ export const ic = {
notify,
notifyRaw,
performanceCounter,
print,
reject,
rejectCode,
rejectMessage,
Expand Down
15 changes: 0 additions & 15 deletions src/lib/experimental/ic/print.ts

This file was deleted.

11 changes: 9 additions & 2 deletions src/lib/stable/globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding';
import { AzleIcExperimental } from '../experimental/ic/azle_ic_experimental';
import { jsonReplacer } from '../stable/stable_structures/stable_json';
import { ExportedCanisterClass } from './canister_methods';
import { print } from './ic_apis';
import { AzleIcStable } from './ic_apis/azle_ic_stable';

declare global {
Expand Down Expand Up @@ -80,7 +79,15 @@ if (globalThis._azleInsideCanister === true) {
})
.join(' ');

print(jsonStringifiedArgs);
if (globalThis._azleIcStable !== undefined) {
return globalThis._azleIcStable.debugPrint(jsonStringifiedArgs);
} else if (globalThis._azleIcExperimental !== undefined) {
return globalThis._azleIcExperimental.debugPrint(
jsonStringifiedArgs
);
}

throw new Error(`No global debugPrint implementation found`);
};

globalThis.console = {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stable/ic_apis/azle_ic_stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type AzleIcStable = {
// interceptor.
acceptMessage: () => void;
methodName: () => string;
print: (...args: any) => void;
debugPrint: (...args: any) => void;
reject: (message: string) => void;
rejectMessage: () => string;
trap: (message: string) => never;
Expand Down
1 change: 0 additions & 1 deletion src/lib/stable/ic_apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export { msgCyclesAvailable } from './msg_cycles_available';
export { msgCyclesRefunded } from './msg_cycles_refunded';
export { notify } from './notify';
export { performanceCounter } from './performance_counter';
export { print } from './print';
export { reject } from './reject';
export { rejectCode, RejectionCode } from './reject_code';
export { rejectMessage } from './reject_message';
Expand Down
29 changes: 0 additions & 29 deletions src/lib/stable/ic_apis/print.ts

This file was deleted.

18 changes: 1 addition & 17 deletions the_azle_book/book/404.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/azle.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/candid.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/canisters_overview.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/cross_canister.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/cycles.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/deployment.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/examples.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/http.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/index.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/installation.html

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/internet_computer_overview.html

Large diffs are not rendered by default.

45 changes: 5 additions & 40 deletions the_azle_book/book/print.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion the_azle_book/book/searchindex.json

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions the_azle_book/book/timers.html

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion the_azle_book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
- [instruction counter](./reference/canister_apis/instruction_counter.md)
- [is controller](./reference/canister_apis/is_controller.md)
- [performance counter](./reference/canister_apis/performance_counter.md)
- [print](./reference/canister_apis/print.md)
- [set certified data](./reference/canister_apis/set_certified_data.md)
- [time](./reference/canister_apis/time.md)
- [trap](./reference/canister_apis/trap.md)
Expand Down
1 change: 0 additions & 1 deletion the_azle_book/src/reference/canister_apis/canister_apis.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- [instruction counter](./instruction_counter.md)
- [is controller](./is_controller.md)
- [performance counter](./performance_counter.md)
- [print](./print.md)
- [set certified data](./set_certified_data.md)
- [time](./time.md)
- [trap](./trap.md)
21 changes: 0 additions & 21 deletions the_azle_book/src/reference/canister_apis/print.md

This file was deleted.

0 comments on commit 16078a5

Please sign in to comment.