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
8 changes: 4 additions & 4 deletions tools/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 10 additions & 1 deletion tools/ui/src/candid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -54,7 +63,7 @@ export async function fetchActor(canisterId: Principal): Promise<ActorSubclass>
}
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<undefined | string> {
Expand Down
4 changes: 2 additions & 2 deletions tools/ui/src/didjs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
15 changes: 8 additions & 7 deletions tools/ui/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
},
{}
Expand Down Expand Up @@ -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'),
Expand Down