Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stable in experimental tests #2268

Merged
merged 3 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified canister_templates/experimental.wasm
Binary file not shown.
Binary file modified canister_templates/stable.wasm
Binary file not shown.
14 changes: 7 additions & 7 deletions src/lib/stable/ic_apis/azle_ic_stable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export type AzleIcStable = {
candidDecode: (candidBytes: Uint8Array) => string;
candidEncode: (candidString: string) => Uint8Array;
canisterBalance: () => string;
canisterVersion: () => bigint;
canisterVersion: () => number;
bdemann marked this conversation as resolved.
Show resolved Hide resolved
clearTimer: (timerId: string) => void;
cyclesBurn: (amountString: string) => string;
dataCertificate: () => Uint8Array | undefined;
id: () => Uint8Array;
instructionCounter: () => bigint;
instructionCounter: () => number;
isController: (principalBytes: Uint8Array) => boolean;
msgCyclesAccept: (maxAmountString: string) => string;
msgCyclesAvailable: () => string;
Expand All @@ -32,13 +32,13 @@ export type AzleIcStable = {
argsRawBuffer: Uint8Array,
cyclesString: string
) => void;
performanceCounter: (counterType: number) => bigint;
performanceCounter: (counterType: number) => number;
rejectCode: () => number;
replyRaw: (bytes: Uint8Array) => void;
setCertifiedData: (dataBytes: Uint8Array) => void;
setTimer: (delay: string, timerCallbackId: string) => bigint;
setTimerInterval: (interval: string, timerCallbackId: string) => bigint;
time: () => bigint;
setTimer: (delay: string, timerCallbackId: string) => number;
setTimerInterval: (interval: string, timerCallbackId: string) => number;
time: () => number;
// These calls aren't intercepted by our IC object, they go right to the
// rust version and come out. Since they don't need to be intercepted I am
// assuming that their types are the same as the types declared by our
Expand Down Expand Up @@ -82,7 +82,7 @@ export type AzleIcStable = {
startIndex: number,
length: number
) => Uint8Array[];
stableBTreeMapLen: (memoryId: number) => bigint;
stableBTreeMapLen: (memoryId: number) => number;
stableBTreeMapRemove(memoryId: number, encodedKey: Uint8Array): Uint8Array;
stableBTreeMapValues: (
memoryId: number,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/stable/ic_apis/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ export async function call<Args extends any[] | undefined, Return = any>(
// TODO for example, we can keep the time with these
// TODO if they are over a certain amount old we can delete them
globalThis._azleResolveIds[globalResolveId] = (
result: Uint8Array
result: Uint8Array | ArrayBuffer
): void => {
if (raw !== undefined) {
resolve(result as Return);
resolve(new Uint8Array(result) as Return);
} else {
const idlType =
returnTypeIdl === undefined ? [] : [returnTypeIdl];
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stable/ic_apis/canister_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export function canisterVersion(): bigint {
return BigInt(globalThis._azleIcExperimental.canisterVersion());
}

return globalThis._azleIcStable.canisterVersion();
return BigInt(globalThis._azleIcStable.canisterVersion());
}
2 changes: 1 addition & 1 deletion src/lib/stable/ic_apis/instruction_counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export function instructionCounter(): bigint {
return BigInt(globalThis._azleIcExperimental.instructionCounter());
}

return globalThis._azleIcStable.instructionCounter();
return BigInt(globalThis._azleIcStable.instructionCounter());
}
2 changes: 1 addition & 1 deletion src/lib/stable/ic_apis/performance_counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ export function performanceCounter(counterType: number): bigint {
);
}

return globalThis._azleIcStable.performanceCounter(counterType);
return BigInt(globalThis._azleIcStable.performanceCounter(counterType));
}
10 changes: 4 additions & 6 deletions src/lib/stable/ic_apis/set_timer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ export function setTimer(

const timerId =
globalThis._azleIcExperimental !== undefined
? BigInt(
globalThis._azleIcExperimental.setTimer(
delay.toString(),
timerCallbackId
)
? globalThis._azleIcExperimental.setTimer(
delay.toString(),
timerCallbackId
)
: globalThis._azleIcStable.setTimer(
delay.toString(),
Expand All @@ -46,5 +44,5 @@ export function setTimer(
}
};

return timerId;
return BigInt(timerId);
}
10 changes: 4 additions & 6 deletions src/lib/stable/ic_apis/set_timer_interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ export function setTimerInterval(

const timerId =
globalThis._azleIcExperimental !== undefined
? BigInt(
globalThis._azleIcExperimental.setTimerInterval(
interval.toString(),
timerCallbackId
)
? globalThis._azleIcExperimental.setTimerInterval(
interval.toString(),
timerCallbackId
)
: globalThis._azleIcStable.setTimerInterval(
interval.toString(),
Expand All @@ -41,5 +39,5 @@ export function setTimerInterval(
// it still needs to be here for the next tick
globalThis._azleTimerCallbacks[timerCallbackId] = callback;

return timerId;
return BigInt(timerId);
}
2 changes: 1 addition & 1 deletion src/lib/stable/ic_apis/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export function time(): bigint {
return BigInt(globalThis._azleIcExperimental.time());
}

return globalThis._azleIcStable.time();
return BigInt(globalThis._azleIcStable.time());
}
Loading