Skip to content
This repository was archived by the owner on Jan 20, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
- name: Create a file with all core Cosmos SDK pkgs
run: go list ./... > pkgs.txt
- name: Split pkgs into 10 files
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
- uses: actions/setup-python@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21
- uses: technote-space/get-diff-action@v6.1.0
with:
PATTERNS: |
Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.21

# Download all coverage reports from the 'tests' job
- name: Download coverage reports
Expand Down
16 changes: 8 additions & 8 deletions client/keys/codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ func getTestCases() testCases {
return testCases{
// nolint:govet
[]keyring.KeyOutput{
{"A", "B", "C", "D", "E"},
{"A", "B", "C", "D", ""},
{"", "B", "C", "D", ""},
{"", "", "", "", ""},
{"A", "B", "C", "", "D", "E"},
{"A", "B", "C", "", "D", ""},
{"", "B", "C", "", "D", ""},
{"", "", "", "", "", ""},
},
make([]keyring.KeyOutput, 4),
[][]byte{
[]byte(`{"name":"A","type":"B","address":"C","pubkey":"D","mnemonic":"E"}`),
[]byte(`{"name":"A","type":"B","address":"C","pubkey":"D"}`),
[]byte(`{"name":"","type":"B","address":"C","pubkey":"D"}`),
[]byte(`{"name":"","type":"","address":"","pubkey":""}`),
[]byte(`{"name":"A","type":"B","address":"C","evm_address":"","pubkey":"D","mnemonic":"E"}`),
[]byte(`{"name":"A","type":"B","address":"C","evm_address":"","pubkey":"D"}`),
[]byte(`{"name":"","type":"B","address":"C","evm_address":"","pubkey":"D"}`),
[]byte(`{"name":"","type":"","address":"","evm_address":"","pubkey":""}`),
},
}
}
Expand Down
4 changes: 4 additions & 0 deletions client/keys/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ func printKeyInfo(w io.Writer, keyInfo cryptokeyring.Info, bechKeyOut bechKeyOut
if err != nil {
panic(err)
}
ko, err = cryptokeyring.PopulateEvmAddrIfApplicable(keyInfo, ko)
if err != nil {
panic(err)
}

switch output {
case OutputFormatText:
Expand Down
36 changes: 31 additions & 5 deletions crypto/keyring/output.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package keyring

import (
"encoding/hex"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/crypto"
)

// TODO: Move this file to client/keys
Expand All @@ -13,11 +17,12 @@ import (
// KeyOutput defines a structure wrapping around an Info object used for output
// functionality.
type KeyOutput struct {
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Address string `json:"address" yaml:"address"`
PubKey string `json:"pubkey" yaml:"pubkey"`
Mnemonic string `json:"mnemonic,omitempty" yaml:"mnemonic"`
Name string `json:"name" yaml:"name"`
Type string `json:"type" yaml:"type"`
Address string `json:"address" yaml:"address"`
EvmAddress string `json:"evm_address" yaml:"evm_address"`
PubKey string `json:"pubkey" yaml:"pubkey"`
Mnemonic string `json:"mnemonic,omitempty" yaml:"mnemonic"`
}

// NewKeyOutput creates a default KeyOutput instance without Mnemonic, Threshold and PubKeys
Expand Down Expand Up @@ -72,7 +77,28 @@ func MkAccKeysOutput(infos []Info) ([]KeyOutput, error) {
if err != nil {
return nil, err
}
kos[i], err = PopulateEvmAddrIfApplicable(info, kos[i])
if err != nil {
return nil, err
}
}

return kos, nil
}

func PopulateEvmAddrIfApplicable(info Info, o KeyOutput) (KeyOutput, error) {
localInfo, ok := info.(LocalInfo)
if ok {
priv, err := legacy.PrivKeyFromBytes([]byte(localInfo.PrivKeyArmor))
if err != nil {
return o, err
}
privHex := hex.EncodeToString(priv.Bytes())
privKey, err := crypto.HexToECDSA(privHex)
if err != nil {
return o, err
}
o.EvmAddress = crypto.PubkeyToAddress(privKey.PublicKey).Hex()
}
return o, nil
}
2 changes: 1 addition & 1 deletion crypto/keyring/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ func TestBech32KeysOutput(t *testing.T) {
out, err := MkAccKeyOutput(info)
require.NoError(t, err)
require.Equal(t, expectedOutput, out)
require.Equal(t, `{Name:multisig Type:multi Address:cosmos1nf8lf6n4wa43rzmdzwe6hkrnw5guekhqt595cw PubKey:{"@type":"/cosmos.crypto.multisig.LegacyAminoPubKey","threshold":1,"public_keys":[{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AurroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJ"}]} Mnemonic:}`, fmt.Sprintf("%+v", out))
require.Equal(t, `{Name:multisig Type:multi Address:cosmos1nf8lf6n4wa43rzmdzwe6hkrnw5guekhqt595cw EvmAddress: PubKey:{"@type":"/cosmos.crypto.multisig.LegacyAminoPubKey","threshold":1,"public_keys":[{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AurroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJ"}]} Mnemonic:}`, fmt.Sprintf("%+v", out))
}
30 changes: 17 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.18
go 1.21

module github.com/cosmos/cosmos-sdk

Expand All @@ -15,6 +15,7 @@ require (
github.com/cosmos/iavl v0.21.0-alpha.1.0.20230904092046-df3db2d96583
github.com/cosmos/ledger-cosmos-go v0.12.2
github.com/deckarep/golang-set v1.8.0
github.com/ethereum/go-ethereum v1.13.2
github.com/gogo/gateway v1.1.0
github.com/gogo/protobuf v1.3.3
github.com/golang/mock v1.6.0
Expand Down Expand Up @@ -54,8 +55,8 @@ require (
go.opentelemetry.io/otel/exporters/jaeger v1.9.0
go.opentelemetry.io/otel/sdk v1.9.0
go.opentelemetry.io/otel/trace v1.9.0
golang.org/x/crypto v0.14.0
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb
golang.org/x/crypto v0.15.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13
google.golang.org/grpc v1.58.3
google.golang.org/protobuf v1.31.0
Expand All @@ -68,18 +69,20 @@ require (
github.com/DataDog/zstd v1.4.5 // indirect
github.com/alitto/pond v1.8.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.8.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/pebble v0.0.0-20230819001538-1798fbf5956c // indirect
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593 // indirect
github.com/cockroachdb/redact v1.0.8 // indirect
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.1.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v3 v3.2103.2 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
Expand All @@ -96,11 +99,10 @@ require (
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/golang/glog v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.2 // indirect
github.com/google/flatbuffers v1.12.1 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
Expand All @@ -109,6 +111,7 @@ require (
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
Expand Down Expand Up @@ -148,13 +151,13 @@ require (
github.com/zondax/ledger-go v0.14.1 // indirect
go.etcd.io/bbolt v1.3.7 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231012201019-e917dd12ba7a // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand All @@ -176,6 +179,7 @@ replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.1.9
github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-8
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability.
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0
Expand Down
Loading