From 0933dc2c4aca82f31c85c7521c7ea3d2fb8ad2a0 Mon Sep 17 00:00:00 2001 From: David Dal Busco Date: Sun, 19 Apr 2026 13:50:50 +0200 Subject: [PATCH 1/2] docs: deprecated dfinity by icp-sdk Signed-off-by: David Dal Busco --- docs/examples/functions/typescript/mutating-docs.mdx | 2 +- docs/guides/nodejs.mdx | 2 +- docs/guides/typescript.mdx | 4 ++-- docs/reference/functions/typescript/canisters.mdx | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/examples/functions/typescript/mutating-docs.mdx b/docs/examples/functions/typescript/mutating-docs.mdx index 51bd59d5..85e5fb93 100644 --- a/docs/examples/functions/typescript/mutating-docs.mdx +++ b/docs/examples/functions/typescript/mutating-docs.mdx @@ -71,7 +71,7 @@ import { encodeDocData, setDocStore } from "@junobuild/functions/sdk"; -import { Principal } from "@dfinity/principal"; +import { Principal } from "@icp-sdk/core/principal"; export const assertSetDoc = defineAssert({ collections: ["demo"], diff --git a/docs/guides/nodejs.mdx b/docs/guides/nodejs.mdx index a6b64a93..286b9f19 100644 --- a/docs/guides/nodejs.mdx +++ b/docs/guides/nodejs.mdx @@ -62,7 +62,7 @@ Suppose you want to fetch a document and export it to a file: ```typescript import { getDoc } from "@junobuild/core"; import { defineRun } from "@junobuild/config"; -import { jsonReplacer } from "@dfinity/utils"; +import { jsonReplacer } from "@junobuild/utils"; import { writeFile } from "node:fs/promises"; export const onRun = defineRun(({ mode }) => ({ diff --git a/docs/guides/typescript.mdx b/docs/guides/typescript.mdx index f5606c2f..afa4ce8e 100644 --- a/docs/guides/typescript.mdx +++ b/docs/guides/typescript.mdx @@ -252,8 +252,8 @@ import Call from "./components/functions/call.md"; ```typescript import { call } from "@junobuild/functions/ic-cdk"; import { defineHook, type OnSetDoc } from "@junobuild/functions"; -import { IDL } from "@dfinity/candid"; -import { Principal } from "@dfinity/principal"; +import { IDL } from "@icp-sdk/core/candid"; +import { Principal } from "@icp-sdk/core/principal"; // Define Candid types const SubAccount = IDL.Vec(IDL.Nat8); diff --git a/docs/reference/functions/typescript/canisters.mdx b/docs/reference/functions/typescript/canisters.mdx index da4803ad..8fc8d9ba 100644 --- a/docs/reference/functions/typescript/canisters.mdx +++ b/docs/reference/functions/typescript/canisters.mdx @@ -137,7 +137,7 @@ icrc1BalanceOf(params: { ```typescript import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc"; -import { Principal } from "@dfinity/principal"; +import { Principal } from "@icp-sdk/core/principal"; export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ @@ -184,7 +184,7 @@ icrc1Transfer(params: { ```typescript import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc"; -import { Principal } from "@dfinity/principal"; +import { Principal } from "@icp-sdk/core/principal"; export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ @@ -242,7 +242,7 @@ icrc2TransferFrom(params: { ```typescript import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc"; -import { Principal } from "@dfinity/principal"; +import { Principal } from "@icp-sdk/core/principal"; export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ @@ -301,7 +301,7 @@ icrc2Approve(params: { ```typescript import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc"; -import { Principal } from "@dfinity/principal"; +import { Principal } from "@icp-sdk/core/principal"; export const onExecute = async () => { const ledger = new IcrcLedgerCanister({ @@ -362,7 +362,7 @@ notifyTopUp(params: { ```typescript import { CMCCanister } from "@junobuild/functions/canisters/cmc"; import { IcpLedgerCanister } from "@junobuild/functions/canisters/ledger/icp"; -import { Principal } from "@dfinity/principal"; +import { Principal } from "@icp-sdk/core/principal"; export const onExecute = async () => { // Step 1: Send ICP to the CMC top-up account From 4554988b80d12601ed71e571723a6d18ff004d40 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 11:53:27 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=84=20Update=20LLMs.txt=20snapshot?= =?UTF-8?q?=20for=20PR=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .llms-snapshots/llms-full.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.llms-snapshots/llms-full.txt b/.llms-snapshots/llms-full.txt index 63f102c8..25c9351a 100644 --- a/.llms-snapshots/llms-full.txt +++ b/.llms-snapshots/llms-full.txt @@ -6562,7 +6562,7 @@ typescript/hooks/├── src/│ ├── satellite/ # TypeScript Here’s the actual TypeScript logic from `index.ts`: ``` -import { type AssertSetDoc, defineAssert, defineHook, type OnSetDoc} from "@junobuild/functions";import { PersonData, PersonDataSchema } from "../types";import { decodeDocData, encodeDocData, setDocStore} from "@junobuild/functions/sdk";import { Principal } from "@dfinity/principal";export const assertSetDoc = defineAssert({ collections: ["demo"], assert: (context) => { // We validate that the data submitted for create or update matches the expected schema. const person = decodeDocData(context.data.data.proposed.data); PersonDataSchema.parse(person); }});export const onSetDoc = defineHook({ collections: ["demo"], run: async (context) => { const { caller, data: { key, collection, data: { after: currentDoc } } } = context; // We decode the new data saved in the Datastore because it holds those as blob. const person = decodeDocData(currentDoc.data); // Some console.log for demo purpose console.log( "[on_set_doc] Caller:", Principal.fromUint8Array(caller).toText() ); console.log("[on_set_doc] Collection:", collection); console.log("[on_set_doc] Data:", person.principal, person.value); // We update the document's data that was saved in the Datastore with the call from the frontend dapp. const { hello, ...rest } = person; const updatePerson = { ...rest, hello: `${hello} checked`, yolo: false }; // We encode the data back to blob. const updateData = encodeDocData(updatePerson); // We save the document for the same caller as the one who triggered the original on_set_doc, in the same collection with the same key as well. setDocStore({ caller: caller, collection, key, doc: { version: currentDoc.version, data: updateData } }); }}); +import { type AssertSetDoc, defineAssert, defineHook, type OnSetDoc} from "@junobuild/functions";import { PersonData, PersonDataSchema } from "../types";import { decodeDocData, encodeDocData, setDocStore} from "@junobuild/functions/sdk";import { Principal } from "@icp-sdk/core/principal";export const assertSetDoc = defineAssert({ collections: ["demo"], assert: (context) => { // We validate that the data submitted for create or update matches the expected schema. const person = decodeDocData(context.data.data.proposed.data); PersonDataSchema.parse(person); }});export const onSetDoc = defineHook({ collections: ["demo"], run: async (context) => { const { caller, data: { key, collection, data: { after: currentDoc } } } = context; // We decode the new data saved in the Datastore because it holds those as blob. const person = decodeDocData(currentDoc.data); // Some console.log for demo purpose console.log( "[on_set_doc] Caller:", Principal.fromUint8Array(caller).toText() ); console.log("[on_set_doc] Collection:", collection); console.log("[on_set_doc] Data:", person.principal, person.value); // We update the document's data that was saved in the Datastore with the call from the frontend dapp. const { hello, ...rest } = person; const updatePerson = { ...rest, hello: `${hello} checked`, yolo: false }; // We encode the data back to blob. const updateData = encodeDocData(updatePerson); // We save the document for the same caller as the one who triggered the original on_set_doc, in the same collection with the same key as well. setDocStore({ caller: caller, collection, key, doc: { version: currentDoc.version, data: updateData } }); }}); ``` **Explanation:** @@ -7077,7 +7077,7 @@ juno run --src ./my-task.ts Suppose you want to fetch a document and export it to a file: ``` -import { getDoc } from "@junobuild/core";import { defineRun } from "@junobuild/config";import { jsonReplacer } from "@dfinity/utils";import { writeFile } from "node:fs/promises";export const onRun = defineRun(({ mode }) => ({ run: async (context) => { const key = mode === "staging" ? "123" : "456"; const doc = await getDoc({ collection: "demo", key, satellite: context }); await writeFile("./mydoc.json", JSON.stringify(doc, jsonReplacer, 2)); }})); +import { getDoc } from "@junobuild/core";import { defineRun } from "@junobuild/config";import { jsonReplacer } from "@junobuild/utils";import { writeFile } from "node:fs/promises";export const onRun = defineRun(({ mode }) => ({ run: async (context) => { const key = mode === "staging" ? "123" : "456"; const doc = await getDoc({ collection: "demo", key, satellite: context }); await writeFile("./mydoc.json", JSON.stringify(doc, jsonReplacer, 2)); }})); ``` This script retrieves a document using `getDoc`, selects the document ID based on the current `mode` (for example staging or production), and writes the result to `mydoc.json`, using `jsonReplacer` to handle types not supported by JSON such as `BigInt`. @@ -7437,7 +7437,7 @@ This is useful if you want to: Here's an example that calls another canister’s method and logs the result: ``` -import { call } from "@junobuild/functions/ic-cdk";import { defineHook, type OnSetDoc } from "@junobuild/functions";import { IDL } from "@dfinity/candid";import { Principal } from "@dfinity/principal";// Define Candid typesconst SubAccount = IDL.Vec(IDL.Nat8);const Account = IDL.Record({ owner: IDL.Principal, subaccount: IDL.Opt(SubAccount)});const Icrc1Tokens = IDL.Nat;// Define TypeScript interfacesexport type SubAccountType = Uint8Array | number[];export interface AccountType { owner: Principal; subaccount: [] | [SubAccountType];}export type Icrc1TokensType = bigint;// Define the onSetDoc hookexport const onSetDoc = defineHook({ collections: ["notes"], run: async (context) => { const account: AccountType = { owner: Principal.from(context.caller), subaccount: [] }; const icpLedgerId = Principal.fromText("ryjl3-tyaaa-aaaaa-aaaba-cai"); const balance = await call({ canisterId: icpLedgerId, method: "icrc1_balance_of", args: [[Account, account]], result: Icrc1Tokens }); console.log("Balance:", balance); }}); +import { call } from "@junobuild/functions/ic-cdk";import { defineHook, type OnSetDoc } from "@junobuild/functions";import { IDL } from "@icp-sdk/core/candid";import { Principal } from "@icp-sdk/core/principal";// Define Candid typesconst SubAccount = IDL.Vec(IDL.Nat8);const Account = IDL.Record({ owner: IDL.Principal, subaccount: IDL.Opt(SubAccount)});const Icrc1Tokens = IDL.Nat;// Define TypeScript interfacesexport type SubAccountType = Uint8Array | number[];export interface AccountType { owner: Principal; subaccount: [] | [SubAccountType];}export type Icrc1TokensType = bigint;// Define the onSetDoc hookexport const onSetDoc = defineHook({ collections: ["notes"], run: async (context) => { const account: AccountType = { owner: Principal.from(context.caller), subaccount: [] }; const icpLedgerId = Principal.fromText("ryjl3-tyaaa-aaaaa-aaaba-cai"); const balance = await call({ canisterId: icpLedgerId, method: "icrc1_balance_of", args: [[Account, account]], result: Icrc1Tokens }); console.log("Balance:", balance); }}); ``` This example performs a call to the ICP Ledger canister using the `icrc1_balance_of` method to retrieve the token balance for the calling user. The result is printed to the log using `console.log`. @@ -12635,7 +12635,7 @@ icrc1BalanceOf(params: { account: Account}): Promise #### Example: ``` -import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@dfinity/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);}; +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);}; ``` ### icrc1Transfer @@ -12665,7 +12665,7 @@ icrc1Transfer(params: { args: TransferArgs}): Promise #### Example: ``` -import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@dfinity/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); }}; +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); }}; ``` ### icrc2TransferFrom @@ -12698,7 +12698,7 @@ icrc2TransferFrom(params: { args: TransferFromArgs}): Promise { 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); }}; +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); }}; ``` ### icrc2Approve @@ -12730,7 +12730,7 @@ icrc2Approve(params: { args: ApproveArgs}): Promise #### Example: ``` -import { IcrcLedgerCanister } from "@junobuild/functions/canisters/ledger/icrc";import { Principal } from "@dfinity/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); }}; +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); }}; ``` --- @@ -12766,7 +12766,7 @@ notifyTopUp(params: { args: NotifyTopUpArgs}): Promise #### Example: ``` -import { CMCCanister } from "@junobuild/functions/canisters/cmc";import { IcpLedgerCanister } from "@junobuild/functions/canisters/ledger/icp";import { Principal } from "@dfinity/principal";export const onExecute = async () => { // Step 1: Send ICP to the CMC top-up account const ledger = new IcpLedgerCanister(); const transferResult = await ledger.transfer({ args: { to: cmcTopUpAccountIdentifier, // Uint8Array amount: { e8s: 100_000_000n }, // 1 ICP fee: { e8s: 10_000n }, memo: 0n } }); if ("Err" in transferResult) { console.error("Transfer failed:", transferResult.Err); return; } const blockIndex = transferResult.Ok; // Step 2: Notify the CMC to convert the ICP to cycles const cmc = new CMCCanister(); const notifyResult = await cmc.notifyTopUp({ args: { block_index: blockIndex, canister_id: Principal.fromText("your-canister-id") } }); if ("Ok" in notifyResult) { console.log("Cycles deposited:", notifyResult.Ok); } else { console.error("Notify failed:", notifyResult.Err); }}; +import { CMCCanister } from "@junobuild/functions/canisters/cmc";import { IcpLedgerCanister } from "@junobuild/functions/canisters/ledger/icp";import { Principal } from "@icp-sdk/core/principal";export const onExecute = async () => { // Step 1: Send ICP to the CMC top-up account const ledger = new IcpLedgerCanister(); const transferResult = await ledger.transfer({ args: { to: cmcTopUpAccountIdentifier, // Uint8Array amount: { e8s: 100_000_000n }, // 1 ICP fee: { e8s: 10_000n }, memo: 0n } }); if ("Err" in transferResult) { console.error("Transfer failed:", transferResult.Err); return; } const blockIndex = transferResult.Ok; // Step 2: Notify the CMC to convert the ICP to cycles const cmc = new CMCCanister(); const notifyResult = await cmc.notifyTopUp({ args: { block_index: blockIndex, canister_id: Principal.fromText("your-canister-id") } }); if ("Ok" in notifyResult) { console.log("Cycles deposited:", notifyResult.Ok); } else { console.error("Notify failed:", notifyResult.Err); }}; ``` ---