Skip to content

Commit

Permalink
feat: guide user for parachain creation (#98)
Browse files Browse the repository at this point in the history
* feat: structure to handle multiple template providers

* feat: guide user in create parachain process

* feat: get latest releases

* feat: clone the repo from the selected release

* refactor: polish

* chore: add warning note about security in external provider templates

* docs: update README

* chore: warning message if user prompt customizable flags in external provider template

* feat: promp user for customization values

* chore: fmt

* refactor: various improvements (#99)

* fix: check for feature contracts

* chore: cargo fmt

* test: unit tests

* feat: -t to select the template

* refactor: remove OpenZeppelin templates

* docs: pop-cli README

* docs: license in new files

* docs: icon in README

* fix: feature flags

* refactor: maximise use of enums (#120)

* refactor: take contract name by reference

* refactor: maximise use of enums

* chore: little change in README

* fix: avoid readme repetition

* fix: link in readme

* chore: create a symbolic link

* fix: tests

* refactor: move functions from helpers to module where they are used

* refactor: remove hardcoded urls

* refactor: improve code to manage different urls

* chore: const for github.com string

* fix: typo

* chore: add deprecated label in help for parity templates

---------

Co-authored-by: Frank Bell <[email protected]>
  • Loading branch information
AlexD10S and evilrobot-01 authored Apr 30, 2024
1 parent dbcf6ba commit 90f8846
Show file tree
Hide file tree
Showing 21 changed files with 650 additions and 423 deletions.
1 change: 1 addition & 0 deletions .github/README.md
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ askama = "0.12"
regex="1.5.4"
walkdir = "2.4"
indexmap = { version = "2.2"}
toml_edit = { version = "0.22" }
toml_edit = { version = "0.22", features = ["serde"] }
symlink = { version = "0.1" }
reqwest = { version = "0.11" }
serde_json = { version = "1.0"}
Expand Down
43 changes: 29 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ cargo install --locked --git https://github.com/r0gue-io/pop-cli

### Parachains

Use `pop` to create a new Parachain project:
Use `pop` to create a new Parachain project.
To be guided through the entire parachain creation process, simply execute
```sh
pop new parachain
```

If no guidance is needed, proceed with:
```sh
# Create a minimal parachain
pop new parachain my-app
# Get a pallet-contracts enabled parachain
pop new parachain my-app cpt
# Get a evm compatible parachain
pop new parachain my-app fpt
```

Use `pop` to build your Parachain:

We also integrate other provider templates in the tool, check them running:
```sh
# Build your parachain
pop build parachain -p ./my-app
pop new parachain --help
```

or

Some examples are:
```sh
cd my-app
pop build parachain
# Get Parity's pallet-contracts enabled parachain template
pop new parachain my-app parity -t cpt
# Get Parity's evm compatible parachain template
pop new parachain my-app parity -t fpt
```

You can also customize your parachain by providing config options for token symbol (as it appears in chain metadata),
For Pop templates you can also customize your parachain by providing config options for token symbol (as it appears in chain metadata),
token decimals, and the initial endowment for developer accounts. Here's how:

```sh
Expand All @@ -57,6 +57,21 @@ There's also the shorter version:
pop new parachain my-app -s DOT -d 6 -i 1_000_000_000
```

Use `pop` to build your Parachain:

```sh
# Build your parachain
pop build parachain -p ./my-app
```

or

```sh
cd my-app
pop build parachain
```


Finally, to build your Parachain:

```sh
Expand Down
257 changes: 0 additions & 257 deletions crates/pop-cli/README.md

This file was deleted.

1 change: 1 addition & 0 deletions crates/pop-cli/README.md
10 changes: 5 additions & 5 deletions crates/pop-cli/src/commands/new/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct NewContractCommand {
}

impl NewContractCommand {
pub(crate) fn execute(self) -> anyhow::Result<()> {
pub(crate) async fn execute(&self) -> anyhow::Result<()> {
clear_screen()?;
intro(format!(
"{}: Generating new contract \"{}\"!",
Expand Down Expand Up @@ -49,7 +49,7 @@ impl NewContractCommand {
fs::create_dir_all(contract_path.as_path())?;
let mut spinner = cliclack::spinner();
spinner.start("Generating contract...");
create_smart_contract(self.name, contract_path.as_path())?;
create_smart_contract(&self.name, contract_path.as_path())?;
spinner.stop("Smart contract created!");
outro(format!("cd into \"{}\" and enjoy hacking! 🚀", contract_path.display()))?;
Ok(())
Expand All @@ -61,14 +61,14 @@ mod tests {
use super::*;
use anyhow::Result;

#[test]
fn test_new_contract_command_execute_success() -> Result<()> {
#[tokio::test]
async fn test_new_contract_command_execute_success() -> Result<()> {
let temp_contract_dir = tempfile::tempdir().expect("Could not create temp dir");
let command = NewContractCommand {
name: "test_contract".to_string(),
path: Some(PathBuf::from(temp_contract_dir.path())),
};
let result = command.execute();
let result = command.execute().await;
assert!(result.is_ok());

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/pop-cli/src/commands/new/pallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct NewPalletCommand {
}

impl NewPalletCommand {
pub(crate) fn execute(&self) -> anyhow::Result<()> {
pub(crate) async fn execute(&self) -> anyhow::Result<()> {
clear_screen()?;
intro(format!(
"{}: Generating new pallet \"{}\"!",
Expand Down
Loading

0 comments on commit 90f8846

Please sign in to comment.