diff --git a/tools/ui/Cargo.lock b/tools/ui/Cargo.lock index 43aceb40..1b28c78d 100644 --- a/tools/ui/Cargo.lock +++ b/tools/ui/Cargo.lock @@ -117,7 +117,7 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "candid" -version = "0.10.0" +version = "0.10.2" dependencies = [ "anyhow", "binread", @@ -415,14 +415,12 @@ checksum = "a54b5297861c651551676e8c43df805dad175cc33bc97dbd992edbbb85dcbcdf" [[package]] name = "ic_principal" -version = "0.1.0" +version = "0.1.1" dependencies = [ "arbitrary", "crc32fast", "data-encoding", - "hex", "serde", - "serde_bytes", "sha2", "thiserror", ] diff --git a/tools/ui/src/candid.ts b/tools/ui/src/candid.ts index bbba1cda..24f5f7f9 100644 --- a/tools/ui/src/candid.ts +++ b/tools/ui/src/candid.ts @@ -12,16 +12,18 @@ declare var d3: any; const names: Record = {}; -function is_local(agent: HttpAgent) { +function isKnownMainnet(agent: HttpAgent) { // @ts-ignore const hostname = agent._host.hostname; - return hostname === '127.0.0.1' || hostname.endsWith('localhost'); + return hostname.endsWith('.icp0.io') || hostname.endsWith('.ic0.app'); } export let authClient: AuthClient | undefined; -const agent = new HttpAgent(); -if (is_local(agent)) { +const agent = new HttpAgent({ + host: window.location.host.replace(/^(localhost)(:\d+)?$/, '127.0.0.1$2') +}); +if (!isKnownMainnet(agent)) { agent.fetchRootKey(); }