Skip to content

Commit

Permalink
Change address from bytes to bech32 strings (cosmos#7242)
Browse files Browse the repository at this point in the history
* init

* Fix bank proto messages

* missing conversions

* remove casttype for addresses

* Fix tests

* Fix consaddress

* more test fixes

* Fix tests

* fixed tests

* migrate missing proto declarations

* format

* Fix format

* Fix alignment

* Fix more tests

* Fix ibc merge issue

* Fix fmt

* Fix more tests

* Fix missing address declarations

* Fix staking tests

* Fix more tests

* Fix config

* fixed tests

* Fix more tests

* Update staking grpc tests

* Fix merge issue

* fixed failing tests in x/distr

* fixed sim tests

* fixed failing tests

* Fix bugs

* Add logs

* fixed slashing issue

* Fix staking grpc tests

* Fix all bank tests :)

* Fix tests in distribution

* Fix more tests in distr

* Fix slashing tests

* Fix statking tests

* Fix evidence tests

* Fix gov tests

* Fix bug in create vesting account

* Fix test

* remove fmt

* fixed gov tests

* fixed x/ibc tests

* fixed x/ibc-transfer tests

* fixed staking tests

* fixed staking tests

* fixed test

* fixed distribution issue

* fix pagination test

* fmt

* lint

* fix build

* fix format

* revert tally tests

* revert tally tests

* lint

* Fix sim test

* revert

* revert

* fixed tally issue

* fix tests

* revert

* fmt

* refactor

* remove `GetAddress()`

* remove fmt

* revert fmt.Striger usage

* Fix tests

* Fix rest test

* disable interfacer lint check

* make proto-format

* add nolint rule

* remove stray println

Co-authored-by: aleem1314 <[email protected]>
Co-authored-by: atheesh <[email protected]>
  • Loading branch information
3 people authored Sep 25, 2020
1 parent 91ca8ad commit d55c1a2
Show file tree
Hide file tree
Showing 247 changed files with 5,812 additions and 7,807 deletions.
6 changes: 4 additions & 2 deletions client/grpc/reflection/reflection.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (s *IntegrationTestSuite) TestGRPCQuery() {
var header metadata.MD
bankRes, err := bankClient.Balance(
context.Background(),
&banktypes.QueryBalanceRequest{Address: val0.Address, Denom: denom},
&banktypes.QueryBalanceRequest{Address: val0.Address.String(), Denom: denom},
grpc.Header(&header), // Also fetch grpc header
)
s.Require().NoError(err)
Expand All @@ -70,7 +70,7 @@ func (s *IntegrationTestSuite) TestGRPCQuery() {
bankClient = banktypes.NewQueryClient(val0.ClientCtx)
bankRes, err = bankClient.Balance(
context.Background(),
&banktypes.QueryBalanceRequest{Address: val0.Address, Denom: denom},
&banktypes.QueryBalanceRequest{Address: val0.Address.String(), Denom: denom},
grpc.Header(&header),
)
blockHeight = header.Get(grpctypes.GRPCBlockHeightHeader)
Expand Down
8 changes: 4 additions & 4 deletions crypto/types/crypto.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions proto/cosmos/auth/v1beta1/auth.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";
// for basic account functionality. Any custom account type should extend this
// type for additional functionality (e.g. vesting).
message BaseAccount {
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = false;

option (cosmos_proto.implements_interface) = "AccountI";

bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
string address = 1;
google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""];
uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""];
uint64 sequence = 4;
Expand Down
5 changes: 4 additions & 1 deletion proto/cosmos/auth/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ service Query {

// QueryAccountRequest is the request type for the Query/Account RPC method.
message QueryAccountRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// address defines the address to query for.
bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
string address = 1;
}

// QueryAccountResponse is the response type for the Query/Account RPC method.
Expand Down
20 changes: 12 additions & 8 deletions proto/cosmos/bank/v1beta1/bank.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ message Params {
bool default_send_enabled = 2 [(gogoproto.moretags) = "yaml:\"default_send_enabled,omitempty\""];
}

// SendEnabled maps coin denom to a send_enabled status (whether a denom is sendable).
// SendEnabled maps coin denom to a send_enabled status (whether a denom is
// sendable).
message SendEnabled {
option (gogoproto.equal) = true;
option (gogoproto.goproto_stringer) = false;
Expand All @@ -24,28 +25,31 @@ message SendEnabled {

// Input models transaction input.
message Input {
option (gogoproto.equal) = true;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
string address = 1;
repeated cosmos.base.v1beta1.Coin coins = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
}

// Output models transaction outputs.
message Output {
option (gogoproto.equal) = true;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
string address = 1;
repeated cosmos.base.v1beta1.Coin coins = 2
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
}

// Supply represents a struct that passively keeps track of the total supply
// amounts in the network.
message Supply {
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
option (gogoproto.equal) = true;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

option (cosmos_proto.implements_interface) = "*github.com/cosmos/cosmos-sdk/x/bank/exported.SupplyI";

repeated cosmos.base.v1beta1.Coin total = 1
Expand Down
3 changes: 2 additions & 1 deletion proto/cosmos/bank/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ message GenesisState {
// Balance defines an account address and balance pair used in the bank module's
// genesis state.
message Balance {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// address is the address of the balance holder.
bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
string address = 1;

// coins defines the different coins this balance holds.
repeated cosmos.base.v1beta1.Coin coins = 2
Expand Down
19 changes: 14 additions & 5 deletions proto/cosmos/bank/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ service Query {

// QueryBalanceRequest is the request type for the Query/Balance RPC method.
message QueryBalanceRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// address is the address to query balances for.
bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
string address = 1;

// denom is the coin denom to query balances for.
string denom = 2;
Expand All @@ -54,14 +57,18 @@ message QueryBalanceResponse {

// QueryBalanceRequest is the request type for the Query/AllBalances RPC method.
message QueryAllBalancesRequest {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

// address is the address to query balances for.
bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
string address = 1;

// pagination defines an optional pagination for the request.
cosmos.base.query.v1beta1.PageRequest pagination = 2;
}

// QueryAllBalancesResponse is the response type for the Query/AllBalances RPC method.
// QueryAllBalancesResponse is the response type for the Query/AllBalances RPC
// method.
message QueryAllBalancesResponse {
// balances is the balances of all the coins.
repeated cosmos.base.v1beta1.Coin balances = 1
Expand All @@ -71,10 +78,12 @@ message QueryAllBalancesResponse {
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC method.
// QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC
// method.
message QueryTotalSupplyRequest {}

// QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC method
// QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC
// method
message QueryTotalSupplyResponse {
// supply is the supply of the coins
repeated cosmos.base.v1beta1.Coin supply = 1
Expand Down
15 changes: 5 additions & 10 deletions proto/cosmos/bank/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,18 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/bank/types";

// MsgSend represents a message to send coins from one account to another.
message MsgSend {
option (gogoproto.equal) = true;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

bytes from_address = 1 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"from_address\""
];
bytes to_address = 2 [
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
(gogoproto.moretags) = "yaml:\"to_address\""
];
string from_address = 1 [(gogoproto.moretags) = "yaml:\"from_address\""];
string to_address = 2 [(gogoproto.moretags) = "yaml:\"to_address\""];
repeated cosmos.base.v1beta1.Coin amount = 3
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
}

// MsgMultiSend represents an arbitrary multi-in, multi-out send message.
message MsgMultiSend {
option (gogoproto.equal) = true;
option (gogoproto.equal) = false;

repeated Input inputs = 1 [(gogoproto.nullable) = false];
repeated Output outputs = 2 [(gogoproto.nullable) = false];
Expand Down
23 changes: 13 additions & 10 deletions proto/cosmos/base/abci/v1beta1/abci.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ message TxResponse {
uint32 code = 4;
// Result bytes, if any.
string data = 5;
// The output of the application's logger (raw string). May be non-deterministic.
// The output of the application's logger (raw string). May be
// non-deterministic.
string raw_log = 6;
// The output of the application's logger (typed). May be non-deterministic.
repeated ABCIMessageLog logs = 7 [(gogoproto.castrepeated) = "ABCIMessageLogs", (gogoproto.nullable) = false];
Expand All @@ -34,8 +35,9 @@ message TxResponse {
int64 gas_used = 10;
// The request transaction bytes.
google.protobuf.Any tx = 11;
// Time of the previous block. For heights > 1, it's the weighted median of the
// timestamps of the valid votes in the block.LastCommit. For height == 1, it's genesis time.
// Time of the previous block. For heights > 1, it's the weighted median of
// the timestamps of the valid votes in the block.LastCommit. For height == 1,
// it's genesis time.
string timestamp = 12;
}

Expand Down Expand Up @@ -80,15 +82,15 @@ message GasInfo {
message Result {
option (gogoproto.goproto_getters) = false;

// Data is any data returned from message or handler execution. It MUST be length
// prefixed in order to separate data from multiple message executions.
// Data is any data returned from message or handler execution. It MUST be
// length prefixed in order to separate data from multiple message executions.
bytes data = 1;

// Log contains the log information from message or handler execution.
string log = 2;

// Events contains a slice of Event objects that were emitted during message or
// handler execution.
// Events contains a slice of Event objects that were emitted during message
// or handler execution.
repeated tendermint.abci.Event events = 3 [(gogoproto.nullable) = false];
}

Expand All @@ -99,16 +101,17 @@ message SimulationResponse {
Result result = 2;
}

// MsgData defines the data returned in a Result object during message execution.
// MsgData defines the data returned in a Result object during message
// execution.
message MsgData {
option (gogoproto.stringer) = true;

string msg_type = 1;
bytes data = 2;
}

// TxMsgData defines a list of MsgData. A transaction will have a MsgData object for
// each message.
// TxMsgData defines a list of MsgData. A transaction will have a MsgData object
// for each message.
message TxMsgData {
option (gogoproto.stringer) = true;

Expand Down
8 changes: 4 additions & 4 deletions proto/cosmos/base/crypto/v1beta1/crypto.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ message PublicKey {
}
}

// PubKeyMultisigThreshold specifies a public key type which nests multiple public
// keys and a threshold
// PubKeyMultisigThreshold specifies a public key type which nests multiple
// public keys and a threshold
message PubKeyMultisigThreshold {
uint32 threshold = 1 [(gogoproto.customname) = "K", (gogoproto.moretags) = "yaml:\"threshold\""];
repeated PublicKey public_keys = 2 [(gogoproto.customname) = "PubKeys", (gogoproto.moretags) = "yaml:\"pubkeys\""];
}

// MultiSignature wraps the signatures from a PubKeyMultisigThreshold.
// See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers signed and
// with which modes.
// See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers
// signed and with which modes.
message MultiSignature {
option (gogoproto.goproto_unrecognized) = true;
repeated bytes signatures = 1;
Expand Down
9 changes: 5 additions & 4 deletions proto/cosmos/base/query/v1beta1/pagination.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ message PageRequest {
uint64 limit = 3;

// count_total is set to true to indicate that the result set should include
// a count of the total number of items available for pagination in UIs. count_total
// is only respected when offset is used. It is ignored when key is set.
// a count of the total number of items available for pagination in UIs.
// count_total is only respected when offset is used. It is ignored when key
// is set.
bool count_total = 4;
}

// PageResponse is to be embedded in gRPC response messages where the corresponding
// request message has used PageRequest.
// PageResponse is to be embedded in gRPC response messages where the
// corresponding request message has used PageRequest.
//
// message SomeResponse {
// repeated Bar results = 1;
Expand Down
9 changes: 6 additions & 3 deletions proto/cosmos/base/reflection/v1beta1/reflection.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ service ReflectionService {
// ListImplementations list all the concrete types that implement a given
// interface.
rpc ListImplementations(ListImplementationsRequest) returns (ListImplementationsResponse) {
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces/{interface_name}/implementations";
option (google.api.http).get = "/cosmos/base/reflection/v1beta1/interfaces/"
"{interface_name}/implementations";
};
}

Expand All @@ -29,13 +30,15 @@ message ListAllInterfacesResponse {
repeated string interface_names = 1;
}

// ListImplementationsRequest is the request type of the ListImplementations RPC.
// ListImplementationsRequest is the request type of the ListImplementations
// RPC.
message ListImplementationsRequest {
// interface_name defines the interface to query the implementations for.
string interface_name = 1;
}

// ListImplementationsResponse is the response type of the ListImplementations RPC.
// ListImplementationsResponse is the response type of the ListImplementations
// RPC.
message ListImplementationsResponse {
repeated string implementation_message_names = 1;
}
4 changes: 2 additions & 2 deletions proto/cosmos/capability/v1beta1/capability.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/capability/types";

import "gogoproto/gogo.proto";

// Capability defines an implementation of an object capability. The index provided to
// a Capability must be globally unique.
// Capability defines an implementation of an object capability. The index
// provided to a Capability must be globally unique.
message Capability {
option (gogoproto.goproto_stringer) = false;

Expand Down
5 changes: 3 additions & 2 deletions proto/cosmos/crisis/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import "gogoproto/gogo.proto";

// MsgVerifyInvariant represents a message to verify a particular invariance.
message MsgVerifyInvariant {
option (gogoproto.equal) = true;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;

bytes sender = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
string sender = 1;
string invariant_module_name = 2 [(gogoproto.moretags) = "yaml:\"invariant_module_name\""];
string invariant_route = 3 [(gogoproto.moretags) = "yaml:\"invariant_route\""];
}
Loading

0 comments on commit d55c1a2

Please sign in to comment.