forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate x/auth cmd's to TxGenerator marshaling (cosmos#6391)
* Migrate encode, decode, and broadcast cmd's to use TxGenerator marshal methods * Fix tests, add EncodingConfig * Add simapp/encoding.go and wire up with simcli * add godocs * fix tests * Debugging CLI Tests * Fix integration test * 6391 - lint issues and code coverage (cosmos#6414) * fixed lint issue of "txEncodeRespStr" * added tests for encode.go * WIP: added tests for decode.go * added txEncoder at bytes * updated decode test * updated txBytes to use TxEncoder in decoder test * added a require after TxEncoder * removed file save * debug decode command * fixed decode tests * added decode cli * updated encode and decode in a single file * separated decode test from encode test * review changes * removed register interface * review change * Fix tests * WIP add test for tx sign * removed commented code * Fix flags * WIP add test for sign * Address review suggestions * fixed command issue * Add tests for TxEncoder * Revert sign changes * Fix TxEncoder tests * Fix GetSign Cmd * Add tx test * Remove duplicate validation * Add tests for TxDecoder * Fix tests * Fix tests * Output to clientCtx.Output * Fix cli_tests Co-authored-by: atheeshp <[email protected]> Co-authored-by: atheesh <[email protected]> Co-authored-by: anilCSE <[email protected]> Co-authored-by: sahith-narahari <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5040ff8
commit 712d237
Showing
32 changed files
with
440 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// TestAccountRetriever is an AccountRetriever that can be used in unit tests | ||
type TestAccountRetriever struct { | ||
Accounts map[string]struct { | ||
Address sdk.AccAddress | ||
Num uint64 | ||
Seq uint64 | ||
} | ||
} | ||
|
||
var _ AccountRetriever = TestAccountRetriever{} | ||
|
||
// EnsureExists implements AccountRetriever.EnsureExists | ||
func (t TestAccountRetriever) EnsureExists(_ NodeQuerier, addr sdk.AccAddress) error { | ||
_, ok := t.Accounts[addr.String()] | ||
if !ok { | ||
return fmt.Errorf("account %s not found", addr) | ||
} | ||
return nil | ||
} | ||
|
||
// GetAccountNumberSequence implements AccountRetriever.GetAccountNumberSequence | ||
func (t TestAccountRetriever) GetAccountNumberSequence(_ NodeQuerier, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error) { | ||
acc, ok := t.Accounts[addr.String()] | ||
if !ok { | ||
return 0, 0, fmt.Errorf("account %s not found", addr) | ||
} | ||
return acc.Num, acc.Seq, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package simapp | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/simapp/params" | ||
"github.com/cosmos/cosmos-sdk/std" | ||
) | ||
|
||
// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. | ||
// | ||
// TODO: this file should add a "+build test_amino" flag for #6190 and a proto.go file with a protobuf configuration | ||
func MakeEncodingConfig() params.EncodingConfig { | ||
encodingConfig := params.MakeEncodingConfig() | ||
std.RegisterCodec(encodingConfig.Amino) | ||
std.RegisterInterfaces(encodingConfig.InterfaceRegistry) | ||
ModuleBasics.RegisterCodec(encodingConfig.Amino) | ||
ModuleBasics.RegisterInterfaceModules(encodingConfig.InterfaceRegistry) | ||
return encodingConfig | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package params | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/types" | ||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
) | ||
|
||
// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. | ||
// | ||
// TODO: this file should add a "+build test_amino" flag for #6190 and a proto.go file with a protobuf configuration | ||
func MakeEncodingConfig() EncodingConfig { | ||
cdc := codec.New() | ||
interfaceRegistry := types.NewInterfaceRegistry() | ||
marshaler := codec.NewHybridCodec(cdc, interfaceRegistry) | ||
|
||
return EncodingConfig{ | ||
InterfaceRegistry: interfaceRegistry, | ||
Marshaler: marshaler, | ||
TxGenerator: authtypes.StdTxGenerator{Cdc: cdc}, | ||
Amino: cdc, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package params | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/codec/types" | ||
) | ||
|
||
// EncodingConfig specifies the concrete encoding types to use for a given app. | ||
// This is provided for compatibility between protobuf and amino implementations. | ||
type EncodingConfig struct { | ||
InterfaceRegistry types.InterfaceRegistry | ||
Marshaler codec.Marshaler | ||
TxGenerator client.TxGenerator | ||
Amino *codec.Codec | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.