Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hosting/oisy-signer-demo/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"format:check": "prettier --check ."
},
"dependencies": {
"@icp-sdk/canisters": "~3.5.0",
"@icp-sdk/core": "~5.0.0",
"@icp-sdk/signer": "5.3.0",
"@icp-sdk/canisters": "~4.0.0",
"@icp-sdk/core": "~6.1.0",
"@icp-sdk/signer": "~6.0.0",
"class-variance-authority": "~0.7.1",
"lucide-react": "~0.575.0",
"react": "~19.2.4",
Expand Down
2 changes: 1 addition & 1 deletion motoko/backend_only/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"
2 changes: 1 addition & 1 deletion motoko/basic_bitcoin/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"

networks:
- name: local
Expand Down
2 changes: 1 addition & 1 deletion motoko/canister_factory/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"
2 changes: 1 addition & 1 deletion motoko/canister_logs/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"
4 changes: 2 additions & 2 deletions motoko/cert-var/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"dev": "vite"
},
"dependencies": {
"@icp-sdk/core": "~5.0.0"
"@icp-sdk/core": "~6.1.0"
},
"devDependencies": {
"@icp-sdk/bindgen": "~0.2.2",
"@icp-sdk/bindgen": "~0.4.1",
"vite": "5.4.11"
}
}
2 changes: 1 addition & 1 deletion motoko/cert-var/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"

- name: frontend
recipe:
Expand Down
2 changes: 1 addition & 1 deletion motoko/composite_query/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"
4 changes: 2 additions & 2 deletions motoko/daily_planner/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"dev": "vite"
},
"dependencies": {
"@icp-sdk/core": "~5.2.0",
"@icp-sdk/core": "~6.1.0",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@icp-sdk/bindgen": "~0.2.2",
"@icp-sdk/bindgen": "~0.4.1",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@vitejs/plugin-react": "4.3.3",
Expand Down
2 changes: 1 addition & 1 deletion motoko/daily_planner/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"

- name: frontend
recipe:
Expand Down
4 changes: 2 additions & 2 deletions motoko/evm_block_explorer/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"dev": "vite"
},
"dependencies": {
"@icp-sdk/core": "~6.0.0",
"@icp-sdk/core": "~6.1.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-json-view-lite": "2.3.0"
},
"devDependencies": {
"@icp-sdk/bindgen": "~0.4.0",
"@icp-sdk/bindgen": "~0.4.1",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@vitejs/plugin-react": "4.3.3",
Expand Down
2 changes: 1 addition & 1 deletion motoko/evm_block_explorer/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"

- name: frontend
recipe:
Expand Down
2 changes: 2 additions & 0 deletions motoko/filevault/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ bash test.sh
icp network stop
```

> Internet Identity sign-in runs against the Internet Identity canister deployed on the local network (`ii: true` in `icp.yaml`). If signing in fails, update the local network launcher with `icp network update` and restart the network.

The frontend is served by the asset canister. To run the Vite dev server with hot reload during frontend development:

```bash
Expand Down
6 changes: 3 additions & 3 deletions motoko/filevault/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"dev": "vite"
},
"dependencies": {
"@icp-sdk/auth": "~5.0.0",
"@icp-sdk/core": "~5.2.0",
"@icp-sdk/auth": "~10.0.0",
"@icp-sdk/core": "~6.1.0",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@icp-sdk/bindgen": "~0.3.0",
"@icp-sdk/bindgen": "~0.4.1",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@vitejs/plugin-react": "4.3.3",
Expand Down
47 changes: 21 additions & 26 deletions motoko/filevault/frontend/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,44 @@
import React, { useState, useEffect } from 'react';
import { AuthClient } from '@icp-sdk/auth/client';
import { createBackendActor, identityProviderUrl } from './actor';
import { authClient, getBackendActor } from './actor';
import '../index.css';

function App() {
const [isAuthenticated, setIsAuthenticated] = useState(false);
const [authClient, setAuthClient] = useState();
const [actor, setActor] = useState();
const [isAuthenticated, setIsAuthenticated] = useState(authClient.isAuthenticated());
const [files, setFiles] = useState([]);
const [errorMessage, setErrorMessage] = useState();
const [fileTransferProgress, setFileTransferProgress] = useState();

useEffect(() => {
updateActor();
setErrorMessage();
}, []);
// Sign-out or session expiry, including from another tab.
useEffect(
() =>
authClient.subscribe(() => {
if (!authClient.isAuthenticated()) setIsAuthenticated(false);
}),
[]
);

useEffect(() => {
if (isAuthenticated) {
loadFiles();
}
}, [isAuthenticated]);

async function updateActor() {
const authClient = await AuthClient.create();
const identity = authClient.getIdentity();
const actor = createBackendActor(identity);
const isAuthenticated = await authClient.isAuthenticated();

setActor(actor);
setAuthClient(authClient);
setIsAuthenticated(isAuthenticated);
}

async function login() {
await authClient.login({
identityProvider: identityProviderUrl,
onSuccess: updateActor
});
try {
await authClient.signIn();
setIsAuthenticated(true);
} catch (error) {
console.error('Sign-in failed:', error);
}
}

async function logout() {
await authClient.logout();
updateActor();
await authClient.signOut();
}

async function loadFiles() {
try {
const actor = await getBackendActor();
const fileList = await actor.getFiles();
setFiles(fileList);
} catch (error) {
Expand All @@ -64,6 +56,7 @@ function App() {
return;
}

const actor = await getBackendActor();
if (await actor.checkFileExists(file.name)) {
setErrorMessage(`File "${file.name}" already exists. Please choose a different file name.`);
return;
Expand Down Expand Up @@ -111,6 +104,7 @@ function App() {
progress: 0
});
try {
const actor = await getBackendActor();
const totalChunks = Number(await actor.getTotalChunks(name));
const fileType = await actor.getFileType(name) ?? '';
let chunks = [];
Expand Down Expand Up @@ -147,6 +141,7 @@ function App() {
async function handleFileDelete(name) {
if (window.confirm(`Are you sure you want to delete "${name}"?`)) {
try {
const actor = await getBackendActor();
const success = await actor.deleteFile(name);
if (success) {
await loadFiles();
Expand Down
29 changes: 25 additions & 4 deletions motoko/filevault/frontend/src/actor.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { AuthClient } from "@icp-sdk/auth/client";
import { safeGetCanisterEnv } from "@icp-sdk/core/agent/canister-env";
import { createActor } from "./bindings/backend";

Expand All @@ -16,18 +17,38 @@ const agentOptions = {
rootKey: canisterEnv?.IC_ROOT_KEY,
};

// Internet Identity is deployed on the local network (`ii: true` in icp.yaml).
const isLocal =
window.location.hostname === "localhost" ||
window.location.hostname === "127.0.0.1" ||
window.location.hostname.endsWith(".localhost");
const II_CANISTER_ID = "uqzsh-gqaaa-aaaaq-qaada-cai";
const networkPort = process.env.REPLICA_PORT || window.location.port || "8000";
export const identityProviderUrl = isLocal
? `http://${II_CANISTER_ID}.localhost:${networkPort}`
: "https://id.ai";

// The client mints its delegations by calling the II canister, so its agent
// needs the network's root key to verify the responses.
export const authClient = new AuthClient({
identityProvider: {
authorizeUrl: isLocal
? `http://id.ai.localhost:${networkPort}/authorize`
: "https://id.ai/authorize",
canisterId: "rdmx6-jaaaa-aaaaa-aaadq-cai",
},
agentOptions: { rootKey: canisterEnv?.IC_ROOT_KEY },
});

export function createBackendActor(identity) {
return createActor(canisterId, {
agentOptions: { ...agentOptions, identity },
});
}

let cached;

// Resolves the identity at call time and reuses the actor while it is unchanged.
export async function getBackendActor() {
const identity = authClient.isAuthenticated() ? await authClient.getIdentity() : undefined;
if (!cached || cached.identity !== identity) {
cached = { identity, actor: createBackendActor(identity) };
}
return cached.actor;
}
2 changes: 1 addition & 1 deletion motoko/filevault/icp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ networks:
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"

- name: frontend
recipe:
Expand Down
4 changes: 2 additions & 2 deletions motoko/flying_ninja/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"dev": "vite"
},
"dependencies": {
"@icp-sdk/core": "~5.0.0",
"@icp-sdk/core": "~6.1.0",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"devDependencies": {
"@icp-sdk/bindgen": "~0.2.2",
"@icp-sdk/bindgen": "~0.4.1",
"@types/react": "18.3.12",
"@types/react-dom": "18.3.1",
"@vitejs/plugin-react": "4.3.3",
Expand Down
2 changes: 1 addition & 1 deletion motoko/flying_ninja/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"

- name: frontend
recipe:
Expand Down
2 changes: 1 addition & 1 deletion motoko/hello_cycles/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"
4 changes: 2 additions & 2 deletions motoko/hello_world/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"dev": "vite"
},
"dependencies": {
"@icp-sdk/core": "~5.0.0"
"@icp-sdk/core": "~6.1.0"
},
"devDependencies": {
"@icp-sdk/bindgen": "~0.2.2",
"@icp-sdk/bindgen": "~0.4.1",
"vite": "5.4.11"
}
}
2 changes: 1 addition & 1 deletion motoko/hello_world/icp.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
canisters:
- name: backend
recipe:
type: "@dfinity/motoko@v5.0.0"
type: "@dfinity/motoko@v5.1.0"

- name: frontend
recipe:
Expand Down
2 changes: 2 additions & 0 deletions motoko/ic-pos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ icp network start -d
bash deploy.sh
```

> Internet Identity sign-in runs against the Internet Identity canister deployed on the local network (`ii: true` in `icp.yaml`). If signing in fails, update the local network launcher with `icp network update` and restart the network.

> **Use `bash deploy.sh`, not `icp deploy`, locally.** The ICRC-1 ledger and index require init args (minting account, initial balances, and the ledger's canister ID) that are only known after identities and canisters are created, so `deploy.sh` installs them with the right arguments. A plain `icp deploy` traps because those canisters receive no init args.

`deploy.sh` installs a local ICRC-1 ledger + index (a throwaway token named **LICRC1**, distinct from the mainnet TICRC1), the `backend`, and the `frontend`. Internet Identity is provided by the local network (`ii: true` in `icp.yaml`) at `http://id.ai.localhost:8000` — no separate deployment. Open the frontend URL printed by the script.
Expand Down
8 changes: 4 additions & 4 deletions motoko/ic-pos/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
},
"dependencies": {
"@hookform/resolvers": "^3.1.1",
"@icp-sdk/auth": "~7.1.0",
"@icp-sdk/canisters": "~3.6.0",
"@icp-sdk/core": "~5.4.0",
"@icp-sdk/auth": "~10.0.0",
"@icp-sdk/canisters": "~4.0.0",
"@icp-sdk/core": "~6.1.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
Expand All @@ -32,7 +32,7 @@
"zod": "^3.22.3"
},
"devDependencies": {
"@icp-sdk/bindgen": "~0.4.0",
"@icp-sdk/bindgen": "~0.4.1",
"@tailwindcss/forms": "^0.5.10",
"@tailwindcss/typography": "^0.5.19",
"@tailwindcss/vite": "~4",
Expand Down
Loading
Loading