-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1851 from demergent-labs/composite_queries
Composite queries
- Loading branch information
Showing
20 changed files
with
10,363 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Principal } from '..'; | ||
|
||
/** | ||
* Gets the id of this canister | ||
* @returns the canister id | ||
*/ | ||
export function id(): Principal { | ||
if (globalThis._azleIc === undefined) { | ||
return undefined as any; | ||
} | ||
|
||
// TODO consider bytes instead of string, just like with caller | ||
const idString = globalThis._azleIc.id(); | ||
return Principal.fromText(idString); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export { call } from './call'; | ||
export { id } from './id'; | ||
export { notify } from './notify'; | ||
export { reply } from './reply'; | ||
export { trap } from './trap'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { IDL } from '..'; | ||
|
||
/** | ||
* Used to manually reply to an ingress message. Intended to be used in | ||
* canister methods with a {@link Manual} return type. | ||
* @param reply the value with which to reply. Must be of type `T` where `T` | ||
* is the generic type supplied to `Manual<T>`. Otherwise will result in an | ||
* uncaught `TypeError`. | ||
*/ | ||
export function reply<T>(data: T, type: IDL.Type<T>): void { | ||
if (globalThis._azleIc === undefined) { | ||
return undefined as any; | ||
} | ||
|
||
return globalThis._azleIc.replyRaw( | ||
new Uint8Array(IDL.encode([type], [data])).buffer | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
tests/end_to_end/candid_rpc/class_syntax/composite_queries/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.azle | ||
.dfx | ||
dfx_generated | ||
node_modules |
46 changes: 46 additions & 0 deletions
46
tests/end_to_end/candid_rpc/class_syntax/composite_queries/dfx.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"canisters": { | ||
"canister1": { | ||
"type": "azle", | ||
"main": "src/canister1/index.ts", | ||
"candid": "src/canister1/index.did", | ||
"candid_gen": "custom", | ||
"env": [ | ||
"CANISTER1_PRINCIPAL", | ||
"CANISTER2_PRINCIPAL", | ||
"CANISTER3_PRINCIPAL", | ||
"AZLE_TEST_FETCH" | ||
], | ||
"assets": [ | ||
["src/canister2/index.did", "candid/canister2.did"], | ||
["src/canister3/index.did", "candid/canister3.did"] | ||
], | ||
"declarations": { | ||
"output": "test/dfx_generated/canister1", | ||
"node_compatibility": true | ||
} | ||
}, | ||
"canister2": { | ||
"type": "azle", | ||
"main": "src/canister2/index.ts", | ||
"candid": "src/canister2/index.did", | ||
"candid_gen": "custom", | ||
"env": ["CANISTER3_PRINCIPAL", "AZLE_TEST_FETCH"], | ||
"assets": [["src/canister3/index.did", "candid/canister3.did"]], | ||
"declarations": { | ||
"output": "test/dfx_generated/canister2", | ||
"node_compatibility": true | ||
} | ||
}, | ||
"canister3": { | ||
"type": "azle", | ||
"main": "src/canister3/index.ts", | ||
"candid": "src/canister3/index.did", | ||
"candid_gen": "custom", | ||
"declarations": { | ||
"output": "test/dfx_generated/canister3", | ||
"node_compatibility": true | ||
} | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/end_to_end/candid_rpc/class_syntax/composite_queries/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest', | ||
'^.+\\.js$': 'ts-jest' | ||
}, | ||
transformIgnorePatterns: ['/node_modules/(?!(azle)/)'] // Make sure azle is transformed | ||
}; |
Oops, something went wrong.