-
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 #1854 from demergent-labs/manual
Manual
- Loading branch information
Showing
18 changed files
with
4,286 additions
and
7 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
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,12 @@ | ||
/** | ||
* Converts a Candid string into bytes | ||
* @param candidString a valid Candid string | ||
* @returns the candid value as bytes | ||
*/ | ||
export function candidEncode(candidString: string): Uint8Array { | ||
if (globalThis._azleIc === undefined) { | ||
return undefined as any; | ||
} | ||
|
||
return new Uint8Array(globalThis._azleIc.candidEncode(candidString)); | ||
} |
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,5 +1,8 @@ | ||
export { call } from './call'; | ||
export { candidEncode } from './candid_encode'; | ||
export { id } from './id'; | ||
export { notify } from './notify'; | ||
export { reject } from './reject'; | ||
export { reply } from './reply'; | ||
export { replyRaw } from './reply_raw'; | ||
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,7 @@ | ||
/** | ||
* Rejects the current call with the provided message | ||
* @param message the rejection message | ||
*/ | ||
export function reject(message: string): void { | ||
return globalThis._azleIc ? globalThis._azleIc.reject(message) : undefined; | ||
} |
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,22 @@ | ||
/** | ||
* Used to manually reply to an ingress message. Intended to be used in | ||
* canister methods with a {@link Manual} return type. | ||
* @param buf the value with which to reply. Intended to be used in conjunction with | ||
* {@link ic.candidEncode}. | ||
* @example | ||
* ```ts | ||
* $update; | ||
* export function replyRaw(): Manual<RawReply> { | ||
* ic.replyRaw( | ||
* ic.candidEncode( | ||
* '(record { "int" = 42; "text" = "text"; "bool" = true; "blob" = blob "raw bytes"; "variant" = variant { Medium } })' | ||
* ) | ||
* ); | ||
* } | ||
* ``` | ||
*/ | ||
export function replyRaw(replyBuffer: Uint8Array): void { | ||
return globalThis._azleIc | ||
? globalThis._azleIc.replyRaw(replyBuffer.buffer) | ||
: undefined; | ||
} |
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/manual_reply/.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 |
14 changes: 14 additions & 0 deletions
14
tests/end_to_end/candid_rpc/class_syntax/manual_reply/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,14 @@ | ||
{ | ||
"canisters": { | ||
"manual_reply": { | ||
"type": "azle", | ||
"main": "src/index.ts", | ||
"candid": "src/index.did", | ||
"candid_gen": "custom", | ||
"declarations": { | ||
"output": "test/dfx_generated/manual_reply", | ||
"node_compatibility": true | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.