Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read canister ID from canister #528

Merged
merged 15 commits into from
Feb 4, 2022
Prev Previous commit
Next Next commit
Format, lint, README
  • Loading branch information
nmattia committed Feb 3, 2022
commit 1b4e766564dda6e60b9c4ae86195d7d565b08bc4
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ Then open `http://localhost:8080` in your browser. Webpack will reload the page
npm run format && npm run lint
```

To customize your canister ID for deployment or particular local development, create a [`.env`](https://www.npmjs.com/package/dotenv) file in the root of the project and add a `CANISTER_ID` attribute. It should look something like
```
CANISTER_ID=rrkah-fqaaa-aaaaa-aaaaq-cai
```

Finally, to test workflows like authentication from a client application, you start the sample app:

```bash
Expand Down
3 changes: 1 addition & 2 deletions src/frontend/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<!-- this is replaced by the backend before serving -->
<!-- XXX: DO NOT CHANGE! or if you do, change the bit that matches on this
exact string in the canister code-->
<script id='setupJs'></script>

<script id="setupJs"></script>
</body>
</html>
18 changes: 9 additions & 9 deletions src/frontend/src/utils/iiConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ import { fromMnemonicWithoutValidation } from "../crypto/ed25519";
declare const canisterId: string;

// Check if the canister ID was defined before we even try to read it
if(typeof canisterId !== undefined) {
displayError({
title: "Canister ID not set",
message:
"There was a problem contacting the IC. The host serving this page did not give us a canister ID. Try reloading the page and contact support if the problem persists.",
primaryButton: "Reload",
}).then(() => {
window.location.reload();
});
if (typeof canisterId !== undefined) {
displayError({
title: "Canister ID not set",
message:
"There was a problem contacting the IC. The host serving this page did not give us a canister ID. Try reloading the page and contact support if the problem persists.",
primaryButton: "Reload",
}).then(() => {
window.location.reload();
});
}

export const canisterIdPrincipal: Principal = Principal.fromText(canisterId);
Expand Down