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

add responses prop test #2180

Merged
merged 26 commits into from
Nov 26, 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
2 changes: 1 addition & 1 deletion src/lib/stable/ic_apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export { notify } from './notify';
export { performanceCounter } from './performance_counter';
export { print } from './print';
export { reject } from './reject';
export { rejectCode } from './reject_code';
export { rejectCode, RejectionCode } from './reject_code';
export { rejectMessage } from './reject_message';
export { reply } from './reply';
export { setCertifiedData } from './set_certified_data';
Expand Down
19 changes: 18 additions & 1 deletion src/lib/stable/ic_apis/reject_code.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
type RejectionCode =
// TODO this should be removed once https://github.com/demergent-labs/azle/issues/2271 is resolved
import { TextDecoder, TextEncoder } from 'text-encoding';
globalThis.TextDecoder = TextDecoder;
globalThis.TextEncoder = TextEncoder;

import { IDL } from '@dfinity/candid';

export type RejectionCode =
| { NoError: null }
| { SysFatal: null }
| { SysTransient: null }
Expand All @@ -7,6 +14,16 @@ type RejectionCode =
| { CanisterError: null }
| { Unknown: null };

export const RejectionCode = IDL.Variant({
NoError: IDL.Null,
SysFatal: IDL.Null,
SysTransient: IDL.Null,
DestinationInvalid: IDL.Null,
CanisterReject: IDL.Null,
CanisterError: IDL.Null,
Unknown: IDL.Null
});

/**
* Returns the rejection code from the most recently executed cross-canister call
* @returns the rejection code
Expand Down
4 changes: 4 additions & 0 deletions tests/property/ic_api/reject/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.azle
.dfx
dfx_generated
node_modules
12 changes: 12 additions & 0 deletions tests/property/ic_api/reject/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"canisters": {
"canister": {
"type": "azle",
"main": "src/index.ts",
"declarations": {
"output": "test/dfx_generated/canister",
"node_compatibility": true
}
}
}
}
11 changes: 11 additions & 0 deletions tests/property/ic_api/reject/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testTimeout: 100_000_000,
transform: {
'^.+\\.ts$': ['ts-jest', { isolatedModules: true }],
'^.+\\.js$': 'ts-jest'
},
transformIgnorePatterns: ['/node_modules/(?!(azle)/)'] // Make sure azle is transformed
};
Loading