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

Update x/auth to use Any #6165

Merged
merged 25 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8c284bf
Migrate keeper codec to use marshaler
sahith-narahari May 7, 2020
ffa0627
Migrate AccountI to types
sahith-narahari May 10, 2020
e5e9d3f
Did go imports
sahith-narahari May 10, 2020
223af59
Fix tests for x/auth
sahith-narahari May 10, 2020
6d9e43f
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/aut…
sahith-narahari May 10, 2020
82be876
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/aut…
sahith-narahari May 11, 2020
f21fb68
Cleanup std/codec
sahith-narahari May 11, 2020
bbd4bab
Sort imports
sahith-narahari May 11, 2020
ff23efa
Fix legacy codec
sahith-narahari May 11, 2020
83e654d
Add godoc for RegisterInterfaces
sahith-narahari May 11, 2020
dadd032
Add RegisterInterfaces to std
sahith-narahari May 15, 2020
d2a15e6
Fix typo
sahith-narahari May 15, 2020
3fec240
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/aut…
sahith-narahari May 15, 2020
22e9fc6
Fixed merge changes
sahith-narahari May 15, 2020
bc9ba3b
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/aut…
sahith-narahari May 15, 2020
4488b72
Eliminate vesting import in auth
sahith-narahari May 15, 2020
9ff8d9c
Fix lint issues
sahith-narahari May 15, 2020
4aa382a
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/aut…
sahith-narahari May 18, 2020
6d58621
Fix tests
sahith-narahari May 18, 2020
067df50
Addressed comments
sahith-narahari May 18, 2020
cf2dd94
Rename interfaces in RegisterInterfaces
sahith-narahari May 19, 2020
cf6e98f
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/aut…
sahith-narahari May 20, 2020
078b16c
Removed codec.proto from std
sahith-narahari May 20, 2020
2e5e9f2
Minor code cleanup
sahith-narahari May 20, 2020
335f994
Merge branch 'master' of github.com:cosmos/cosmos-sdk into sahith/aut…
aaronc May 20, 2020
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
4 changes: 2 additions & 2 deletions simapp/cmd/simd/genaccounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/cosmos/cosmos-sdk/server"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/types"
authvesting "github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/genutil"
Expand Down Expand Up @@ -84,7 +84,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa
}

// create concrete account type based on input parameters
var genAccount authexported.GenesisAccount
var genAccount types.GenesisAccount

balances := bank.Balance{Address: addr, Coins: coins.Sort()}
baseAccount := auth.NewBaseAccount(addr, nil, 0, 0)
Expand Down
3 changes: 1 addition & 2 deletions simapp/genesis_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

var _ authexported.GenesisAccount = (*SimGenesisAccount)(nil)
var _ authtypes.GenesisAccount = (*SimGenesisAccount)(nil)

// SimGenesisAccount defines a type that implements the GenesisAccount interface
// to be used for simulation accounts in the genesis state.
Expand Down
3 changes: 1 addition & 2 deletions simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/cosmos/cosmos-sdk/simapp/helpers"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/bank"
)

Expand Down Expand Up @@ -70,7 +69,7 @@ func Setup(isCheckTx bool) *SimApp {

// SetupWithGenesisAccounts initializes a new SimApp with the provided genesis
// accounts and possible balances.
func SetupWithGenesisAccounts(genAccs []authexported.GenesisAccount, balances ...bank.Balance) *SimApp {
func SetupWithGenesisAccounts(genAccs []auth.GenesisAccount, balances ...bank.Balance) *SimApp {
db := dbm.NewMemDB()
app := NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, 0)

Expand Down
42 changes: 0 additions & 42 deletions std/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ import (
"github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
bankexported "github.com/cosmos/cosmos-sdk/x/bank/exported"
gov "github.com/cosmos/cosmos-sdk/x/gov/types"
)

var (
_ auth.Codec = (*Codec)(nil)
_ bank.Codec = (*Codec)(nil)
_ gov.Codec = (*Codec)(nil)
)
Expand All @@ -35,45 +32,6 @@ func NewAppCodec(amino *codec.Codec, anyUnpacker types.AnyUnpacker) *Codec {
return &Codec{Marshaler: codec.NewHybridCodec(amino, anyUnpacker), amino: amino, anyUnpacker: anyUnpacker}
}

// MarshalAccount marshals an Account interface. If the given type implements
// the Marshaler interface, it is treated as a Proto-defined message and
// serialized that way. Otherwise, it falls back on the internal Amino codec.
func (c *Codec) MarshalAccount(accI authexported.Account) ([]byte, error) {
acc := &Account{}
if err := acc.SetAccount(accI); err != nil {
return nil, err
}

return c.Marshaler.MarshalBinaryBare(acc)
}

// UnmarshalAccount returns an Account interface from raw encoded account bytes
// of a Proto-based Account type. An error is returned upon decoding failure.
func (c *Codec) UnmarshalAccount(bz []byte) (authexported.Account, error) {
acc := &Account{}
if err := c.Marshaler.UnmarshalBinaryBare(bz, acc); err != nil {
return nil, err
}

return acc.GetAccount(), nil
}

// MarshalAccountJSON JSON encodes an account object implementing the Account
// interface.
func (c *Codec) MarshalAccountJSON(acc authexported.Account) ([]byte, error) {
return c.Marshaler.MarshalJSON(acc)
}

// UnmarshalAccountJSON returns an Account from JSON encoded bytes.
func (c *Codec) UnmarshalAccountJSON(bz []byte) (authexported.Account, error) {
acc := &Account{}
if err := c.Marshaler.UnmarshalJSON(bz, acc); err != nil {
return nil, err
}

return acc.GetAccount(), nil
}

// MarshalSupply marshals a SupplyI interface. If the given type implements
// the Marshaler interface, it is treated as a Proto-defined message and
// serialized that way. Otherwise, it falls back on the internal Amino codec.
Expand Down
Loading