Skip to content

Commit a1f12a7

Browse files
feat: wire custom coin type and get bech32 prefix (backport #4569) (#4572)
* feat: wire custom coin type and get bech32 prefix (#4569) (cherry picked from commit 2b45eaa) # Conflicts: # go.mod # ignite/cmd/scaffold_chain.go # ignite/cmd/testnet_inplace.go # ignite/pkg/cosmosaccount/cosmosaccount.go # ignite/services/chain/chain.go # ignite/services/scaffolder/init.go # ignite/templates/app/app.go # integration/app/cmd_app_test.go * conflicts * updates * consumer --------- Co-authored-by: julienrbrt <julien@rbrt.fr>
1 parent 22ba6b2 commit a1f12a7

File tree

26 files changed

+419
-43
lines changed

26 files changed

+419
-43
lines changed

changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
## Unreleased
44

5+
## [`v28.8.2`](https://github.com/ignite/cli/releases/tag/v28.8.2)
6+
57
### Changes
68

79
- [#4568](https://github.com/ignite/cli/pull/4568) Bump Cosmos SDK to v0.50.13.
10+
- [#4569](https://github.com/ignite/cli/pull/4569) Add flags to set coin type on commands. Add getters for bech32 prefix and coin type.
811

912
## [`v28.8.1`](https://github.com/ignite/cli/releases/tag/v28.8.1)
1013

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ replace (
1313
)
1414

1515
require (
16-
cosmossdk.io/math v1.4.0
16+
cosmossdk.io/core v0.11.2
17+
cosmossdk.io/math v1.5.0
1718
github.com/99designs/keyring v1.2.2
1819
github.com/AlecAivazis/survey/v2 v2.3.7
1920
github.com/DATA-DOG/go-sqlmock v1.5.2
@@ -97,13 +98,12 @@ require (
9798
connectrpc.com/otelconnect v0.7.0 // indirect
9899
cosmossdk.io/api v0.7.6 // indirect
99100
cosmossdk.io/collections v0.4.0 // indirect
100-
cosmossdk.io/core v0.11.1 // indirect
101101
cosmossdk.io/depinject v1.1.0 // indirect
102102
cosmossdk.io/errors v1.0.1 // indirect
103103
cosmossdk.io/log v1.4.1 // indirect
104104
cosmossdk.io/store v1.1.1 // indirect
105105
cosmossdk.io/x/tx v0.13.7 // indirect
106-
dario.cat/mergo v1.0.0 // indirect
106+
dario.cat/mergo v1.0.1 // indirect
107107
filippo.io/edwards25519 v1.0.0 // indirect
108108
github.com/4meepo/tagalign v1.3.4 // indirect
109109
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
@@ -163,6 +163,7 @@ require (
163163
github.com/cilium/ebpf v0.11.0 // indirect
164164
github.com/ckaznocha/intrange v0.1.2 // indirect
165165
github.com/cloudflare/circl v1.3.7 // indirect
166+
github.com/cockroachdb/apd/v3 v3.2.1 // indirect
166167
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
167168
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
168169
github.com/cockroachdb/pebble v1.1.2 // indirect

go.sum

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY=
2828
cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
2929
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
3030
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
31-
cosmossdk.io/core v0.11.1 h1:h9WfBey7NAiFfIcUhDVNS503I2P2HdZLebJlUIs8LPA=
32-
cosmossdk.io/core v0.11.1/go.mod h1:OJzxcdC+RPrgGF8NJZR2uoQr56tc7gfBKhiKeDO7hH0=
31+
cosmossdk.io/core v0.11.2 h1:20PXbQxhWRKA83pSYW76OXrc1MI2E93flbMAGSVFlyc=
32+
cosmossdk.io/core v0.11.2/go.mod h1:q137AJUo+/BFZ0hTTgx+7enPAar5c3Nr0h042BgcZMY=
3333
cosmossdk.io/depinject v1.1.0 h1:wLan7LG35VM7Yo6ov0jId3RHWCGRhe8E8bsuARorl5E=
3434
cosmossdk.io/depinject v1.1.0/go.mod h1:kkI5H9jCGHeKeYWXTqYdruogYrEeWvBQCw1Pj4/eCFI=
3535
cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
3636
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
3737
cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
3838
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
39-
cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ=
40-
cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk=
39+
cosmossdk.io/math v1.5.0 h1:sbOASxee9Zxdjd6OkzogvBZ25/hP929vdcYcBJQbkLc=
40+
cosmossdk.io/math v1.5.0/go.mod h1:AAwwBmUhqtk2nlku174JwSll+/DepUXW3rWIXN5q+Nw=
4141
cosmossdk.io/store v1.1.1 h1:NA3PioJtWDVU7cHHeyvdva5J/ggyLDkyH0hGHl2804Y=
4242
cosmossdk.io/store v1.1.1/go.mod h1:8DwVTz83/2PSI366FERGbWSH7hL6sB7HbYp8bqksNwM=
4343
cosmossdk.io/x/tx v0.13.7 h1:8WSk6B/OHJLYjiZeMKhq7DK7lHDMyK0UfDbBMxVmeOI=
4444
cosmossdk.io/x/tx v0.13.7/go.mod h1:V6DImnwJMTq5qFjeGWpXNiT/fjgE4HtmclRmTqRVM3w=
45-
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
46-
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
45+
dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s=
46+
dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
4747
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
4848
filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek=
4949
filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
@@ -267,6 +267,8 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH
267267
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
268268
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
269269
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
270+
github.com/cockroachdb/apd/v3 v3.2.1 h1:U+8j7t0axsIgvQUqthuNm82HIrYXodOV2iWLWtEaIwg=
271+
github.com/cockroachdb/apd/v3 v3.2.1/go.mod h1:klXJcjp+FffLTHlhIG69tezTDvdP065naDsHzKhYSqc=
270272
github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8=
271273
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f h1:otljaYPt5hWxV3MUfO5dFPFiOXg9CyG5/kCfayTqsJ4=
272274
github.com/cockroachdb/datadriven v1.0.3-0.20230413201302-be42291fc80f/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU=

ignite/cmd/account.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
const (
1515
flagAddressPrefix = "address-prefix"
16+
flagCoinType = "coin-type"
1617
flagPassphrase = "passphrase"
1718
flagNonInteractive = "non-interactive"
1819
flagKeyringBackend = "keyring-backend"
@@ -102,6 +103,17 @@ func getAddressPrefix(cmd *cobra.Command) string {
102103
return prefix
103104
}
104105

106+
func flagSetCoinType() *flag.FlagSet {
107+
fs := flag.NewFlagSet("", flag.ContinueOnError)
108+
fs.Uint32(flagCoinType, cosmosaccount.CoinTypeCosmos, "coin type to use for the account")
109+
return fs
110+
}
111+
112+
func getCoinType(cmd *cobra.Command) uint32 {
113+
coinType, _ := cmd.Flags().GetUint32(flagCoinType)
114+
return coinType
115+
}
116+
105117
func flagSetAccountImport() *flag.FlagSet {
106118
fs := flag.NewFlagSet("", flag.ContinueOnError)
107119
fs.Bool(flagNonInteractive, false, "do not enter into interactive mode")

ignite/cmd/account_create.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ func NewAccountCreate() *cobra.Command {
1515
RunE: accountCreateHandler,
1616
}
1717

18+
c.Flags().AddFlagSet(flagSetCoinType())
19+
1820
return c
1921
}
2022

@@ -24,6 +26,7 @@ func accountCreateHandler(cmd *cobra.Command, args []string) error {
2426
ca, err := cosmosaccount.New(
2527
cosmosaccount.WithKeyringBackend(getKeyringBackend(cmd)),
2628
cosmosaccount.WithHome(getKeyringDir(cmd)),
29+
cosmosaccount.WithCoinType(getCoinType(cmd)),
2730
)
2831
if err != nil {
2932
return errors.Errorf("unable to create registry: %w", err)

ignite/cmd/account_import.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ func NewAccountImport() *cobra.Command {
2323

2424
c.Flags().String(flagSecret, "", "Your mnemonic or path to your private key (use interactive mode instead to securely pass your mnemonic)")
2525
c.Flags().AddFlagSet(flagSetAccountImport())
26+
c.Flags().AddFlagSet(flagSetCoinType())
2627

2728
return c
2829
}
@@ -61,6 +62,7 @@ func accountImportHandler(cmd *cobra.Command, args []string) error {
6162
ca, err := cosmosaccount.New(
6263
cosmosaccount.WithKeyringBackend(getKeyringBackend(cmd)),
6364
cosmosaccount.WithHome(getKeyringDir(cmd)),
65+
cosmosaccount.WithCoinType(getCoinType(cmd)),
6466
)
6567
if err != nil {
6668
return err

ignite/cmd/account_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func accountListHandler(cmd *cobra.Command, _ []string) error {
2222
ca, err := cosmosaccount.New(
2323
cosmosaccount.WithKeyringBackend(getKeyringBackend(cmd)),
2424
cosmosaccount.WithHome(getKeyringDir(cmd)),
25+
cosmosaccount.WithBech32Prefix(getAddressPrefix(cmd)),
2526
)
2627
if err != nil {
2728
return err

ignite/cmd/account_show.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func accountShowHandler(cmd *cobra.Command, args []string) error {
2525
ca, err := cosmosaccount.New(
2626
cosmosaccount.WithKeyringBackend(getKeyringBackend(cmd)),
2727
cosmosaccount.WithHome(getKeyringDir(cmd)),
28+
cosmosaccount.WithBech32Prefix(getAddressPrefix(cmd)),
2829
)
2930
if err != nil {
3031
return err

ignite/cmd/scaffold_chain.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ about Cosmos SDK on https://docs.cosmos.network
7979

8080
flagSetClearCache(c)
8181
c.Flags().AddFlagSet(flagSetAccountPrefixes())
82+
c.Flags().AddFlagSet(flagSetCoinType())
8283
c.Flags().StringP(flagPath, "p", "", "create a project in a specific path")
8384
c.Flags().Bool(flagNoDefaultModule, false, "create a project without a default module")
8485
c.Flags().StringSlice(flagParams, []string{}, "add default module parameters")
@@ -99,6 +100,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error {
99100
var (
100101
name = args[0]
101102
addressPrefix = getAddressPrefix(cmd)
103+
coinType = getCoinType(cmd)
102104
appPath = flagGetPath(cmd)
103105
noDefaultModule, _ = cmd.Flags().GetBool(flagNoDefaultModule)
104106
skipGit, _ = cmd.Flags().GetBool(flagSkipGit)
@@ -124,6 +126,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error {
124126
appPath,
125127
name,
126128
addressPrefix,
129+
coinType,
127130
noDefaultModule,
128131
skipGit,
129132
skipProto,

ignite/cmd/scaffold_chain_registry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func scaffoldChainRegistryFiles(cmd *cobra.Command, _ []string) error {
5555
return err
5656
}
5757

58-
if err = sc.AddChainRegistryFiles(c, cfg); err != nil {
58+
if err = sc.CreateChainRegistryFiles(c, cfg); err != nil {
5959
return err
6060
}
6161

0 commit comments

Comments
 (0)