Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Jul 2, 2024
1 parent f8f0c58 commit 1e90d8c
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 22 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ jobs:
"tests/end_to_end/candid_rpc/class_syntax/timers",
"tests/end_to_end/candid_rpc/class_syntax/tuple_types",
"tests/end_to_end/candid_rpc/class_syntax/update",
"tests/end_to_end/candid_rpc/class_syntax/vanilla_js",
]
END
)
Expand Down
4 changes: 4 additions & 0 deletions src/lib/stable/globals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { TextDecoder, TextEncoder } from 'text-encoding';

globalThis.TextDecoder = TextDecoder;
globalThis.TextEncoder = TextEncoder;
1 change: 1 addition & 0 deletions src/lib/stable/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './globals';
export * from '../stable_structures/stable_b_tree_map';
export * from '../stable_structures/stable_json';
export { heartbeat } from './heartbeat';
Expand Down
20 changes: 8 additions & 12 deletions src/lib/stable/system_types/rejection_code.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { IDL } from '..';
import { IDL } from '@dfinity/candid';

/**
* Indicates an error was encountered during a canister method.
*/
export const RejectionCode = IDL.Variant({
NoError: IDL.Null
// TODO we are getting some sort of error when all of these are added in. It
// is happening during what looks like a sort of the properties (which might
// explain why one is fine (it doesn't need to be sorted)). The error is
// ReferenceError: 'TextEncoder' is not defined
// SysFatal: IDL.Null,
// SysTransient: IDL.Null,
// DestinationInvalid: IDL.Null
// CanisterReject: IDL.Null,
// CanisterError: IDL.Null,
// Unknown: IDL.Null,
NoError: IDL.Null,
SysFatal: IDL.Null,
SysTransient: IDL.Null,
DestinationInvalid: IDL.Null,
CanisterReject: IDL.Null,
CanisterError: IDL.Null,
Unknown: IDL.Null
});

export type RejectionCode =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export default class {
fee: bigint,
createdAtTime: [bigint] | []
) {
const created_at_time =
createdAtTime.length === 0
? []
: [{ timestamp_nanos: createdAtTime[0] }];
return await call(getIcpCanisterPrincipal(), 'transfer', {
paramIdls: [TransferArgs],
returnIdl: TransferResult,
Expand All @@ -39,7 +43,7 @@ export default class {
},
from_subaccount: [],
to: binaryAddressFromAddress(to),
created_at_time: createdAtTime
created_at_time
}
]
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ export default class {
@update([CanisterStatusArgs], CanisterStatusResult)
async getCanisterStatus(
args: CanisterStatusArgs
): Promise<CanisterInfoResult> {
): Promise<CanisterStatusResult> {
return await call('aaaaa-aa', 'canister_status', {
paramIdls: [CanisterStatusArgs],
returnIdl: CanisterInfoResult,
returnIdl: CanisterStatusResult,
args: [args]
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
export default class {
@update([], RejectionCode)
async getRejectionCodeNoError() {
await call(getSomeCanisterPrincipal(), 'accept');
await call(getSomeCanisterPrincipal(), 'accept', {
returnIdl: IDL.Bool
});

return rejectCode();
}
Expand All @@ -30,6 +32,7 @@ export default class {
async getRejectionCodeCanisterReject() {
try {
await call(getSomeCanisterPrincipal(), 'reject', {
paramIdls: [IDL.Text],
args: ['reject']
});
} catch (error) {
Expand All @@ -54,6 +57,7 @@ export default class {
async getRejectionMessage(message: string) {
try {
await call(getSomeCanisterPrincipal(), 'reject', {
paramIdls: [IDL.Text],
args: [message]
});
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import { IDL, query, reject } from 'azle';

export default class {
@query([IDL.Text], IDL.Empty, { manual: true })
reject(message: string) {
reject(message: string): void {
reject(message);
}

@query([], IDL.Bool)
accept() {
accept(): boolean {
return true;
}

@query([], IDL.Empty, { manual: true })
error() {
error(): void {
// This errors because neither ic.reject nor ic.reply were called
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1e90d8c

Please sign in to comment.