near / cargo-near

Cargo extension for building Rust smart contracts on NEAR
Apache License 2.0
34 stars 17 forks source link

`cargo near new` command to initialize a new smart contract project #100

Closed frol closed 11 months ago

frol commented 1 year ago

It would be great to have a new command to initialize an empty project.

There is cargo-generate and near-create-app that are currently suggested in the docs, but I would prefer avoiding having extra dependency (cargo-generate) or a whole different stack (near-create-app requires Node.js) and rather build the whole DevX around cargo near ... commands.

image

I believe near-create-app does too much (initializes the frontend and the contract inside a single project), and cargo-generate makes things harder to use than necessary, and currently developers face the whole page of just "Create a new project" where I would love to see:

cargo near new my-new-project
cd my-new-project

and the next commands:

cargo near build
...
cargo near deploy

P.S. It might also be useful to initialize common projects like basic FT, NFT contracts (see https://github.com/near/near-sdk-rs/tree/master/examples).

ShivangRawat30 commented 1 year ago

Hey I am currently learning rust, as it is a good first issue can you please assign this to me

frol commented 1 year ago

@ShivangRawat30 Sure, go ahead!

frol commented 1 year ago

In addition to the regular Rust project setup, I suggest also including GitHub Actions setup for fmt/linting checks on PRs, and build and deploy to testnet and (optional) mainnet on merges to main branch.

A very basic one can be found here: https://github.com/frol/transfer-near-contract/blob/main/.github/workflows/rust.yml (there is no deployment part there)

frol commented 1 year ago

And also setup tests environment (workspaces-rs)

frol commented 1 year ago

I think we could start with polishing one contract repo to a reasonable state before scripting it into cargo near new. Currently, looking at https://github.com/near-examples/, I cannot find any Rust contract example without npm/yarn in there. It makes things much more complex than necessary.

So to summarize it, a new project should have the following:

iho commented 1 year ago

@ShivangRawat30 Hi. How is your progress? Can I take this task?

frol commented 11 months ago

Here is a bootstrap project that cargo near new should use as a template: https://github.com/frol/cargo-near-new-project.