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

rustup and wasm32-unknown-unknown auto setup #632

Merged
merged 28 commits into from Mar 26, 2021
Merged

Conversation

volovyks
Copy link
Contributor

@volovyks volovyks commented Dec 20, 2020

Tested on Linux (Arch + Bash/ZSH)
Latest Mac OS (ZSH)
Windows 10 (Power Shell)

It will be great to run it on your PC. Don't forget to clear .bashrc, .zshenv, etc., and make sure that cargo is not in the PATH before the test.

Example:

node ../create-near-app/index.js coolApp --contract=rust
...[some boilerplate here]...
Checking if rustup is installed...
rustup is not installed


In order to work with rust smart contracts we recommend you install rustup, the Rust toolchain installer. We can run the following command to do it for you:

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

Continue with installation (Y/n)?: y
Installing rustup...

...[some boilerplate from Rust]...

Checking installed Rust targets..
x86_64-unknown-linux-gnu
wasm32-unknown-unknown target  is not added

To build Rust smart contracts you need to add WebAssembly compiler target to Rust toolchain. We can run the following command to do it for you:

    rustup target add wasm32-unknown-unknown

Continue with installation (Y/n)?: y
Adding wasm32-unknown-unknown target...

...[more Rust and js boilerplate]...

Success! Created coolApp
Inside that directory, you can run several commands:

  yarn dev
    Starts the development server. Both contract and client-side code will
    auto-reload once you change source files.

  yarn test
    Starts the test runner.

  yarn deploy
    Deploys contract in permanent location (as configured in src/config.js).
    Also deploys web frontend using GitHub Pages.
    Consult with README.md for details on how to deploy and package.json for full list of commands.

We suggest that you begin by typing:

    source $HOME/.cargo/env
    cd coolApp
    yarn dev

Happy hacking!

@volovyks volovyks linked an issue Dec 20, 2020 that may be closed by this pull request
@volovyks volovyks marked this pull request as ready for review January 5, 2021 00:31
@volovyks volovyks requested a review from chadoh as a code owner January 5, 2021 00:31
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
Copy link
Contributor

@vgrichina vgrichina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm besides few nits

disclaimer: I didn't test whether works alright

@volovyks volovyks self-assigned this Mar 19, 2021
@volovyks volovyks added the enhancement New feature or request label Mar 19, 2021
Copy link
Contributor

@chadoh chadoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put an example of what this complete interaction looks like (as a screenshot or copy-pasted text) in the description of this PR, please?

index.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
utils/rust-setup.js Outdated Show resolved Hide resolved
volovyks and others added 6 commits March 25, 2021 14:37
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
volovyks and others added 9 commits March 25, 2021 20:37
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
Co-authored-by: Chad Ostrowski <221614+chadoh@users.noreply.github.com>
@volovyks volovyks requested a review from chadoh March 25, 2021 20:20
Copy link
Contributor

@chadoh chadoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more nit, see below, and I also noticed that the rust-setup.js file has four-space indents instead of 2 like the rest of the project. This project even has a .editorconfig file that specifies two-space indents. Please configure your editor to honor this file.

But these are small things, and I don't need to review this PR again once you address them. This change looks great and it'll make a big difference for newbie NEARies who want to use Rust! Thank you!

utils/rust-setup.js Outdated Show resolved Hide resolved
@volovyks volovyks merged commit c2ed262 into master Mar 26, 2021
@volovyks volovyks mentioned this pull request May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Offer to install Rust automatically
3 participants