Skip to content

Commit d458aed

Browse files
authored
fix(chain): keyring backend & upgrade LP version (ignite#832)
* fix(chain): keyring backend & upgrade LP version to fix hmac panic on Go 1.16. * fix linter errors
1 parent 2ac8c6e commit d458aed

File tree

8 files changed

+35
-20
lines changed

8 files changed

+35
-20
lines changed

starport/pkg/chaincmd/chaincmd.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type ChainCmd struct {
5959
chainID string
6060
homeDir string
6161
keyringBackend KeyringBackend
62-
KeyringPassword string
62+
keyringPassword string
6363
cliCmd string
6464
cliHome string
6565
nodeAddress string
@@ -137,7 +137,7 @@ func WithKeyringBackend(keyringBackend KeyringBackend) Option {
137137
// WithKeyringPassword provides a password to unlock keyring
138138
func WithKeyringPassword(password string) Option {
139139
return func(c *ChainCmd) {
140-
c.KeyringPassword = password
140+
c.keyringPassword = password
141141
}
142142
}
143143

@@ -501,6 +501,16 @@ func (c ChainCmd) StatusCommand() step.Option {
501501
return c.cliCommand(command)
502502
}
503503

504+
// KeyringBackend returns the underlying keyring backend.
505+
func (c ChainCmd) KeyringBackend() KeyringBackend {
506+
return c.keyringBackend
507+
}
508+
509+
// KeyringPassword returns the underlying keyring password.
510+
func (c ChainCmd) KeyringPassword() string {
511+
return c.keyringPassword
512+
}
513+
504514
// attachChainID appends the chain ID flag to the provided command
505515
func (c ChainCmd) attachChainID(command []string) []string {
506516
if c.chainID != "" {

starport/pkg/chaincmd/runner/account.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func (r Runner) AddAccount(ctx context.Context, name, mnemonic string) (Account,
5050
input := &bytes.Buffer{}
5151
fmt.Fprintln(input, mnemonic)
5252

53-
if r.cc.KeyringPassword != "" {
54-
fmt.Fprintln(input, r.cc.KeyringPassword)
55-
fmt.Fprintln(input, r.cc.KeyringPassword)
53+
if r.cc.KeyringPassword() != "" {
54+
fmt.Fprintln(input, r.cc.KeyringPassword())
55+
fmt.Fprintln(input, r.cc.KeyringPassword())
5656
}
5757

5858
if err := r.run(
@@ -80,9 +80,9 @@ func (r Runner) AddAccount(ctx context.Context, name, mnemonic string) (Account,
8080
r.cc.ShowKeyAddressCommand(name),
8181
}
8282

83-
if r.cc.KeyringPassword != "" {
83+
if r.cc.KeyringPassword() != "" {
8484
input := &bytes.Buffer{}
85-
fmt.Fprintln(input, r.cc.KeyringPassword)
85+
fmt.Fprintln(input, r.cc.KeyringPassword())
8686
opt = append(opt, step.Write(input.Bytes()))
8787
}
8888

@@ -109,9 +109,9 @@ func (r Runner) ShowAccount(ctx context.Context, name string) (Account, error) {
109109
r.cc.ShowKeyAddressCommand(name),
110110
}
111111

112-
if r.cc.KeyringPassword != "" {
112+
if r.cc.KeyringPassword() != "" {
113113
input := &bytes.Buffer{}
114-
fmt.Fprintln(input, r.cc.KeyringPassword)
114+
fmt.Fprintln(input, r.cc.KeyringPassword())
115115
opt = append(opt, step.Write(input.Bytes()))
116116
}
117117

starport/pkg/chaincmd/runner/chain.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ func (r Runner) BankSend(ctx context.Context, fromAccount, toAccount, amount str
142142
r.cc.BankSendCommand(fromAccount, toAccount, amount),
143143
}
144144

145-
if r.cc.KeyringPassword != "" {
145+
if r.cc.KeyringPassword() != "" {
146146
input := &bytes.Buffer{}
147-
fmt.Fprintln(input, r.cc.KeyringPassword)
148-
fmt.Fprintln(input, r.cc.KeyringPassword)
149-
fmt.Fprintln(input, r.cc.KeyringPassword)
147+
fmt.Fprintln(input, r.cc.KeyringPassword())
148+
fmt.Fprintln(input, r.cc.KeyringPassword())
149+
fmt.Fprintln(input, r.cc.KeyringPassword())
150150
opt = append(opt, step.Write(input.Bytes()))
151151
}
152152

starport/pkg/chaincmd/runner/runner.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ func (r Runner) Copy(options ...Option) Runner {
8989
return r
9090
}
9191

92+
// Cmd returns underlying chain cmd.
93+
func (r Runner) Cmd() chaincmd.ChainCmd {
94+
return r.cc
95+
}
96+
9297
type runOptions struct {
9398
// wrappedStdErrMaxLen determines the maximum length of the wrapped error logs
9499
// this option is used for long running command to prevent the buffer containing stderr getting too big

starport/services/chain/grpcweb_proxy.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ func newGRPCWebProxyHandler(grpcServerAddress string) (*grpc.ClientConn, http.Ha
1818
grpcopts := []grpc.DialOption{
1919
grpc.WithInsecure(),
2020
// TODO: https://github.com/tendermint/starport/issues/562
21-
// nolint:staticcheck
2221
grpc.WithCodec(proxy.Codec()),
2322
}
2423

@@ -42,7 +41,6 @@ func newGRPCWebProxyHandler(grpcServerAddress string) (*grpc.ClientConn, http.Ha
4241
// Server with logging and monitoring enabled.
4342
grpcserver := grpc.NewServer(
4443
// TODO: https://github.com/tendermint/starport/issues/562
45-
// nolint:staticcheck
4644
grpc.CustomCodec(proxy.Codec()), // needed for proxy to function.
4745
grpc.UnknownServiceHandler(proxy.TransparentHandler(director)),
4846
grpc_middleware.WithUnaryServerChain(),

starport/services/chain/plugin-launchpad.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package chain
22

33
import (
44
"context"
5+
"fmt"
56
"os"
67
"path/filepath"
78

@@ -46,15 +47,16 @@ func (p *launchpadPlugin) Setup(ctx context.Context) error {
4647
gocmd.Name(),
4748
"mod",
4849
"edit",
49-
"-require=github.com/cosmos/cosmos-sdk@v0.39.1",
50+
"-require=github.com/cosmos/cosmos-sdk@v0.39.2",
5051
),
5152
),
5253
)
5354
}
5455

5556
func (p *launchpadPlugin) Configure(ctx context.Context, runner chaincmdrunner.Runner, chainID string) error {
57+
fmt.Println(1, runner.Cmd().KeyringBackend())
5658
return runner.LaunchpadSetConfigs(ctx,
57-
chaincmdrunner.NewKV("keyring-backend", "test"),
59+
chaincmdrunner.NewKV("keyring-backend", string(runner.Cmd().KeyringBackend())),
5860
chaincmdrunner.NewKV("chain-id", chainID),
5961
chaincmdrunner.NewKV("output", "json"),
6062
chaincmdrunner.NewKV("indent", "true"),

starport/templates/app/launchpad/go.mod.plush

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module <%= ModulePath %>
33
go 1.15
44

55
require (
6-
github.com/cosmos/cosmos-sdk v0.39.1
6+
github.com/cosmos/cosmos-sdk v0.39.2
77
github.com/golang/mock v1.4.3 // indirect
88
github.com/google/uuid v1.0.0
99
github.com/gorilla/mux v1.7.4

starport/templates/app/launchpad/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7
8585
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
8686
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
8787
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
88-
github.com/cosmos/cosmos-sdk v0.39.0 h1:lWZQLFxLYQ4ydD01cDZF7tRF8IN2xclDmoNPIJ5Kw44=
89-
github.com/cosmos/cosmos-sdk v0.39.0/go.mod h1:3iKiqnQ48T0UG4IDw9EM8utQSwItutLUkmGkRSWpS5U=
88+
github.com/cosmos/cosmos-sdk v0.39.2 h1:nLfCJMkUuFt7ansi/YvCxwwxLFrgHCA3cYP4sJKYQdk=
89+
github.com/cosmos/cosmos-sdk v0.39.2/go.mod h1:VNUluciWBFj2vkhpMcp8rYZL/kCw0FtNc7SseUjE1KM=
9090
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d h1:49RLWk1j44Xu4fjHb6JFYmeUnDORVwHNkDxaQ0ctCVU=
9191
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
9292
github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4=

0 commit comments

Comments
 (0)