diff --git a/tools/ui/package.json b/tools/ui/package.json index 74859b3f..9ce048c1 100644 --- a/tools/ui/package.json +++ b/tools/ui/package.json @@ -7,11 +7,11 @@ "build": "webpack" }, "devDependencies": { - "@dfinity/agent": "0.9.0", - "@dfinity/candid": "0.9.0", - "@dfinity/principal": "0.9.0", + "@dfinity/agent": "0.9.2", + "@dfinity/candid": "0.9.2", + "@dfinity/principal": "0.9.2", "buffer": "6.0.3", - "copy-webpack-plugin": "^5.1.1", + "copy-webpack-plugin": "^9.0.1", "css-loader": "^3.6.0", "html-webpack-plugin": "^5.2.0", "style-loader": "^1.2.1", diff --git a/tools/ui/src/candid.ts b/tools/ui/src/candid.ts index 1db36a71..99b3a6fe 100644 --- a/tools/ui/src/candid.ts +++ b/tools/ui/src/candid.ts @@ -5,7 +5,16 @@ import { import {Principal} from '@dfinity/principal' import './candid.css'; +function is_local(agent: HttpAgent) { + // @ts-ignore + const hostname = agent._host.hostname; + return hostname === '127.0.0.1' || hostname.endsWith('localhost'); +} + const agent = new HttpAgent(); +if (is_local(agent)) { + agent.fetchRootKey(); +} function getCanisterId(): Principal { // Check the query params. @@ -54,7 +63,7 @@ export async function fetchActor(canisterId: Principal): Promise } const dataUri = 'data:text/javascript;charset=utf-8,' + encodeURIComponent(js); const candid: any = await eval('import("' + dataUri + '")'); - return Actor.createActor(candid.default, { agent, canisterId }); + return Actor.createActor(candid.idlFactory, { agent, canisterId }); } async function getLocalDidJs(canisterId: Principal): Promise { diff --git a/tools/ui/src/didjs/Cargo.toml b/tools/ui/src/didjs/Cargo.toml index f68d1780..36f2506a 100644 --- a/tools/ui/src/didjs/Cargo.toml +++ b/tools/ui/src/didjs/Cargo.toml @@ -8,7 +8,7 @@ path = "lib.rs" crate-type = ["cdylib"] [dependencies] -ic-cdk = "0.2" -ic-cdk-macros = "0.2" +ic-cdk = "0.3" +ic-cdk-macros = "0.3" serde = "1.0" serde_bytes = "0.11" diff --git a/tools/ui/webpack.config.js b/tools/ui/webpack.config.js index 65845df3..00b183ac 100644 --- a/tools/ui/webpack.config.js +++ b/tools/ui/webpack.config.js @@ -23,7 +23,7 @@ const aliases = Object.entries(dfxJson.canisters).reduce( return { ...acc, - ["dfx-generated/" + name]: path.join(outputRoot, name + ".js"), + ["dfx-generated/" + name]: path.join(outputRoot), }; }, {} @@ -90,12 +90,13 @@ function generateWebpackConfigForCanister(name, info) { template: 'src/candid.html', filename: 'index.html', }), - new CopyWebpackPlugin([ - { - from: 'src/favicon.ico', - to: 'favicon.ico', - }, - ]), + new CopyWebpackPlugin({ + patterns: [ + { + from: 'src/favicon.ico', + to: 'favicon.ico', + }, + ]}), new webpack.ProvidePlugin({ Buffer: [require.resolve('buffer/'), 'Buffer'], //process: require.resolve('process/browser'),