Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
36211f7
change tag and commit info when starport build
fly33499 Sep 9, 2021
64815ac
Fix tag sort issue by tagger info
fly33499 Sep 10, 2021
bff2910
Update starport/services/chain/chain.go
fly33499 Sep 11, 2021
7015937
chore(services/chain): add unit test for determining app version
ilgooz Sep 11, 2021
13ed6f4
Improve tag versioning and commit info
fly33499 Sep 14, 2021
e197c1e
Merge pull request #1 from tendermint/chore/version-test
fly33499 Sep 14, 2021
4f5cd7e
Merge branch 'tendermint:develop' into develop
fly33499 Sep 14, 2021
bfa89e6
remove v character on tag
fly33499 Sep 14, 2021
b473c6e
Merge branch 'develop' of https://github.com/FirmaChain/starport into…
fly33499 Sep 14, 2021
95bc59e
Update starport/services/chain/chain_test.go
fly33499 Sep 14, 2021
a934173
Update starport/services/chain/chain_test.go
fly33499 Sep 14, 2021
693bc0e
Update starport/services/chain/chain_test.go
fly33499 Sep 14, 2021
91bdf6f
Merge branch 'tendermint:develop' into develop
fly33499 Sep 14, 2021
4f34a7b
change tag output without commit count
fly33499 Sep 14, 2021
f00aa17
Merge branch 'develop' of https://github.com/FirmaChain/starport into…
fly33499 Sep 14, 2021
1572d1f
remove test code
fly33499 Sep 14, 2021
f475038
update testcase and untar option
fly33499 Sep 14, 2021
b26b07f
add repoversion pkg to determine version
fly33499 Sep 14, 2021
c07e161
Update starport/pkg/repoversion/repoversion.go
fly33499 Sep 14, 2021
e3ebfe9
Update starport/services/chain/chain_test.go
fly33499 Sep 14, 2021
cea8ffe
Merge branch 'tendermint:develop' into develop
fly33499 Sep 23, 2021
eda2c0d
Update README.md
fly33499 Sep 23, 2021
c0adaaa
Merge branch 'tendermint:develop' into develop
fly33499 Sep 24, 2021
be69f00
Merge branch 'tendermint:develop' into develop
fly33499 Sep 28, 2021
3033666
Merge branch 'tendermint:develop' into develop
fly33499 Sep 30, 2021
eb90664
Merge branch 'tendermint:develop' into develop
fly33499 Oct 9, 2021
e098e71
add cointype support to config.yml
fly33499 Oct 9, 2021
16fb319
Update starport/chainconfig/config_test.go
fly33499 Oct 9, 2021
702e337
Update starport/pkg/chaincmd/chaincmd.go
fly33499 Oct 9, 2021
5dd541a
Update starport/pkg/chaincmd/chaincmd.go
fly33499 Oct 9, 2021
9d336bb
Update starport/pkg/cosmosfaucet/cosmosfaucet.go
fly33499 Oct 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions starport/chainconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ type Account struct {
Coins []string `yaml:"coins,omitempty"`
Mnemonic string `yaml:"mnemonic,omitempty"`
Address string `yaml:"address,omitempty"`
CoinType string `yaml:"cointype,omitempty"`

// The RPCAddress off the chain that account is issued at.
RPCAddress string `yaml:"rpc_address,omitempty"`
Expand Down
38 changes: 38 additions & 0 deletions starport/chainconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ validator:
`

conf, err := Parse(strings.NewReader(confyml))

require.NoError(t, err)
require.Equal(t, []Account{
{
Expand All @@ -37,6 +38,43 @@ validator:
}, conf.Validator)
}

func TestCoinTypeParse(t *testing.T) {
confyml := `
accounts:
- name: me
coins: ["1000token", "100000000stake"]
mnemonic: ozone unfold device pave lemon potato omit insect column wise cover hint narrow large provide kidney episode clay notable milk mention dizzy muffin crazy
cointype: 7777777
- name: you
coins: ["5000token"]
cointype: 123456
validator:
name: user1
staked: "100000000stake"
`

conf, err := Parse(strings.NewReader(confyml))

require.NoError(t, err)
require.Equal(t, []Account{
{
Name: "me",
Coins: []string{"1000token", "100000000stake"},
Mnemonic: "ozone unfold device pave lemon potato omit insect column wise cover hint narrow large provide kidney episode clay notable milk mention dizzy muffin crazy",
CoinType: "7777777",
},
{
Name: "you",
Coins: []string{"5000token"},
CoinType: "123456",
},
}, conf.Accounts)
require.Equal(t, Validator{
Name: "user1",
Staked: "100000000stake",
}, conf.Validator)
}

func TestParseInvalid(t *testing.T) {
confyml := `
accounts:
Expand Down
11 changes: 9 additions & 2 deletions starport/pkg/chaincmd/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
optionValidatorGasPrices = "--gas-prices"
optionYes = "--yes"
optionHomeClient = "--home-client"
optionCoinType = "--coin-type"

constTendermint = "tendermint"
constJSON = "json"
Expand Down Expand Up @@ -192,27 +193,33 @@ func (c ChainCmd) InitCommand(moniker string) step.Option {
}

// AddKeyCommand returns the command to add a new key in the chain keyring
func (c ChainCmd) AddKeyCommand(accountName string) step.Option {
func (c ChainCmd) AddKeyCommand(accountName string, coinType string) step.Option {
command := []string{
commandKeys,
"add",
accountName,
optionOutput,
constJSON,
}
if coinType != "" {
command = append(command, optionCoinType, coinType)
}
command = c.attachKeyringBackend(command)

return c.cliCommand(command)
}

// ImportKeyCommand returns the command to import a key into the chain keyring from a mnemonic
func (c ChainCmd) ImportKeyCommand(accountName string) step.Option {
func (c ChainCmd) ImportKeyCommand(accountName string, coinType string) step.Option {
command := []string{
commandKeys,
"add",
accountName,
optionRecover,
}
if coinType != "" {
command = append(command, optionCoinType, coinType)
}
command = c.attachKeyringBackend(command)

return c.cliCommand(command)
Expand Down
6 changes: 3 additions & 3 deletions starport/pkg/chaincmd/runner/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var (
// AddAccount creates a new account or imports an account when mnemonic is provided.
// returns with an error if the operation went unsuccessful or an account with the provided name
// already exists.
func (r Runner) AddAccount(ctx context.Context, name, mnemonic string) (Account, error) {
func (r Runner) AddAccount(ctx context.Context, name, mnemonic string, coinType string) (Account, error) {
b := newBuffer()

// check if account already exists.
Expand Down Expand Up @@ -65,7 +65,7 @@ func (r Runner) AddAccount(ctx context.Context, name, mnemonic string) (Account,
if err := r.run(
ctx,
runOptions{},
r.chainCmd.ImportKeyCommand(name),
r.chainCmd.ImportKeyCommand(name, coinType),
step.Write(input.Bytes()),
); err != nil {
return Account{}, err
Expand All @@ -75,7 +75,7 @@ func (r Runner) AddAccount(ctx context.Context, name, mnemonic string) (Account,
stdout: b,
stderr: b,
stdin: os.Stdin,
}, r.chainCmd.AddKeyCommand(name)); err != nil {
}, r.chainCmd.AddKeyCommand(name, coinType)); err != nil {
return Account{}, err
}

Expand Down
8 changes: 6 additions & 2 deletions starport/pkg/cosmosfaucet/cosmosfaucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type Faucet struct {
// accountMnemonic is the mnemonic of the account.
accountMnemonic string

// coinType registered coin type number for HD derivation (BIP-0044).
coinType string

// coins keeps a list of coins that can be distributed by the faucet.
coins []coin

Expand Down Expand Up @@ -73,10 +76,11 @@ type Option func(*Faucet)

// Account provides the account information to transfer tokens from.
// when mnemonic isn't provided, account assumed to be exists in the keyring.
func Account(name, mnemonic string) Option {
func Account(name, mnemonic string, coinType string) Option {
return func(f *Faucet) {
f.accountName = name
f.accountMnemonic = mnemonic
f.coinType = coinType
}
}

Expand Down Expand Up @@ -137,7 +141,7 @@ func New(ctx context.Context, ccr chaincmdrunner.Runner, options ...Option) (Fau

// import the account if mnemonic is provided.
if f.accountMnemonic != "" {
_, err := f.runner.AddAccount(ctx, f.accountName, f.accountMnemonic)
_, err := f.runner.AddAccount(ctx, f.accountName, f.accountMnemonic, f.coinType)
if err != nil && err != chaincmdrunner.ErrAccountAlreadyExists {
return Faucet{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion starport/services/chain/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *Chain) Faucet(ctx context.Context) (cosmosfaucet.Faucet, error) {
}

faucetOptions := []cosmosfaucet.Option{
cosmosfaucet.Account(*conf.Faucet.Name, ""),
cosmosfaucet.Account(*conf.Faucet.Name, "", ""),
cosmosfaucet.ChainID(id),
cosmosfaucet.OpenAPI(xurl.HTTP(apiAddress)),
}
Expand Down
3 changes: 2 additions & 1 deletion starport/services/chain/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (c *Chain) InitAccounts(ctx context.Context, conf chainconfig.Config) error

// If the account doesn't provide an address, we create one
if accountAddress == "" {
generatedAccount, err = commands.AddAccount(ctx, account.Name, account.Mnemonic)
generatedAccount, err = commands.AddAccount(ctx, account.Name, account.Mnemonic, account.CoinType)
if err != nil {
return err
}
Expand Down Expand Up @@ -219,5 +219,6 @@ type Account struct {
Name string
Address string
Mnemonic string `json:"mnemonic"`
CoinType string
Coins string
}
2 changes: 1 addition & 1 deletion starport/services/networkbuilder/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (b *Blockchain) CreateAccount(ctx context.Context, account chain.Account) (
return chain.Account{}, err
}

acc, err := commands.AddAccount(ctx, account.Name, account.Mnemonic)
acc, err := commands.AddAccount(ctx, account.Name, account.Mnemonic, account.CoinType)
if err != nil {
return chain.Account{}, err
}
Expand Down