Skip to content

Commit 5d14caf

Browse files
docs: msgCaller and canisterSelf (#665)
* docs: msgCaller and canisterSelf Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> * 📄 Update LLMs.txt snapshot for PR review --------- Signed-off-by: David Dal Busco <david.dalbusco@outlook.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent afd842a commit 5d14caf

2 files changed

Lines changed: 50 additions & 4 deletions

File tree

.llms-snapshots/llms-full.txt

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

1146311463
---
1146411464

11465-
## id
11465+
## canisterSelf
1146611466

1146711467
Retrieves the Principal ID of the current Satellite.
1146811468

1146911469
This is useful when you want to use functions such as [setDocStore](/docs/reference/functions/typescript/sdk.md#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.
1147011470

1147111471
```
11472-
function id(): Principal;
11472+
function canisterSelf(): Principal;
1147311473
```
1147411474

1147511475
📦 Import from `@junobuild/functions/ic-cdk`
@@ -11481,6 +11481,7 @@ function id(): Principal;
1148111481
#### Notes:
1148211482

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

1148511486
---
1148611487

@@ -11514,6 +11515,28 @@ function call<T>(params: CallParams): Promise<T | undefined>;
1151411515

1151511516
---
1151611517

11518+
## msgCaller
11519+
11520+
Returns the Principal ID of the caller of the current function.
11521+
11522+
```
11523+
function msgCaller(): Principal;
11524+
```
11525+
11526+
📦 Import from `@junobuild/functions/ic-cdk`
11527+
11528+
#### Returns:
11529+
11530+
* `Principal`: The Principal ID of the caller.
11531+
11532+
#### Notes:
11533+
11534+
* 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).
11535+
* In serverless hooks, the caller is the Satellite itself. The end user's Principal can be retrieved from the payload instead.
11536+
* This function was previously named `caller()`.
11537+
11538+
---
11539+
1151711540
## time
1151811541

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

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)