Skip to content

Commit cb7f2c2

Browse files
committed
Conflicts
2 parents a8562a4 + 76b079f commit cb7f2c2

File tree

10 files changed

+157
-17
lines changed

10 files changed

+157
-17
lines changed

docs/1 Introduction/1 Introduction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ Let us dive into Starport, what we can achieve with it, and which other technolo
66

77
Starport is a tool that makes it easier to create blockchains.
88

9-
Starport uses the Tendermint Consensus engine and the Cosmos SDK to create a blockchain application in the Go programming language. This blockchain has a Proof-of-Stake system with validators (https://en.longhash.com/news/how-cosmos-governance-works-and-how-you-can-become-a-validator) that can be defined in the genesis block.
9+
Starport uses the Tendermint Consensus engine and the Cosmos SDK to create a blockchain application in the Go programming language. This blockchain has a Proof-of-Stake system with validators that can be defined in the genesis block.
1010

11-
With just a few command lines, you can create a blockchain, launch it, serve it on the cloud and have a GUI ready to start testing your application.
11+
With just a few commands, you can create a blockchain, launch it, serve it on the cloud and have a GUI ready to start testing your application.
1212

1313
Bootstrapping blockchains was initially the job of the `scaffold` program, which was used to create a blockchain application. Starport takes it to the next level and also creates a user interface with Vue.js, which provides a good starting point for developers creating a browser-based client-side application for your blockchain.
1414

@@ -40,6 +40,6 @@ Many of the live blockchains use multiple Cosmos modules. The foundational modul
4040
## Summary
4141

4242
- Starport lets you create, develop, and build a blockchain.
43-
- Starport and Cosmos are written in Go.
43+
- Starport and Cosmos SDK are written in Go.
4444
- Today, Cosmos SDK has a unique position worldwide as one of the most successful blockchains.
4545
- Developers can use different Cosmos SDK modules to customize their blockchain.

docs/1 Introduction/2 Install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ git clone https://github.com/tendermint/starport && cd starport && make
2424

2525
This will build and install `starport` binary into `$GOBIN`.
2626

27-
Note: When building from source, it is important to have your `$GOPATH` set correctly. When in doubt, the folllowing should do:
27+
Note: When building from source, it is important to have your `$GOPATH` set correctly. When in doubt, the following should do:
2828

2929
```
3030
mkdir ~/go
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
# Quickstart
22

3-
With `starport` installed on your machine, you can now build your very first blockchain application!
3+
With `starport` installed on your machine, you can now build your very first blockchain!
44

5-
```bash
5+
```
66
starport app github.com/username/myapp && cd myapp
77
```
88

9-
Serve the blockchain application
9+
This command will create a directory `myapp` and scaffold a Cosmos SDK blockchain.
1010

11-
```bash
11+
```
1212
starport serve
1313
```
1414

15-
Add a new transaction type to your application
15+
`serve` will install dependencies, build, initialise and run your blokchain.
1616

17-
```bash
17+
```
1818
starport type post title body
1919
```
20+
21+
`type` scaffolds functionality to create, read, update and delete for a custom type.

docs/1 Introduction/4 Configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Configuration
22

3-
When creating a new app with starport, you will see a `config.yml` file in your blockchain application folder. This file defines the genesis file, the network you will be using and the first validators of your blockchain.
3+
When creating a new app with starport, you will see a `config.yml` file in your blockchain folder. This file defines the genesis file, the network you will be using and the first validators of your blockchain.
44

55
Let us examine the parts of the configuration of this file.
66

docs/2 Architecture/1 Introduction.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ To create a blockchain application we use the command `app`
1414
starport app github.com/username/myapp
1515
```
1616

17-
| Flag | Default | Description |
18-
| ------------------ | -------- | -------------------------- |
19-
| `--address-prefix` | `cosmos` | Prefix, used for addresses |
17+
| Flag | Default | Description |
18+
| ------------------ | ---------- | ------------------------------------------------ |
19+
| `--address-prefix` | `cosmos` | Prefix, used for addresses |
20+
| `--sdk-version` | `stargate` | Version of Cosmos SDK: `launchpad` or `stargate` |
2021

2122
This will create the folder `myapp` and is a usable blockchain blueprint. If you want to dive directly into looking at the details of your blockchain you can run it with entering your `myapp` folder and use the command `serve` to initialise your blockchain and start it.
2223

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Configuration
2+
3+
With Starport your blockchain can be configured with `config.yml`.
4+
5+
## `accounts`
6+
7+
A list of user accounts created during genesis of your application.
8+
9+
| Key | Required | Type | Description |
10+
| ----- | -------- | --------------- | ------------------------------------------------- |
11+
| name | Y | String | Local name of a key pair |
12+
| coins | Y | List of Strings | Initial coins with denominations (e.g. "100coin") |
13+
14+
### Example
15+
16+
```yaml
17+
accounts:
18+
- name: alice
19+
coins: ["1000token", "100000000stake"]
20+
- name: bob
21+
coins: ["500token"]
22+
```
23+
24+
## `validator`
25+
26+
A blockchain has to have at least one validator-node. `validator` specifies the account that will be used to initialize the validator and parameters of the validator.
27+
28+
| Key | Required | Type | Description |
29+
| ------ | -------- | ------ | --------------------------------------------------------------------------------- |
30+
| name | Y | String | Name of a key pair. `name` must be in `accounts` |
31+
| staked | Y | String | Amount of coins to bond. Must be less or equal to the amount of coins account has |
32+
33+
### Example
34+
35+
```yaml
36+
accounts:
37+
- name: alice
38+
coins: ["1000token", "100000000stake"]
39+
validator:
40+
name: user1
41+
staked: "100000000stake"
42+
```
43+
44+
## `init.home`
45+
46+
A blockchain stores data and configuration in a data directory. This property specifies a path to the data directory.
47+
48+
### Example
49+
50+
```yaml
51+
init:
52+
home: "~/.myblockchain"
53+
```
54+
55+
## `init.config`
56+
57+
Overwrites properties in `config/config.toml` in the data directory.
58+
59+
## `init.app`
60+
61+
Overwrites properties in `config/app.toml` in the data directory.
62+
63+
## `init.keyring-backend`
64+
65+
Specifies a [keyring backend](https://docs.cosmos.network/master/run-node/keyring.html).
66+
67+
### Example
68+
69+
```yaml
70+
init:
71+
keyring-backend: "os"
72+
```
73+
74+
## `genesis`
75+
76+
Overwrites properties in `config.genesis.json` in the data directory.
77+
78+
### Example
79+
80+
```yaml
81+
genesis:
82+
chain-id: "foobar"
83+
```
84+
85+
## Learn more
86+
87+
- [Starport](https://github.com/tendermint/starport)
88+
- [Cosmos SDK documentation](https://docs.cosmos.network)
89+
- [Cosmos Tutorials](https://tutorials.cosmos.network)
90+
- [Channel on Discord](https://discord.gg/W8trcGV)

starport/services/scaffolder/init.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,23 @@ func (s *Scaffolder) Init(name string) (path string, err error) {
3939
return "", err
4040
}
4141
absRoot := filepath.Join(pwd, pathInfo.Root)
42+
43+
// create the project
4244
if err := s.generate(pathInfo, absRoot); err != nil {
4345
return "", err
4446
}
47+
48+
// generate protobuf types
4549
if err := s.protoc(absRoot, s.options.sdkVersion); err != nil {
4650
return "", err
4751
}
52+
53+
// format the source
54+
if err := fmtProject(absRoot); err != nil {
55+
return "", err
56+
}
57+
58+
// initialize git repository and perform the first commit
4859
if err := initGit(pathInfo.Root); err != nil {
4960
return "", err
5061
}

starport/services/scaffolder/module.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ func (s *Scaffolder) CreateModule(moduleName string) error {
7676
if err != nil {
7777
return err
7878
}
79-
return s.protoc(pwd, majorVersion)
79+
80+
if err := s.protoc(pwd, majorVersion); err != nil {
81+
return err
82+
}
83+
return fmtProject(pwd)
8084
}
8185

8286
// ImportModule imports specified module with name to the scaffolded app.
@@ -125,7 +129,14 @@ func (s *Scaffolder) ImportModule(name string) error {
125129
}
126130
run := genny.WetRunner(context.Background())
127131
run.With(g)
128-
return run.Run()
132+
if err := run.Run(); err != nil {
133+
return err
134+
}
135+
pwd, err := os.Getwd()
136+
if err != nil {
137+
return err
138+
}
139+
return fmtProject(pwd)
129140
}
130141

131142
func ModuleExists(appPath string, moduleName string) (bool, error) {

starport/services/scaffolder/scaffolder.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
package scaffolder
44

55
import (
6+
"context"
7+
"os"
68
"strings"
79

10+
"github.com/tendermint/starport/starport/pkg/cmdrunner"
11+
"github.com/tendermint/starport/starport/pkg/cmdrunner/step"
12+
813
"github.com/tendermint/starport/starport/pkg/cosmosver"
914
)
1015

@@ -36,3 +41,20 @@ func (s *Scaffolder) version() (cosmosver.Version, error) {
3641
func owner(modulePath string) string {
3742
return strings.Split(modulePath, "/")[1]
3843
}
44+
45+
func fmtProject(path string) error {
46+
return cmdrunner.
47+
New(
48+
cmdrunner.DefaultStderr(os.Stderr),
49+
cmdrunner.DefaultWorkdir(path),
50+
).
51+
Run(context.Background(),
52+
step.New(
53+
step.Exec(
54+
"go",
55+
"fmt",
56+
"./...",
57+
),
58+
),
59+
)
60+
}

starport/services/scaffolder/type.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ func (s *Scaffolder) AddType(moduleName string, stype string, fields ...string)
128128
if err != nil {
129129
return err
130130
}
131-
return s.protoc(pwd, majorVersion)
131+
if err := s.protoc(pwd, majorVersion); err != nil {
132+
return err
133+
}
134+
return fmtProject(pwd)
132135
}
133136

134137
func isTypeCreated(appPath, moduleName, typeName string) (isCreated bool, err error) {

0 commit comments

Comments
 (0)