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

Switch all proto structs to use strings for addresses #165

Merged
merged 4 commits into from
May 8, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
42 changes: 21 additions & 21 deletions proto/osmosis/epochs/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ import "google/protobuf/timestamp.proto";
option go_package = "github.com/c-osmosis/osmosis/x/epochs/types";

message EpochInfo {
string identifier = 1;
google.protobuf.Timestamp start_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"start_time\""
];
google.protobuf.Duration duration = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"duration\""
];
int64 current_epoch = 4;
google.protobuf.Timestamp current_epoch_start_time = 5 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"current_epoch_start_time\""
];
bool epoch_counting_started = 6;
bool current_epoch_ended = 7;
string identifier = 1;
google.protobuf.Timestamp start_time = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"start_time\""
];
google.protobuf.Duration duration = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
(gogoproto.jsontag) = "duration,omitempty",
(gogoproto.moretags) = "yaml:\"duration\""
];
int64 current_epoch = 4;
google.protobuf.Timestamp current_epoch_start_time = 5 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
(gogoproto.moretags) = "yaml:\"current_epoch_start_time\""
];
bool epoch_counting_started = 6;
bool current_epoch_ended = 7;
}

// GenesisState defines the epochs module's genesis state.
message GenesisState {
repeated EpochInfo epochs = 1 [(gogoproto.nullable) = false];
repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ];
}
10 changes: 5 additions & 5 deletions proto/osmosis/epochs/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ option go_package = "github.com/c-osmosis/osmosis/x/epochs/types";

// Query defines the gRPC querier service.
service Query {
// EpochInfos provide running epochInfos
rpc EpochInfos(QueryEpochsInfoRequest) returns (QueryEpochsInfoResponse) {
option (google.api.http).get = "/osmosis/epochs/v1beta1/epochs";
}
// EpochInfos provide running epochInfos
rpc EpochInfos(QueryEpochsInfoRequest) returns (QueryEpochsInfoResponse) {
option (google.api.http).get = "/osmosis/epochs/v1beta1/epochs";
}
}

message QueryEpochsInfoRequest {}
message QueryEpochsInfoResponse {
repeated EpochInfo epochs = 1 [(gogoproto.nullable) = false];
repeated EpochInfo epochs = 1 [ (gogoproto.nullable) = false ];
}
3 changes: 1 addition & 2 deletions proto/osmosis/gamm/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ message QueryPoolsResponse {
}

//=============================== TotalPools
message QueryTotalPoolsRequest {
}
message QueryTotalPoolsRequest {}
message QueryTotalPoolsResponse {
uint64 totalPools = 1 [ (gogoproto.moretags) = "yaml:\"total_pools\"" ];
}
Expand Down
6 changes: 3 additions & 3 deletions proto/osmosis/incentives/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ option go_package = "github.com/c-osmosis/osmosis/x/incentives/types";

// GenesisState defines the incentives module's genesis state.
message GenesisState {
// params defines all the parameters of the module
Params params = 1 [(gogoproto.nullable) = false];
repeated Pot pots = 2 [(gogoproto.nullable) = false];
// params defines all the parameters of the module
Params params = 1 [ (gogoproto.nullable) = false ];
repeated Pot pots = 2 [ (gogoproto.nullable) = false ];
}
5 changes: 3 additions & 2 deletions proto/osmosis/incentives/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ option go_package = "github.com/c-osmosis/osmosis/x/incentives/types";

// Params holds parameters for the incentives module
message Params {
// distribution epoch identifier
string distr_epoch_identifier = 1 [(gogoproto.moretags) = "yaml:\"distr_epoch_identifier\""];
// distribution epoch identifier
string distr_epoch_identifier = 1
[ (gogoproto.moretags) = "yaml:\"distr_epoch_identifier\"" ];
}
3 changes: 1 addition & 2 deletions proto/osmosis/incentives/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ message UpcomingPotsResponse {
}

message RewardsEstRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
repeated lockup.PeriodLock locks = 2 [ (gogoproto.nullable) = false ];
repeated Pot pots = 3 [ (gogoproto.nullable) = false ];
int64 end_epoch = 4;
Expand Down
6 changes: 2 additions & 4 deletions proto/osmosis/incentives/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ service Msg {
message MsgCreatePot {
bool is_perpetual = 1; // flag to show if it's perpetual or multi-epoch
// distribution incentives by third party
bytes owner = 2 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 2 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
osmosis.lockup.QueryCondition distribute_to = 3 [
(gogoproto.nullable) = false
]; // distribute condition of a lock which meet one of these conditions
Expand All @@ -37,8 +36,7 @@ message MsgCreatePot {
message MsgCreatePotResponse {}

message MsgAddToPot {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
uint64 pot_id = 2;
repeated cosmos.base.v1beta1.Coin rewards = 3 [
(gogoproto.nullable) = false,
Expand Down
3 changes: 1 addition & 2 deletions proto/osmosis/lockup/lock.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ option go_package = "github.com/c-osmosis/osmosis/x/lockup/types";
// coins locked.
message PeriodLock {
uint64 ID = 1;
bytes owner = 2 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 2 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Duration duration = 3 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
Expand Down
30 changes: 10 additions & 20 deletions proto/osmosis/lockup/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ message ModuleLockedAmountResponse {
};

message AccountUnlockableCoinsRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
};
message AccountUnlockableCoinsResponse {
repeated cosmos.base.v1beta1.Coin coins = 1 [
Expand All @@ -86,8 +85,7 @@ message AccountUnlockableCoinsResponse {
};

message AccountUnlockingCoinsRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
}
message AccountUnlockingCoinsResponse {
repeated cosmos.base.v1beta1.Coin coins = 1 [
Expand All @@ -97,8 +95,7 @@ message AccountUnlockingCoinsResponse {
}

message AccountLockedCoinsRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
};
message AccountLockedCoinsResponse {
repeated cosmos.base.v1beta1.Coin coins = 1 [
Expand All @@ -108,8 +105,7 @@ message AccountLockedCoinsResponse {
};

message AccountLockedPastTimeRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Timestamp timestamp = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
Expand All @@ -121,8 +117,7 @@ message AccountLockedPastTimeResponse {
};

message AccountLockedPastTimeNotUnlockingOnlyRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Timestamp timestamp = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
Expand All @@ -134,8 +129,7 @@ message AccountLockedPastTimeNotUnlockingOnlyResponse {
};

message AccountUnlockedBeforeTimeRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Timestamp timestamp = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
Expand All @@ -147,8 +141,7 @@ message AccountUnlockedBeforeTimeResponse {
}

message AccountLockedPastTimeDenomRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Timestamp timestamp = 2 [
(gogoproto.stdtime) = true,
(gogoproto.nullable) = false,
Expand All @@ -164,8 +157,7 @@ message LockedRequest { uint64 lock_id = 1; };
message LockedResponse { PeriodLock lock = 1; };

message AccountLockedLongerDurationRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Duration duration = 2 [
(gogoproto.stdduration) = true,
(gogoproto.nullable) = false,
Expand All @@ -177,8 +169,7 @@ message AccountLockedLongerDurationResponse {
};

message AccountLockedLongerDurationNotUnlockingOnlyRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Duration duration = 2 [
(gogoproto.stdduration) = true,
(gogoproto.nullable) = false,
Expand All @@ -190,8 +181,7 @@ message AccountLockedLongerDurationNotUnlockingOnlyResponse {
};

message AccountLockedLongerDurationDenomRequest {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Duration duration = 2 [
(gogoproto.stdduration) = true,
(gogoproto.nullable) = false,
Expand Down
15 changes: 5 additions & 10 deletions proto/osmosis/lockup/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ service Msg {
}

message MsgLockTokens {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
google.protobuf.Duration duration = 2 [
(gogoproto.nullable) = false,
(gogoproto.stdduration) = true,
Expand All @@ -41,27 +40,23 @@ message MsgLockTokens {
message MsgLockTokensResponse { uint64 ID = 1; }

message MsgBeginUnlocking {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
}
message MsgBeginUnlockingResponse { repeated PeriodLock unlocks = 1; }

message MsgUnlockTokens {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
}
message MsgUnlockTokensResponse { repeated PeriodLock unlocks = 1; }

message MsgBeginUnlockPeriodLock {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
uint64 ID = 2;
}
message MsgBeginUnlockPeriodLockResponse { bool success = 1; }

message MsgUnlockPeriodLock {
bytes owner = 1 [ (gogoproto.casttype) =
"github.com/cosmos/cosmos-sdk/types.AccAddress" ];
string owner = 1 [ (gogoproto.moretags) = "yaml:\"owner\"" ];
uint64 ID = 2;
}
message MsgUnlockPeriodLockResponse { bool success = 1; }
1 change: 0 additions & 1 deletion x/gamm/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func ValidateFutureGovernor(governor string) error {
return nil
}


lockTimeStr := ""
splits := strings.Split(governor, ",")
if len(splits) > 2 {
Expand Down
41 changes: 25 additions & 16 deletions x/incentives/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,28 @@ func NewCreatePotCmd() *cobra.Command {
return err
}

msg := &types.MsgCreatePot{
Owner: clientCtx.GetFromAddress(),
DistributeTo: lockuptypes.QueryCondition{
LockQueryType: lockuptypes.LockQueryType(queryType),
Denom: denom,
Duration: duration,
Timestamp: time.Unix(timestamp, 0),
},
Coins: coins,
StartTime: startTime,
NumEpochsPaidOver: numEpochsPaidOver,
distributeTo := lockuptypes.QueryCondition{
LockQueryType: lockuptypes.LockQueryType(queryType),
Denom: denom,
Duration: duration,
Timestamp: time.Unix(timestamp, 0),
}

// TODO: Confirm this is correct logic
isPerpetual := false
if numEpochsPaidOver == 0 {
isPerpetual = true
}

msg := types.NewMsgCreatePot(
isPerpetual,
clientCtx.GetFromAddress(),
distributeTo,
coins,
startTime,
numEpochsPaidOver,
)

return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg)
},
}
Expand Down Expand Up @@ -133,11 +142,11 @@ func NewAddToPotCmd() *cobra.Command {
return err
}

msg := &types.MsgAddToPot{
Owner: clientCtx.GetFromAddress(),
PotId: potId,
Rewards: rewards,
}
msg := types.NewMsgAddToPot(
clientCtx.GetFromAddress(),
potId,
rewards,
)

return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg)
},
Expand Down
6 changes: 5 additions & 1 deletion x/incentives/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,9 @@ func (k Keeper) UpcomingPots(goCtx context.Context, req *types.UpcomingPotsReque
// RewardsEst returns rewards estimation at a future specific time
func (k Keeper) RewardsEst(goCtx context.Context, req *types.RewardsEstRequest) (*types.RewardsEstResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
return &types.RewardsEstResponse{Coins: k.GetRewardsEst(ctx, req.Owner, req.Locks, req.Pots, req.EndEpoch)}, nil
owner, err := sdk.AccAddressFromBech32(req.Owner)
if err != nil {
return nil, err
}
return &types.RewardsEstResponse{Coins: k.GetRewardsEst(ctx, owner, req.Locks, req.Pots, req.EndEpoch)}, nil
}
4 changes: 2 additions & 2 deletions x/incentives/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (suite *KeeperTestSuite) TestGRPCRewardsEst() {
// initial check
lockOwner := sdk.AccAddress([]byte("addr1---------------"))
res, err := suite.app.IncentivesKeeper.RewardsEst(sdk.WrapSDKContext(suite.ctx), &types.RewardsEstRequest{
Owner: lockOwner,
Owner: lockOwner.String(),
})
suite.Require().NoError(err)
suite.Require().Equal(res.Coins, sdk.Coins{})
Expand All @@ -154,7 +154,7 @@ func (suite *KeeperTestSuite) TestGRPCRewardsEst() {
lockOwner, _, coins, _ := suite.SetupLockAndPot(false)

res, err = suite.app.IncentivesKeeper.RewardsEst(sdk.WrapSDKContext(suite.ctx), &types.RewardsEstRequest{
Owner: lockOwner,
Owner: lockOwner.String(),
EndEpoch: 100,
})
suite.Require().NoError(err)
Expand Down
Loading