Skip to content

Commit

Permalink
add info for what happens when called outside call context
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Jan 13, 2025
1 parent 801c73a commit 3cfd6f2
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/lib/stable/ic_apis/accept_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { inspectMessage } from '../canister_methods/inspect_message'; // Used fo
* - Signals that a message should proceed to execution
* - **Call Context**:
* - inspectMessage
* - **When called outside of Call Context**:
* - Traps
*/
export function acceptMessage(): void {
if (
Expand Down
2 changes: 2 additions & 0 deletions src/lib/stable/ic_apis/arg_data_raw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* - after a cross-canister call
* - after a cross-canister call from a composite query
* - inspectMessage
* - **When called outside of Call Context**:
* - Traps
*/
export function argDataRaw(): Uint8Array {
if (
Expand Down
2 changes: 2 additions & 0 deletions src/lib/stable/ic_apis/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { idlDecode, idlEncode } from '../execute_with_candid_serde';
* - after a rejected cross-canister call from a composite query
* - heartbeat
* - timer
* - **When called outside of Call Context**:
* - Traps
*/
export async function call<Args extends any[] | undefined, Return = any>(
canisterId: Principal | string,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/stable/ic_apis/data_certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { setCertifiedData } from './set_certified_data'; // Used for links in co
* - **Call Context**:
* - query (non-replicated)
* - composite query
* - **When called outside of Call Context**:
* - Returns undefined
*/
export function dataCertificate(): Uint8Array | undefined {
if (
Expand Down
6 changes: 2 additions & 4 deletions src/lib/stable/ic_apis/method_name.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { inspectMessage } from '../canister_methods/inspect_message'; // Used for links in comments

/**
* Returns the name of the method being called.
*
* @returns The name of the current method, or empty string if called outside the IC environment
*
* @remarks
* - Traps if called outside {@link inspectMessage} context
* - **Call Context**:
* - inspectMessage
* - **When called outside of Call Context**:
* - Traps
*/
export function methodName(): string {
if (
Expand Down
2 changes: 2 additions & 0 deletions src/lib/stable/ic_apis/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { idlEncode } from '../execute_with_candid_serde';
* - heartbeat
* - timer
* - Note: Assuming same as call
* - **When called outside of Call Context**:
* - Traps
*/
export function notify(
canisterId: Principal | string,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/stable/ic_apis/reject_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { rejectCode } from './reject_code'; // Used for links in comments
* - **Call Context**:
* - after a rejected cross-canister call
* - after a rejected cross-canister call from a composite query
* - **When called outside of Call Context**:
* - Traps
*/
export function rejectMessage(): string {
if (
Expand Down

0 comments on commit 3cfd6f2

Please sign in to comment.