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
Merged

Read canister ID from canister #528

merged 15 commits into from
Feb 4, 2022

Conversation

nmattia
Copy link
Collaborator

@nmattia nmattia commented Feb 3, 2022

This includes a few changes that together make the frontend read the canister ID from the canister. This means:

  • The same wasm module can be used anywhere (since the canister ID isn't baked in anymore)
  • The webpack config is a lot saner and doesn't rely on assumptions and hard coded values
  • You can now npm run build without having to first start the replica + call dfx canister create (or after having wiped .dfx/).

This includes the following changed:

  • The <script> tag in index.html is now a dummy; the real content is injected in the backend. The real content includes the canister ID. Notes:
    • By doing this -- as opposed to e.g. fetching a config file also served by the canister -- we don't need to deal with promises and the FE code doesn't need to change
    • This means the SRI hash (for CSP) is now dynamic, so we compute it on startup (init/post_upgrade)
  • Iterating over the assets (to insert the hashes in the certification map/tree) isn't callback-based anymore; instead all assets have a static lifetime. This also ensures that assets are created once and (in the case of index.html) aren't duplicated.
  • The webpack config changed a bit. In order to retain the live reload feature (when using npm run start) we make sure that only the index.html is fetched from the backend; that way, the index.js is still local. The webpack config doesn't assume that the canister has been deployed anymore; now it only tried reading canister IDs when the server is started; before, it would do so at build time as well, meaning you couldn't build the FE if your canister hadn't been deployed (ok, created). I think this is much, much saner.

@nmattia nmattia force-pushed the nm-inject-canister-id branch from 3ad5921 to 6c3c62d Compare February 3, 2022 16:59
@nmattia nmattia changed the title WIP inject canid Read canister ID from canister Feb 3, 2022
@nmattia nmattia marked this pull request as ready for review February 3, 2022 18:05
@bitdivine
Copy link
Member

How has this code been tested?

src/internet_identity/src/assets.rs Outdated Show resolved Hide resolved
src/internet_identity/src/assets.rs Show resolved Hide resolved
webpack.config.js Show resolved Hide resolved
webpack.config.js Show resolved Hide resolved
@nmattia
Copy link
Collaborator Author

nmattia commented Feb 4, 2022

How has this code been tested?

This has been tested manually locally and automatically by selenium and the backend-tests on CI. This will also allow us to test the wasm on mainnet with a different canister ID than the official II.

@nmattia nmattia merged commit 4873fc0 into main Feb 4, 2022
@nmattia nmattia deleted the nm-inject-canister-id branch February 4, 2022 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants