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 in replicated execution #2513

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should be implementing anything on the ic object anymore, let's remove this and all experimental ic object code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export default Canister({
id: query([], Principal, () => {
return ic.id();
}),
// returns true if the canister is in replicated execution
inReplicatedExecution: update([], bool, () => {
return ic.inReplicatedExecution();
}),
// determines whether the given principal is a controller of the canister
isController: query([Principal], bool, (principal) => {
return ic.isController(principal);
Expand Down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's delete this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ export function getTests(icApiCanister: ActorSubclass<_SERVICE>): Test {
expect(result.toText()).toBe(icApiCanisterId);
});

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

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

it('calls isController on the ic object', async () => {
const principal = Principal.fromText(
execSync(`dfx identity get-principal`).toString().trim()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
dataCertificate,
id,
IDL,
inReplicatedExecution,
isController,
performanceCounter,
Principal,
Expand Down Expand Up @@ -121,6 +122,11 @@ export default class {
return id();
}

@update([], IDL.Bool)
inReplicatedExecution(): boolean {
return inReplicatedExecution();
}

// determines whether the given principal is a controller of the canister
@query([IDL.Principal], IDL.Bool)
isController(principal: Principal): boolean {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.azle
.dfx
dfx_generated
node_modules
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
}
}
}
}
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
Loading