Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(textual): Add client-side infra #14661

Merged
merged 117 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
0b0f659
wip
amaury1093 Oct 20, 2022
ea7691b
wip
amaury1093 Oct 20, 2022
d857356
Add signer data to Textual
amaury1093 Oct 20, 2022
6c3c77a
Use any
amaury1093 Oct 20, 2022
94c0501
wip
amaury1093 Oct 24, 2022
49cff84
WIP
amaury1093 Oct 24, 2022
10891fd
add tx vr
amaury1093 Oct 25, 2022
9700665
Add examples
amaury1093 Oct 25, 2022
709dfb5
revert
amaury1093 Oct 25, 2022
460bce9
Add hash
amaury1093 Oct 25, 2022
eeaeaa9
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Oct 25, 2022
ae1fb1f
codegen
amaury1093 Oct 25, 2022
1513109
updates
amaury1093 Oct 25, 2022
18777bf
simplify test
amaury1093 Oct 25, 2022
b29e359
go mod tidy
amaury1093 Oct 25, 2022
b3a5670
Useless import
amaury1093 Oct 25, 2022
4d28d9c
Revert
amaury1093 Oct 25, 2022
f97e3ea
typo
amaury1093 Oct 25, 2022
8e363d5
remove textual fields
amaury1093 Oct 27, 2022
0bad609
create proto types
amaury1093 Oct 27, 2022
6d252e4
Fix tests
amaury1093 Oct 27, 2022
4e24b71
add comment
amaury1093 Oct 27, 2022
d1338ed
regenerate to internal
amaury1093 Nov 2, 2022
3cf05e5
Wire up sign mode handler
amaury1093 Nov 2, 2022
badc2c3
wip
amaury1093 Nov 2, 2022
a815747
Make it work?
amaury1093 Nov 2, 2022
cd038f5
Add comments
amaury1093 Nov 2, 2022
65e60ed
wip
amaury1093 Nov 7, 2022
75e0bc3
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 14, 2022
025a9eb
go mod tidy
amaury1093 Nov 14, 2022
93d4b5d
Use MessageValueRenderer
amaury1093 Nov 14, 2022
9c87a2c
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 28, 2022
f2b7a58
fix conflicts
amaury1093 Nov 28, 2022
0efbc25
Add part2
amaury1093 Nov 28, 2022
77a6ae1
Start doing parse
amaury1093 Nov 28, 2022
4f810fa
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 28, 2022
00c313a
wip
amaury1093 Nov 29, 2022
7c3a6e6
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 29, 2022
96e5137
Show transactions
amaury1093 Nov 29, 2022
bbee363
Add metadata
amaury1093 Nov 29, 2022
98c26e9
Add all fields
amaury1093 Nov 29, 2022
721e0c6
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Nov 30, 2022
bac3383
Add complex test case
amaury1093 Dec 1, 2022
db5dbfb
Link to JSON
amaury1093 Dec 1, 2022
45401a8
changelog
amaury1093 Dec 1, 2022
463a5e4
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Dec 1, 2022
7042623
Update
amaury1093 Dec 1, 2022
6fd8d79
update links
amaury1093 Dec 1, 2022
d0bb4f8
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Dec 2, 2022
201a1ff
go mod tidy
amaury1093 Dec 2, 2022
32a0608
Fix enum
amaury1093 Dec 2, 2022
01cfb3c
Make JSON clearer
amaury1093 Dec 2, 2022
2169ea1
Update links
amaury1093 Dec 2, 2022
b3e0fca
Refactor proto files
amaury1093 Dec 2, 2022
cc59b56
Clean up
amaury1093 Dec 2, 2022
5d96b7d
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Dec 2, 2022
727b93c
WIP parsing
amaury1093 Dec 2, 2022
79c6698
newlines
amaury1093 Dec 6, 2022
0106bc1
Pluralize
amaury1093 Dec 6, 2022
d05479d
Use enveloppe in approach 2a
amaury1093 Dec 6, 2022
cb0b6cc
Coin amounts are Ints
amaury1093 Dec 6, 2022
a1bc7dd
Add tests
amaury1093 Dec 6, 2022
37c9c52
buf format
amaury1093 Dec 6, 2022
82c0dd7
Add address
amaury1093 Dec 6, 2022
ee78038
Fix all tests
amaury1093 Dec 6, 2022
7c9dabc
Add address to spec
amaury1093 Dec 6, 2022
d05951f
Add changelog
amaury1093 Dec 6, 2022
d2d6d19
Update links to examples
amaury1093 Dec 6, 2022
f80932c
Merge branch 'main' into am/13579-textual-tx
amaury1093 Dec 6, 2022
f14e704
envelope
amaury1093 Dec 7, 2022
094abcd
2 test files
amaury1093 Dec 7, 2022
5647c04
Update exampls
amaury1093 Dec 7, 2022
f540695
Merge branch 'main' into am/13579-textual-tx
amaury1093 Dec 7, 2022
979e3ba
Merge branch 'main' into am/13579-textual-tx
amaury1093 Dec 12, 2022
c827732
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/135…
amaury1093 Jan 9, 2023
f54b831
Merge branch 'am/13579-textual-tx' into am/textual-wip-handler
amaury1093 Jan 9, 2023
317b327
Make it build
amaury1093 Jan 9, 2023
a462cb4
Improve any error message
amaury1093 Jan 9, 2023
cbeebaf
Add client-side stuff for textual
amaury1093 Jan 11, 2023
caf25d9
Add references to when to change Envelope
amaury1093 Jan 11, 2023
1a94bd7
Merge branch 'main' into am/13579-textual-tx
amaury1093 Jan 11, 2023
e0a1626
Fix tests
amaury1093 Jan 11, 2023
e3e55b5
Merge branch 'am/13579-textual-tx' of ssh://github.com/cosmos/cosmos-…
amaury1093 Jan 11, 2023
0d321f1
Merge branch 'am/13579-textual-tx' of ssh://github.com/cosmos/cosmos-…
amaury1093 Jan 11, 2023
e358af2
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jan 11, 2023
117cac6
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jan 16, 2023
41fdedd
go mod tidy
amaury1093 Jan 16, 2023
b0d9c4b
Fix build
amaury1093 Jan 16, 2023
3bb2b6f
Amino default still
amaury1093 Jan 16, 2023
6c595dd
revert
amaury1093 Jan 16, 2023
ceae2c5
revert
amaury1093 Jan 16, 2023
ac0b7af
Use local cosmos-ledger-go
amaury1093 Jan 16, 2023
65fd876
clean ups
amaury1093 Jan 16, 2023
17041c5
Update ot latest pacakge
amaury1093 Jan 16, 2023
e3785a5
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jan 17, 2023
f285a6d
x/tx
amaury1093 Jan 17, 2023
ee4e55b
Add ante tests
amaury1093 Jan 17, 2023
fb09df5
Make tests pass
amaury1093 Jan 17, 2023
a4cc711
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/tex…
amaury1093 Jan 18, 2023
ad84318
Update ledger-cosmos-go
amaury1093 Jan 18, 2023
283690f
add experimental
amaury1093 Jan 18, 2023
9b8eac2
Add back test
amaury1093 Jan 18, 2023
44b9b5f
Add comments
amaury1093 Jan 18, 2023
1ba1a9b
Fix
amaury1093 Jan 18, 2023
c525dd0
SignLedgerAminoJSON
amaury1093 Jan 18, 2023
df2da96
Add client textual
amaury1093 Jan 18, 2023
db3fcb9
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/137…
amaury1093 Jan 18, 2023
1c7551b
Fix ledger_mock
amaury1093 Jan 18, 2023
edd02a3
Fix tests
amaury1093 Jan 18, 2023
764dff9
proto-gen
amaury1093 Jan 18, 2023
5e9e13a
Move to same pkg
amaury1093 Jan 23, 2023
b424a5c
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/137…
amaury1093 Jan 23, 2023
1117acc
gofumpt
amaury1093 Jan 23, 2023
01de8e7
Merge branch 'main' into am/13747-textual-client
JeancarloBarrios Jan 23, 2023
f68f4e1
Merge branch 'main' of ssh://github.com/cosmos/cosmos-sdk into am/137…
amaury1093 Jan 24, 2023
eb85bc9
go mod tidy
amaury1093 Jan 24, 2023
4dcf5ae
Merge branch 'main' into am/13747-textual-client
amaury1093 Jan 24, 2023
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

* (crypto/keyring) [#13734](https://github.com/cosmos/cosmos-sdk/pull/13834) The keyring's `Sign` method now takes a new `signMode` argument. It is only used if the signing key is a Ledger hardware device. You can set it to 0 in all other cases.
* (x/evidence) [14724](https://github.com/cosmos/cosmos-sdk/pull/14724) Extract Evidence in its own go.mod and rename the package to `cosmossdk.io/x/evidence`.
* (x/nft) [#14725](https://github.com/cosmos/cosmos-sdk/pull/14725) Extract NFT in its own go.mod and rename the package to `cosmossdk.io/x/nft`.
* (tx) [#14634](https://github.com/cosmos/cosmos-sdk/pull/14634) Move the `tx` go module to `x/tx`.
Expand Down
11 changes: 10 additions & 1 deletion client/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,19 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err

clientCtx = clientCtx.WithFrom(from).WithFromAddress(fromAddr).WithFromName(fromName)

// TODO Remove this once SIGN_MODE_TEXTUAL is released
// ref: https://github.com/cosmos/cosmos-sdk/issues/11970
if keyType == keyring.TypeLedger && clientCtx.SignModeStr == flags.SignModeTextual {
return clientCtx, fmt.Errorf("SIGN_MODE_TEXTUAL is currently not supported, please follow https://github.com/cosmos/cosmos-sdk/issues/11970")
}

// If the `from` signer account is a ledger key, we need to use
// SIGN_MODE_AMINO_JSON, because ledger doesn't support proto yet.
// ref: https://github.com/cosmos/cosmos-sdk/issues/8109
if keyType == keyring.TypeLedger && clientCtx.SignModeStr != flags.SignModeLegacyAminoJSON && !clientCtx.LedgerHasProtobuf {
if keyType == keyring.TypeLedger &&
clientCtx.SignModeStr != flags.SignModeLegacyAminoJSON &&
clientCtx.SignModeStr != flags.SignModeTextual &&
!clientCtx.LedgerHasProtobuf {
fmt.Println("Default sign-mode 'direct' not supported by Ledger, using sign-mode 'amino-json'.")
clientCtx = clientCtx.WithSignModeStr(flags.SignModeLegacyAminoJSON)
}
Expand Down
4 changes: 4 additions & 0 deletions client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ const (
SignModeLegacyAminoJSON = "amino-json"
// SignModeDirectAux is the value of the --sign-mode flag for SIGN_MODE_DIRECT_AUX
SignModeDirectAux = "direct-aux"
// SignModeTextual is the value of the --sign-mode flag for SIGN_MODE_TEXTUAL.
// Choosing this flag will result in an error for now, as Textual should be
// used only for TESTING purposes for now.
SignModeTextual = "textual"
// SignModeEIP191 is the value of the --sign-mode flag for SIGN_MODE_EIP_191
SignModeEIP191 = "eip-191"
)
Expand Down
2 changes: 2 additions & 0 deletions client/tx/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory {
signMode = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON
case flags.SignModeDirectAux:
signMode = signing.SignMode_SIGN_MODE_DIRECT_AUX
case flags.SignModeTextual:
signMode = signing.SignMode_SIGN_MODE_TEXTUAL
case flags.SignModeEIP191:
signMode = signing.SignMode_SIGN_MODE_EIP_191
}
Expand Down
4 changes: 2 additions & 2 deletions client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func Sign(ctx context.Context, txf Factory, name string, txBuilder client.TxBuil
}

// Sign those bytes
sigBytes, _, err := txf.keybase.Sign(name, bytesToSign)
sigBytes, _, err := txf.keybase.Sign(name, bytesToSign, signMode)
if err != nil {
return err
}
Expand Down Expand Up @@ -409,7 +409,7 @@ func makeAuxSignerData(clientCtx client.Context, f Factory, msgs ...sdk.Msg) (tx
return tx.AuxSignerData{}, err
}

sig, _, err := clientCtx.Keyring.Sign(name, signBz)
sig, _, err := clientCtx.Keyring.Sign(name, signBz, f.signMode)
if err != nil {
return tx.AuxSignerData{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion client/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ require (
github.com/cosmos/gogoproto v1.4.3 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.4 // indirect
github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.0 // 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.1.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions client/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
cosmossdk.io/api v0.2.6 h1:AoNwaLLapcLsphhMK6+o0kZl+D6MMUaHVqSdwinASGU=
cosmossdk.io/api v0.2.6/go.mod h1:u/d+GAxil0nWpl1XnQL8nkziQDIWuBDhv8VnDm/s6dI=
cosmossdk.io/core v0.4.1 h1:5icpjPmw8J4uFp6w8OoLJPxsw6X3kRi9nAtTr3qp2Ok=
cosmossdk.io/core v0.4.1/go.mod h1:Zqd1GB+krTF3bzhTnPNwzy3NTtXu+MKLX/9sPQXTIDE=
cosmossdk.io/core v0.5.0 h1:37BkURamssr1FQkE6ZNSjgesLYMflREiykK/Z3k4l7Q=
cosmossdk.io/core v0.5.0/go.mod h1:QVJT+YsJWs0pD/HuczGY5y/WEc9JCn1ycLsuCDUvFlc=
cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z+zfw=
Expand Down Expand Up @@ -143,8 +141,8 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4
github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw=
github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok=
github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw=
github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA=
github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI=
github.com/cosmos/ledger-cosmos-go v0.13.0 h1:ex0CvCxToSR7j5WjrghPu2Bu9sSXKikjnVvUryNnx4s=
github.com/cosmos/ledger-cosmos-go v0.13.0/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6VqkYlkM=
Expand Down
31 changes: 21 additions & 10 deletions crypto/keyring/keyring.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/go-bip39"
)

Expand Down Expand Up @@ -103,10 +104,10 @@ type Keyring interface {
// Signer is implemented by key stores that want to provide signing capabilities.
type Signer interface {
// Sign sign byte messages with a user key.
Sign(uid string, msg []byte) ([]byte, types.PubKey, error)
Sign(uid string, msg []byte, signMode signing.SignMode) ([]byte, types.PubKey, error)

// SignByAddress sign byte messages with a user key providing the address.
SignByAddress(address sdk.Address, msg []byte) ([]byte, types.PubKey, error)
SignByAddress(address sdk.Address, msg []byte, signMode signing.SignMode) ([]byte, types.PubKey, error)
}

// Importer is implemented by key stores that support import of public and private keys.
Expand Down Expand Up @@ -356,7 +357,7 @@ func (ks keystore) ImportPubKey(uid string, armor string) error {
return nil
}

func (ks keystore) Sign(uid string, msg []byte) ([]byte, types.PubKey, error) {
func (ks keystore) Sign(uid string, msg []byte, signMode signing.SignMode) ([]byte, types.PubKey, error) {
k, err := ks.Key(uid)
if err != nil {
return nil, nil, err
Expand All @@ -377,7 +378,7 @@ func (ks keystore) Sign(uid string, msg []byte) ([]byte, types.PubKey, error) {
return sig, priv.PubKey(), nil

case k.GetLedger() != nil:
return SignWithLedger(k, msg)
return SignWithLedger(k, msg, signMode)

// multi or offline record
default:
Expand All @@ -390,13 +391,13 @@ func (ks keystore) Sign(uid string, msg []byte) ([]byte, types.PubKey, error) {
}
}

func (ks keystore) SignByAddress(address sdk.Address, msg []byte) ([]byte, types.PubKey, error) {
func (ks keystore) SignByAddress(address sdk.Address, msg []byte, signMode signing.SignMode) ([]byte, types.PubKey, error) {
k, err := ks.KeyByAddress(address)
if err != nil {
return nil, nil, err
}

return ks.Sign(k.Name, msg)
return ks.Sign(k.Name, msg, signMode)
}

func (ks keystore) SaveLedgerKey(uid string, algo SignatureAlgo, hrp string, coinType, account, index uint32) (*Record, error) {
Expand Down Expand Up @@ -598,7 +599,7 @@ func (ks keystore) SupportedAlgorithms() (SigningAlgoList, SigningAlgoList) {
// SignWithLedger signs a binary message with the ledger device referenced by an Info object
// and returns the signed bytes and the public key. It returns an error if the device could
// not be queried or it returned an error.
func SignWithLedger(k *Record, msg []byte) (sig []byte, pub types.PubKey, err error) {
func SignWithLedger(k *Record, msg []byte, signMode signing.SignMode) (sig []byte, pub types.PubKey, err error) {
ledgerInfo := k.GetLedger()
if ledgerInfo == nil {
return nil, nil, errors.New("not a ledger object")
Expand All @@ -611,9 +612,19 @@ func SignWithLedger(k *Record, msg []byte) (sig []byte, pub types.PubKey, err er
return
}

sig, err = priv.Sign(msg)
if err != nil {
return nil, nil, err
switch signMode {
case signing.SignMode_SIGN_MODE_TEXTUAL:
sig, err = priv.Sign(msg)
if err != nil {
return nil, nil, err
}
case signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON:
sig, err = priv.SignLedgerAminoJSON(msg)
if err != nil {
return nil, nil, err
}
default:
return nil, nil, fmt.Errorf("got invalid sign mode %d, expected LEGACY_AMINO_JSON or TEXTUAL", signMode)
}

if !priv.PubKey().VerifySignature(msg, sig) {
Expand Down
7 changes: 4 additions & 3 deletions crypto/keyring/keyring_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
)

func TestInMemoryCreateLedger(t *testing.T) {
Expand Down Expand Up @@ -66,10 +67,10 @@ func TestSignVerifyKeyRingWithLedger(t *testing.T) {
require.Equal(t, "key", k.Name)

d1 := []byte("my first message")
s1, pub1, err := kb.Sign("key", d1)
s1, pub1, err := kb.Sign("key", d1, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.NoError(t, err)

s2, pub2, err := SignWithLedger(k, d1)
s2, pub2, err := SignWithLedger(k, d1, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.NoError(t, err)

require.True(t, pub1.Equals(pub2))
Expand All @@ -86,7 +87,7 @@ func TestSignVerifyKeyRingWithLedger(t *testing.T) {

k, _, err = kb.NewMnemonic("test", English, types.FullFundraiserPath, DefaultBIP39Passphrase, hd.Secp256k1)
require.NoError(t, err)
_, _, err = SignWithLedger(k, d1)
_, _, err = SignWithLedger(k, d1, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Error(t, err)
require.Equal(t, "not a ledger object", err.Error())
}
Expand Down
27 changes: 14 additions & 13 deletions crypto/keyring/keyring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
)

const (
Expand Down Expand Up @@ -191,27 +192,27 @@ func TestSignVerifyKeyRing(t *testing.T) {
d3 := []byte("feels like I forgot something...")

// try signing both data with both ..
s11, pub1, err := kb.Sign(n1, d1)
s11, pub1, err := kb.Sign(n1, d1, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.NoError(t, err)

key1, err := kr1.GetPubKey()
require.NoError(t, err)
require.NotNil(t, key1)
require.Equal(t, key1, pub1)

s12, pub1, err := kb.Sign(n1, d2)
s12, pub1, err := kb.Sign(n1, d2, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Nil(t, err)
require.Equal(t, key1, pub1)

s21, pub2, err := kb.Sign(n2, d1)
s21, pub2, err := kb.Sign(n2, d1, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Nil(t, err)

key2, err := kr2.GetPubKey()
require.NoError(t, err)
require.NotNil(t, key2)
require.Equal(t, key2, pub2)

s22, pub2, err := kb.Sign(n2, d2)
s22, pub2, err := kb.Sign(n2, d2, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Nil(t, err)
require.Equal(t, key2, pub2)

Expand Down Expand Up @@ -250,7 +251,7 @@ func TestSignVerifyKeyRing(t *testing.T) {
require.NoError(t, err)
require.Equal(t, i3.Name, n3)

_, _, err = kb.Sign(n3, d3)
_, _, err = kb.Sign(n3, d3, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Error(t, err)
require.Equal(t, "cannot sign with offline keys", err.Error())
}
Expand Down Expand Up @@ -642,23 +643,23 @@ func TestInMemorySignVerify(t *testing.T) {
d3 := []byte("feels like I forgot something...")

// try signing both data with both ..
s11, pub1, err := cstore.Sign(n1, d1)
s11, pub1, err := cstore.Sign(n1, d1, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Nil(t, err)
key1, err := kr1.GetPubKey()
require.NoError(t, err)
require.Equal(t, key1, pub1)

s12, pub1, err := cstore.Sign(n1, d2)
s12, pub1, err := cstore.Sign(n1, d2, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Nil(t, err)
require.Equal(t, key1, pub1)

s21, pub2, err := cstore.Sign(n2, d1)
s21, pub2, err := cstore.Sign(n2, d1, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Nil(t, err)
key2, err := kr2.GetPubKey()
require.NoError(t, err)
require.Equal(t, key2, pub2)

s22, pub2, err := cstore.Sign(n2, d2)
s22, pub2, err := cstore.Sign(n2, d2, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Nil(t, err)
require.Equal(t, key2, pub2)

Expand Down Expand Up @@ -698,7 +699,7 @@ func TestInMemorySignVerify(t *testing.T) {
require.Equal(t, i3.Name, n3)

// Now try to sign data with a secret-less key
_, _, err = cstore.Sign(n3, d3)
_, _, err = cstore.Sign(n3, d3, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.Error(t, err)
require.Equal(t, "cannot sign with offline keys", err.Error())
}
Expand Down Expand Up @@ -933,7 +934,7 @@ func ExampleNew() {

// We need to use passphrase to generate a signature
tx := []byte("deadbeef")
sig, pub, err := cstore.Sign("Bob", tx)
sig, pub, err := cstore.Sign("Bob", tx, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
if err != nil {
fmt.Println("don't accept real passphrase")
}
Expand Down Expand Up @@ -1204,7 +1205,7 @@ func TestAltKeyring_Sign(t *testing.T) {

msg := []byte("some message")

sign, key, err := kr.Sign(uid, msg)
sign, key, err := kr.Sign(uid, msg, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.NoError(t, err)

require.True(t, key.VerifySignature(msg, sign))
Expand All @@ -1223,7 +1224,7 @@ func TestAltKeyring_SignByAddress(t *testing.T) {

addr, err := mnemonic.GetAddress()
require.NoError(t, err)
sign, key, err := kr.SignByAddress(addr, msg)
sign, key, err := kr.SignByAddress(addr, msg, signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON)
require.NoError(t, err)

require.True(t, key.VerifySignature(msg, sign))
Expand Down
2 changes: 1 addition & 1 deletion crypto/ledger/ledger_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (mock LedgerSECP256K1Mock) GetAddressPubKeySECP256K1(derivationPath []uint3
return pk, addr, err
}

func (mock LedgerSECP256K1Mock) SignSECP256K1(derivationPath []uint32, message []byte) ([]byte, error) {
func (mock LedgerSECP256K1Mock) SignSECP256K1(derivationPath []uint32, message []byte, p2 byte) ([]byte, error) {
path := hd.NewParams(derivationPath[0], derivationPath[1], derivationPath[2], derivationPath[3] != 0, derivationPath[4])
seed, err := bip39.NewSeedWithErrorChecking(testdata.TestMnemonic, "")
if err != nil {
Expand Down
Loading