Internet Base VS Code extension

I am happy to present to you, the Internet Base extension (alpha).

Currently, it adds notebooks that can run js with icblast.
You can easily interact with mainnet or locally deployed canisters.

It also has an interface browser from which you can directly generate the code for calls.


The identity used in these Blast notebooks is stored inside VS Code’s account system.

You can install the extension from the marketplace.

I welcome comments and suggestions

20 Likes

Very cool. I really like the way you handle variants and opt values.

image
What does this icon do? Doesn’t seem to do anything when I click it

Keep up the good work!

Thanks.
Glad you asked about the button - it generates code for your call. You need to have an open file so it can insert code inside.

Btw. Here is post explaining the icblast - agentjs differences.
Basically OPT: Instead of being key:[val] becomes key:val

2 Likes

We’ve decided to do our homework and launch SNS locally.
It’s great that dfx allows the whole NNS to be installed locally :clap:.
We’ve made a few .blasts to facilitate the process without using any tools except the casual dfx deploy and such.


This helped us understand what is going on on a lower level (imo the proper level). The ic-admin tool is great, but kind of obfuscates the process. Questions like, what calls are you making? Is it one, are there more? What are they doing? Where are they going? Who is making them? Are unanswered (unless you read the tool code)
These blasts at GitHub - infu/internet-base-vsc-examples are using simple ic calls to get it done.

Few fun facts from our observations.
It’s possible to create a pre-SNS dao that launches the SNS.
It’s possible for one SNS to launch another SNS

3 Likes

I’d love to see it deconstructed for deploying them as application canisters instead of being deployed from the sns.

The code is the repo. Give me a few min to fix it for dfx 13.1 (it also had wrong steps, I am replaying it again to see how it goes) Then make sure you clone the latest repo

Following the step by step guide should look like this ~8min

9 Likes

I just want to highlight how amazing that video is :point_up_2:

1 Like

This is great, simple, elegant and fast :slight_smile: Messed with it for half hour still failed. Note to self must buy a Mac. Thanks for the video

1 Like

FYI. The security of VSCode extensions is tragic. Node and NPM packages are the same.


A possible solution is to use the web-based Github Codespaces or vscode.dev and Deno instead of Node.

3 Likes

We are absolutely thrilled to announce that we have successfully added a Dev Container for the Internet Computer to both VS Code desktop and Github Codespaces :partying_face:. This addition, which was just approved a few hours ago, will now be globally accessible in every application that supports the dev container specification. Significantly, this marks the first-ever inclusion of a Web3 Dev Container template into such a registry.

List of supporting tools https://containers.dev/supporting

If you have the “Dev Containers” extension, you can start developing on the IC after a few clicks without having to worry about setting your environment. There are a few benefits:

  • Security - NPM extensions and scripts you run won’t have access to your computer, because they are inside a Docker. It’s pretty insecure to run public projects locally. Deno fixes some of these concerns, but it’s not as popular as Node.

  • Replicability - Your whole team and the public will be able to run your projects and see the same thing without additional environment setup. Our Dockerfile is based on the one for reproducible builds Internet Computer Loading This means if you get your project running inside a Dev Container, you are one step from creating Dockerfiles that compile your reproducible builds. Think of Docker Containers as reproducible apps. If you are only reproducing the wasm files, that won’t allow others to see how the app works locally without them compromising their security.

If you run this command you will be creating a blank container that’s not mounting any local folder.
image

You can then start with sns/1_start.blast and get the whole NNS running locally, then launch your local SNS within minutes.

What Dev Containers do?

They are isolated containers you can start and stop whenever you want. Applications inside can’t touch the files outside of containers except for the folders you mounted.

.devcontainer/devcontainer.json - config
.devcontainer/Dockerfile - build instructions
… the rest of the files are examples and will contain example projects to kickstart Motoko, Rust, Azle, Kybra projects.

You can take this folder from the templates and place it in your own projects. You can also do that by clicking this green button and choosing “Add dev configuration files” or typing the command
image

If you copy the .devcontainer files inside your own project, then all you need to do is hit +
image
and image

You can also modify the Dockerfile however you want, we are just providing the starting template.

VS Code info about Dev Containers Developing inside a Container using Visual Studio Code Remote Development

Good luck with whatever obstacles there may be ahead and have fun!

9 Likes

Sadly doesn’t seem to work on an apple silicon mac :frowning: .

I have tried to make a devcontainer in the past, but annoyingly the sdk doesn’t have an aarch64 build SDK for aarch64 · dfinity/sdk · Discussion #2642 · GitHub

2 Likes

You can use Codespaces.


I suppose one has to make sure they stop their containers when not in use.

UPDATE: Made the Blast Node Kernel use esbuild, now it can import libraries.
Dockerfile is getting fixed right now. no sudo and Nvm was installed for the root user.
Whoever used the previous version should recreate their containers (the new version is coming later today)

1 Like

hello @infu
I’m trying out the container:
it fails with the following error:

 => ERROR [builder  3/13] RUN curl http://archive.ubuntu.com/ubuntu/pool/  1.2s
------                                                                          
 > [builder  3/13] RUN curl http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb --output libssl1.deb && dpkg -i libssl1.deb:                            
#0 0.194   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
#0 0.194                                  Dload  Upload   Total   Spent    Left  Speed
100 1101k  100 1101k    0     0  1126k      0 --:--:-- --:--:-- --:--:-- 1125k  
#0 1.219 dpkg: error processing archive libssl1.deb (--install):
#0 1.219  package architecture (amd64) does not match system (arm64)
#0 1.231 Errors were encountered while processing:
#0 1.231  libssl1.deb
------
Dockerfile-with-features:23
--------------------
  21 |     
  22 |     # Ubuntu 23.04 comes with libssl3 while dfx uses libssl1.1
  23 | >>> RUN curl http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb --output libssl1.deb && dpkg -i libssl1.deb
  24 |     
  25 |     
--------------------
error: failed to solve: process "/bin/sh -c curl http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb --output libssl1.deb && dpkg -i libssl1.deb" did not complete successfully: exit code: 1
[126705 ms] Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /tmp/devcontainercli-root/container-features/0.42.0-1688168989295/Dockerfile-with-features -t vsc-ic-2-b06f1d4b63a661fe184e84ea57fad2dce9ee9100435f6a2ceb6e1f8e6f43d2f8 --target dev_containers_target_stage --build-arg _DEV_CONTAINERS_BASE_IMAGE=builder /workspaces/ic-2/.devcontainer
[126706 ms]     at vte (/root/.vscode-remote-containers/dist/dev-containers-cli-0.295.0/dist/spec-node/devContainersSpecCLI.js:2004:1698)
[126706 ms]     at runMicrotasks (<anonymous>)
[126706 ms]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[126707 ms]     at async zx (/root/.vscode-remote-containers/dist/dev-containers-cli-0.295.0/dist/spec-node/devContainersSpecCLI.js:2003:3911)
[126707 ms]     at async IN (/root/.vscode-remote-containers/dist/dev-containers-cli-0.295.0/dist/spec-node/devContainersSpecCLI.js:2003:2830)
[126707 ms]     at async Ote (/root/.vscode-remote-containers/dist/dev-containers-cli-0.295.0/dist/spec-node/devContainersSpecCLI.js:2020:3660)
[126707 ms]     at async Hf (/root/.vscode-remote-containers/dist/dev-containers-cli-0.295.0/dist/spec-node/devContainersSpecCLI.js:2020:4775)
[126707 ms]     at async Qre (/root/.vscode-remote-containers/dist/dev-containers-cli-0.295.0/dist/spec-node/devContainersSpecCLI.js:2151:10371)
[126708 ms]     at async Zre (/root/.vscode-remote-containers/dist/dev-containers-cli-0.295.0/dist/spec-node/devContainersSpecCLI.js:2151:10112)
[126721 ms] Exit code 1
[126722 ms] Start: Run: docker rm -f be3efe7e89fb8a6bffc82cbebe99931bea66cdfefdc670e129607027d8902a72
[126724 ms] Command failed: node /root/.vscode-remote-containers/dist/dev-containers-cli-0.295.0/dist/spec-node/devContainersSpecCLI.js up --container-session-data-folder /tmp/devcontainers-8c7731a7-0168-4287-86be-1c89befae7411688168970383 --workspace-folder /workspaces/ic-2 --workspace-mount-consistency cached --id-label vsc.devcontainer.volume.name=ic-2 --id-label vsc.devcontainer.volume.folder=ic-2 --id-label devcontainer.config_file=/workspaces/ic-2/.devcontainer/devcontainer.json --log-level debug --log-format json --config /workspaces/ic-2/.devcontainer/devcontainer.json --override-config /tmp/devcontainer-4392ab1d-4ccf-44bd-94e3-234a9e49e520.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=ic-2,target=/workspaces,external=true --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default off --mount-workspace-git-root true
[126724 ms] Exit code 1

Can’t see anything that makes sense in this error.

I’ve just rebuilt it with DFX 4.2 and it worked out.
Then I uploaded the built image to Docker Hub and placed it inside devcontainer.json.
This way it won’t take 12min to launch it the first time, probably less than 1min.
You can pull the latest repo and try again.

4.2 ??
I have 14.1
so to use the container I need to downgrade dfx to 4.2?

I got the error in both ways, cloning the code and using new dev container too.

typo. I meant 14.2 (it’s inside the docker, you don’t need to upgrade or downgrade)

What is your PC and OS? Maybe that is the problem. Also, your Docker version could be old.
You are using this correct? https://github.com/infu/internet-computer-start

You can also check Codespaces. Click on Use this template and open in Codespaces

I am trying to use it but I get so many permission errors.

I did change the version of Rust and dfx in the Dockerfile

ENV RUST_VERSION=1.71.0
and 
ENV DFX_VERSION=0.15.1

but I get the older version anyway
I managed to changed the version of Rust but other errors and now I have

/usr/bin/ld:/tmp/rustcbvyiC5/list:3: syntax error in VERSION script

when I do cargo build because of other errors when I run dfx deploy

the project is deploying fine on my computer when not on docker

I’ve made the last one to start from a docker image so it should spawn a lot faster and if a remote API breaks should work still.
image
https://github.com/infu/internet-computer-start/blob/main/.devcontainer/devcontainer.json

If you start changing versions, you may find this useful https://internetcomputer.org/docs/current/developer-docs/backend/reproducible-builds