Skip to content

Commit 53fd743

Browse files
docs: msgCaller and canisterSelf
Signed-off-by: David Dal Busco <david.dalbusco@outlook.com>
1 parent afd842a commit 53fd743

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

docs/reference/functions/typescript/ic-cdk.mdx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ You have to follow the pace of the Juno release to ensure compatibility. Refer t
2828

2929
---
3030

31-
## id
31+
## canisterSelf
3232

3333
Retrieves the Principal ID of the current Satellite.
3434

3535
This is useful when you want to use functions such as [setDocStore](./sdk.mdx#setdocstore) with the caller set as the administrator. Since the code is running on the backend side (inside the container), the Satellite itself is considered the caller and has admin-level permissions.
3636

3737
```typescript
38-
function id(): Principal;
38+
function canisterSelf(): Principal;
3939
```
4040

4141
📦 Import from `@junobuild/functions/ic-cdk`
@@ -47,6 +47,7 @@ function id(): Principal;
4747
#### Notes:
4848

4949
- This function is a JavaScript binding for the Rust function [ic_cdk::id()](https://docs.rs/ic-cdk/latest/ic_cdk/fn.id.html).
50+
- It was previously named `id()` and is also accessible as `satelliteSelf()`.
5051

5152
---
5253

@@ -80,6 +81,28 @@ function call<T>(params: CallParams): Promise<T | undefined>;
8081

8182
---
8283

84+
## msgCaller
85+
86+
Returns the Principal ID of the caller of the current function.
87+
88+
```typescript
89+
function msgCaller(): Principal;
90+
```
91+
92+
📦 Import from `@junobuild/functions/ic-cdk`
93+
94+
#### Returns:
95+
96+
- `Principal`: The Principal ID of the caller.
97+
98+
#### Notes:
99+
100+
- This function is a JavaScript binding for the Rust function [ic_cdk::api::msg_caller()](https://docs.rs/ic-cdk/latest/ic_cdk/api/fn.msg_caller.html).
101+
- In serverless hooks, the caller is the Satellite itself. The end user's Principal can be retrieved from the payload instead.
102+
- This function was previously named `caller()`.
103+
104+
---
105+
83106
## time
84107

85108
Returns the current timestamp in nanoseconds since the Unix epoch.

0 commit comments

Comments
 (0)