Skip to content

Commit 717f499

Browse files
docs: fix your-icrc-ledger-canister-id is principal (#721)
* docs: fix your-icrc-ledger-canister-id is principal 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 146d6ef commit 717f499

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

.llms-snapshots/llms-full.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12658,7 +12658,7 @@ icrc1BalanceOf(params: { account: Account}): Promise<bigint>
1265812658
#### Example:
1265912659

1266012660
```
12661-
import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@icp-sdk/core/principal";export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ canisterId: "your-icrc-ledger-canister-id" }); const balance = await ledger.icrc1BalanceOf({ account: { owner: Principal.fromText("user-principal") } }); console.log("Balance:", balance);};
12661+
import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@icp-sdk/core/principal";export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ canisterId: Principal.fromText("your-icrc-ledger-canister-id") }); const balance = await ledger.icrc1BalanceOf({ account: { owner: Principal.fromText("user-principal") } }); console.log("Balance:", balance);};
1266212662
```
1266312663

1266412664
### icrc1Transfer
@@ -12688,7 +12688,7 @@ icrc1Transfer(params: { args: TransferArgs}): Promise<TransferResult>
1268812688
#### Example:
1268912689

1269012690
```
12691-
import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@icp-sdk/core/principal";export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ canisterId: "your-icrc-ledger-canister-id" }); const result = await ledger.icrc1Transfer({ args: { to: { owner: Principal.fromText("recipient-principal") }, amount: 1_000_000n, fee: 10_000n } }); if ("Ok" in result) { console.log("Transfer successful, block index:", result.Ok); } else { console.error("Transfer failed:", result.Err); }};
12691+
import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@icp-sdk/core/principal";export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ canisterId: Principal.fromText("your-icrc-ledger-canister-id") }); const result = await ledger.icrc1Transfer({ args: { to: { owner: Principal.fromText("recipient-principal") }, amount: 1_000_000n, fee: 10_000n } }); if ("Ok" in result) { console.log("Transfer successful, block index:", result.Ok); } else { console.error("Transfer failed:", result.Err); }};
1269212692
```
1269312693

1269412694
### icrc2TransferFrom
@@ -12721,7 +12721,7 @@ icrc2TransferFrom(params: { args: TransferFromArgs}): Promise<TransferFromResul
1272112721
#### Example:
1272212722

1272312723
```
12724-
import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@icp-sdk/core/principal";export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ canisterId: "your-icrc-ledger-canister-id" }); const result = await ledger.icrc2TransferFrom({ args: { from: { owner: Principal.fromText("source-principal") }, to: { owner: Principal.fromText("destination-principal") }, amount: 500_000n } }); if ("Ok" in result) { console.log("Transfer from successful, block index:", result.Ok); } else { console.error("Transfer from failed:", result.Err); }};
12724+
import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@icp-sdk/core/principal";export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ canisterId: Principal.fromText("your-icrc-ledger-canister-id") }); const result = await ledger.icrc2TransferFrom({ args: { from: { owner: Principal.fromText("source-principal") }, to: { owner: Principal.fromText("destination-principal") }, amount: 500_000n } }); if ("Ok" in result) { console.log("Transfer from successful, block index:", result.Ok); } else { console.error("Transfer from failed:", result.Err); }};
1272512725
```
1272612726

1272712727
### icrc2Approve
@@ -12753,7 +12753,7 @@ icrc2Approve(params: { args: ApproveArgs}): Promise<ApproveResult>
1275312753
#### Example:
1275412754

1275512755
```
12756-
import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@icp-sdk/core/principal";export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ canisterId: "your-icrc-ledger-canister-id" }); const result = await ledger.icrc2Approve({ args: { spender: { owner: Principal.fromText("spender-principal") }, amount: 1_000_000n } }); if ("Ok" in result) { console.log("Approval successful, block index:", result.Ok); } else { console.error("Approval failed:", result.Err); }};
12756+
import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@icp-sdk/core/principal";export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ canisterId: Principal.fromText("your-icrc-ledger-canister-id") }); const result = await ledger.icrc2Approve({ args: { spender: { owner: Principal.fromText("spender-principal") }, amount: 1_000_000n } }); if ("Ok" in result) { console.log("Approval successful, block index:", result.Ok); } else { console.error("Approval failed:", result.Err); }};
1275712757
```
1275812758

1275912759
---

docs/reference/functions/typescript/canisters.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ import { Principal } from "@icp-sdk/core/principal";
141141

142142
export const onExecute = async () => {
143143
const ledger = new IcrcLedgerCanister({
144-
canisterId: "your-icrc-ledger-canister-id"
144+
canisterId: Principal.fromText("your-icrc-ledger-canister-id")
145145
});
146146

147147
const balance = await ledger.icrc1BalanceOf({
@@ -188,7 +188,7 @@ import { Principal } from "@icp-sdk/core/principal";
188188

189189
export const onExecute = async () => {
190190
const ledger = new IcrcLedgerCanister({
191-
canisterId: "your-icrc-ledger-canister-id"
191+
canisterId: Principal.fromText("your-icrc-ledger-canister-id")
192192
});
193193

194194
const result = await ledger.icrc1Transfer({
@@ -246,7 +246,7 @@ import { Principal } from "@icp-sdk/core/principal";
246246

247247
export const onExecute = async () => {
248248
const ledger = new IcrcLedgerCanister({
249-
canisterId: "your-icrc-ledger-canister-id"
249+
canisterId: Principal.fromText("your-icrc-ledger-canister-id")
250250
});
251251

252252
const result = await ledger.icrc2TransferFrom({
@@ -305,7 +305,7 @@ import { Principal } from "@icp-sdk/core/principal";
305305

306306
export const onExecute = async () => {
307307
const ledger = new IcrcLedgerCanister({
308-
canisterId: "your-icrc-ledger-canister-id"
308+
canisterId: Principal.fromText("your-icrc-ledger-canister-id")
309309
});
310310

311311
const result = await ledger.icrc2Approve({

0 commit comments

Comments
 (0)