Hi
I have question
Like I made a project a month ago using motoko as backend ،there were new things of motoko which I had to put in the project then the project worked fine then a week ago when I ran that same project again I had these II bugs and more
Is that because motoko is constantly updating day by day and old things become deprecated?
TBH ,I have made the project worked with local nns but I still don’t know the cause of this II error
Do you mind sharing a snippet of code and the error you’re getting?
hi ,
i still struggle to configure local II with my dapp
dfx.json:
{
“canisters”: {
“internet_identity”: {
“candid”: “https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity.did”,
“frontend”: {},
“type”: “custom”,
“wasm”: “https://github.com/dfinity/internet-identity/releases/latest/download/internet_identity_dev.wasm.gz”
},
“tokenc_backend”: {
“main”: “src/tokenc_backend/main.mo”,
“type”: “motoko”
},
“tokenc_frontend”: {
“dependencies”: [
“tokenc_backend”
],
“source”: [
“src/tokenc_frontend/dist”
],
“type”: “assets”,
“workspace”: “tokenc_frontend”
}
},
“defaults”: {
“build”: {
“args”: “”,
“packtool”: “mops sources”
}
},
“output_env_file”: “.env”,
“version”: 1
}
vite.config.js
///
import { fileURLToPath, URL } from ‘url’;
import react from ‘@vitejs/plugin-react’;
import { defineConfig } from ‘vite’;
import environment from ‘vite-plugin-environment’;
import dotenv from ‘dotenv’;
dotenv.config({ path: ‘../../.env’ });
export default defineConfig({
build: {
emptyOutDir: true,
},
optimizeDeps: {
esbuildOptions: {
define: {
global: “globalThis”,
},
},
},
server: {
host: ‘127.0.0.1’,
port:4943,
proxy: {
“/api”: {
target: “http://127.0.0.1:4943”,
changeOrigin: true,
},
},
},
plugins: [
react(),
environment(“all”, { prefix: “CANISTER_” }),
environment(“all”, { prefix: “DFX_” }),
],
test: {
environment: ‘jsdom’,
setupFiles: ‘src/setupTests.js’,
},
resolve: {
alias: [
{
find: “declarations”,
replacement: fileURLToPath(
new URL(“../declarations”, import.meta.url ),
}],
dedupe: [‘@dfinity/agent’],
},
});main.jsx :
import ReactDOM from ‘react-dom/client’
import React from ‘react’
import App from “./components/App.jsx”;
import { AuthClient } from “@dfinity/auth-client”;
import { HttpAgent, Actor } from “@dfinity/agent”;
import { idlFactory as backend_idl, canisterId as backend_id } from “../../declarations/tokenc_backend”;
const init = async () => {
const authClientInstance = await AuthClient.create();
await authClientInstance.login({
// identityProvider: "http://127.0.0.1:4943?canisterId=uxrrr-q7777-77774-qaaaq-cai",
identityProvider: `http://127.0.0.1:4943?canisterId=${import.meta.env.VITE_CANISTER_ID_INTERNET_IDENTITY}`,
onSuccess: async () => {
const identity = authClientInstance.getIdentity();
const agent = new HttpAgent({ identity, host: "http://127.0.0.1:4943" });
// only for local dev: fetch root key (skip this in prod)
if (process.env.DFX_NETWORK === "local") {
await agent.fetchRootKey();
}
// create an actor for the backend canister
const tokenActor = Actor.createActor(backend_idl, {
agent,
canisterId: backend_id,
});
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App actor={tokenActor}/>);
}
});};
init();
root package.json:
{
“engines”: {
“node”: “>=16.0.0”,
“npm”: “>=7.0.0”
},
“name”: “tokenc”,
“scripts”: {
“build”: “npm run build --workspaces --if-present”,
“prebuild”: “npm run prebuild --workspaces --if-present”,
“pretest”: “npm run prebuild --workspaces --if-present”,
“start”: “npm start --workspaces --if-present”,
“test”: “npm test --workspaces --if-present”
},
“type”: “module”,
“workspaces”: [
“src/tokenc_frontend”
],
“dependencies”: {
“@mui/icons-material”: “^7.2.0”
}
}
frontend package.json :
{
“name”: “tokenc_frontend”,
“version”: “0.0.0”,
“private”: true,
“proxy”: “https://identity.ic0.app”,
“type”: “module”,
“scripts”: {
“build”: “tsc && vite build”,
“format”: “prettier --write “src/**/*.{json,js,jsx,ts,tsx,css,scss}””,
“prebuild”: “dfx generate”,
“setup”: “npm i && dfx canister create tokenc_backend && dfx generate tokenc_backend && dfx deploy”,
“start”: “vite --port 4943”,
“test”: “vitest run”
},
“dependencies”: {
“@dfinity/agent”: “^2.1.3”,
“@dfinity/auth-client”: “^1.0.0”,
“@dfinity/candid”: “^2.1.3”,
“@dfinity/principal”: “^2.1.3”,
“react”: “^18.2.0”,
“react-dom”: “^18.2.0”,
“react-scripts”: “^0.0.0”
},
“devDependencies”: {
“@testing-library/jest-dom”: “^5.16.5”,
“@testing-library/react”: “^14.0.0”,
“@types/react”: “^18.2.14”,
“@types/react-dom”: “^18.2.6”,
“@vitejs/plugin-react”: “^4.0.1”,
“cross-fetch”: “^3.1.6”,
“dotenv”: “^16.3.1”,
“jsdom”: “^22.1.0”,
“sass”: “^1.63.6”,
“typescript”: “^5.1.3”,
“vite”: “^7.0.6”,
“vite-plugin-environment”: “^1.1.3”,
“vitest”: “^3.2.4”
}
}
these are my files and error before configuring nns extension locally
after configuring nns
local II worked ,I want to know what actually fixed the issue
another question ,I have is that ,I took course ‘Full stack web development by Anglea Yu’
That course has become very outdated in case of motoko ,that is why i had to find all the concepts myself and build almost everything from scratch while learning that course.I almost figured out that what was outdated in course and what was new but there is still this :
in that course in one project angela calls mainet II on her local dApp .I tried that code but did not work for me then sirilux suggested me to use local II .I did not find any doc online telling about this behaviour .So ,I wanna confirm that main II could be called by local dApps in past and now it is not possible ,right ??
Are there any public links to the coarse chapter where they discuss Motoko and, in particular, how to integrate with the mainnet II into a local environment?
Can’t speak for the coarse author, but I don’t understand why this would be desirable for a developer. But if you’re facing a problem while developing on ICP with II, please describe the problem, and I might be able to point you towards a better approach.
@zoro-onepiece Regarding the original question, thanks for sharing the contents of the files of your project.
Debugging this further would require me to reproduce the error on my side. For this purpose, may I request the you share a link to a repository, for example on GitHub, from which I could pull your project (that would be more reliable than copy-and-paste from the forum).
motoko is constantly updating day by day and old things become deprecated
You’re not wrong about this, there’s constant development going on, and some changes should be expected, but those should not be breaking changes. However, it’s probably not that’s causing your issue, if you are using the same version of the tools, you should be getting the same results as before. Have you recently upgraded or reinstalled DFX on your system?
my github repo GitHub - zoro-onepiece/Crypto-Token
using the old dfx version from course was breaking things for me so now i tend to use only latest dfx ,it works then
Thanks for the quick response. Could you also list the steps needed to reproduce your issue, please? say I already cloned the repo, what command do you run? Or do you follow precisely what the README file says?
I told above that I made it work by using nns extension
I think without nns extension installation ,it will break so if you not follow my read me steps ,without nns ,you might reproduce the issue
btw:
This is the course and this is even recommended by dfinity.I urge dfinity to ask the mentor to update the contents
Glad to hear you found a way to resolve the issue. If you have further questions, we’re here to help.
PS. Thanks a lot for sharing the link to the course. Do you mind also sharing which DFINITY website is recommending it? That way, I would know whom to relay the request to adjust the contents.
