Skip to content

Commit 3dee6cc

Browse files
chore(uibc): update quota -> outflows (#1865)
* chore(uibc): update quota -> outflows * renames * review --------- Co-authored-by: Sai Kumar <17549398+gsk967@users.noreply.github.com>
1 parent 25827f8 commit 3dee6cc

File tree

17 files changed

+257
-262
lines changed

17 files changed

+257
-262
lines changed

proto/umee/uibc/v1/genesis.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ option (gogoproto.goproto_getters_all) = false;
1212

1313
// GenesisState defines the uibc module's genesis state.
1414
message GenesisState {
15-
Params params = 1 [(gogoproto.nullable) = false];
16-
repeated cosmos.base.v1beta1.DecCoin quotas = 2 [
15+
Params params = 1 [(gogoproto.nullable) = false];
16+
repeated cosmos.base.v1beta1.DecCoin outflows = 2 [
1717
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
1818
(gogoproto.nullable) = false
1919
];
2020

21-
// total_outflow_sum defines the total outflow sum of ibc-transfer in USD
21+
// total_outflow_sum defines the total outflow sum of ibc-transfer in USD.
2222
string total_outflow_sum = 3 [
2323
(cosmos_proto.scalar) = "cosmos.Dec",
2424
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
2525
(gogoproto.nullable) = false
2626
];
27-
// quota_expires defines quota expires for ibc-transfer denom in seconds
27+
// quota_expires defines quota expire time (as unix timestamp) for ibc-transfer denom.
2828
google.protobuf.Timestamp quota_expires = 4 [
2929
(gogoproto.nullable) = false,
3030
(gogoproto.stdtime) = true,

proto/umee/uibc/v1/query.proto

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ service Query {
1717
option (google.api.http).get = "/umee/uibc/v1/params";
1818
}
1919

20-
// Quota queries the rate limits of ibc denoms.
21-
// If denom is empty, returns quota for all tokens.
22-
rpc Quota(QueryQuota) returns (QueryQuotaResponse) {
23-
option (google.api.http).get = "/umee/uibc/v1/quota/{denom}";
20+
// Outflow returns IBC denom outflows in the current epoch.
21+
// If denom is empty, returns outflows of all tokens in the current epoch.
22+
rpc Outflows(QueryOutflows) returns (QueryOutflowsResponse) {
23+
option (google.api.http).get = "/umee/uibc/v1/outflows/{denom}";
2424
}
2525
}
2626

@@ -34,14 +34,14 @@ message QueryParamsResponse {
3434
Params params = 1 [(gogoproto.nullable) = false];
3535
}
3636

37-
// QueryQuota defines request type for query the quota of denoms
38-
message QueryQuota {
37+
// QueryOutflow defines request type for query the quota of denoms
38+
message QueryOutflows {
3939
string denom = 1;
4040
}
4141

42-
// QueryQuotaResponse defines response type of Query/Quota
43-
message QueryQuotaResponse {
44-
repeated cosmos.base.v1beta1.DecCoin quotas = 1 [
42+
// QueryOutflowResponse defines response type of Query/Outflow
43+
message QueryOutflowsResponse {
44+
repeated cosmos.base.v1beta1.DecCoin outflows = 1 [
4545
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
4646
(gogoproto.nullable) = false
4747
];

x/uibc/client/cli/query.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func GetQueryCmd() *cobra.Command {
2222

2323
cmd.AddCommand(
2424
GetCmdQueryParams(),
25-
GetQuota(),
25+
GetOutflows(),
2626
)
2727

2828
return cmd
@@ -52,24 +52,24 @@ func GetCmdQueryParams() *cobra.Command {
5252
return cmd
5353
}
5454

55-
// GetQuota returns cmd to get the quota of ibc denoms.
56-
func GetQuota() *cobra.Command {
55+
// GetOutflows returns cmd creator
56+
func GetOutflows() *cobra.Command {
5757
cmd := &cobra.Command{
58-
Use: "quota [denom]",
58+
Use: "outflows [denom]",
5959
Args: cobra.MaximumNArgs(1),
60-
Short: "Get the quota for ibc and native denoms",
60+
Short: "Get the outflows for ibc and native denoms",
6161
RunE: func(cmd *cobra.Command, args []string) error {
6262
clientCtx, err := client.GetClientQueryContext(cmd)
6363
if err != nil {
6464
return err
6565
}
6666

6767
queryClient := uibc.NewQueryClient(clientCtx)
68-
queryReq := uibc.QueryQuota{}
68+
queryReq := uibc.QueryOutflows{}
6969
if len(args) > 0 {
7070
queryReq.Denom = args[0]
7171
}
72-
resp, err := queryClient.Quota(cmd.Context(), &queryReq)
72+
resp, err := queryClient.Outflows(cmd.Context(), &queryReq)
7373
return cli.PrintOrErr(resp, err, clientCtx)
7474
},
7575
}

x/uibc/client/tests/cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestIntegrationSuite(t *testing.T) {
4141

4242
var uibcGenState uibc.GenesisState
4343
assert.NilError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[uibc.ModuleName], &uibcGenState))
44-
uibcGenState.Quotas = sdk.DecCoins{sdk.NewInt64DecCoin("uumee", 0)}
44+
uibcGenState.Outflows = sdk.DecCoins{sdk.NewInt64DecCoin("uumee", 0)}
4545
uibcGenState.TotalOutflowSum = sdk.NewDec(10)
4646

4747
bz, err = cfg.Codec.MarshalJSON(&uibcGenState)

x/uibc/client/tests/query_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ func (s *IntegrationTestSuite) TestGetQuota(t *testing.T) {
6767

6868
for _, tc := range tests {
6969
t.Run(tc.name, func(t *testing.T) {
70-
out, err := clitestutil.ExecTestCLICmd(clientCtx, cli.GetQuota(), tc.args)
70+
out, err := clitestutil.ExecTestCLICmd(clientCtx, cli.GetOutflows(), tc.args)
7171
if tc.errMsg == "" {
72-
var res uibc.QueryQuotaResponse
72+
var res uibc.QueryOutflowsResponse
7373
assert.NilError(t, clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res))
74-
assert.Equal(t, len(res.Quotas), tc.noOfRecords)
74+
assert.Equal(t, len(res.Outflows), tc.noOfRecords)
7575
} else {
7676
assert.ErrorContains(t, err, tc.errMsg)
7777
}

x/uibc/genesis.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import (
77
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
88
)
99

10-
func NewGenesisState(params Params, quotas sdk.DecCoins, outflowSum sdk.Dec) *GenesisState {
10+
func NewGenesisState(params Params, outflows sdk.DecCoins, outflowSum sdk.Dec) *GenesisState {
1111
return &GenesisState{
1212
Params: params,
13-
Quotas: quotas,
13+
Outflows: outflows,
1414
TotalOutflowSum: outflowSum,
1515
}
1616
}
1717

1818
func DefaultGenesisState() *GenesisState {
1919
return &GenesisState{
2020
Params: DefaultParams(),
21-
Quotas: nil,
21+
Outflows: nil,
2222
TotalOutflowSum: sdk.NewDec(0),
2323
}
2424
}
@@ -29,11 +29,11 @@ func (gs GenesisState) Validate() error {
2929
return err
3030
}
3131

32-
for _, quota := range gs.Quotas {
33-
if quota.Amount.IsNil() {
34-
return sdkerrors.ErrInvalidRequest.Wrap("ibc denom quota must be defined")
32+
for _, o := range gs.Outflows {
33+
if o.Amount.IsNil() {
34+
return sdkerrors.ErrInvalidRequest.Wrap("ibc denom outflow must be defined")
3535
}
36-
if err := quota.Validate(); err != nil {
36+
if err := o.Validate(); err != nil {
3737
return err
3838
}
3939
}

x/uibc/genesis.pb.go

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

x/uibc/genesis_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestGenesisValidation(t *testing.T) {
1616
err = gs.Validate()
1717
assert.ErrorContains(t, err, "total outflow sum cannot be negative")
1818

19-
gs.Quotas = []sdk.DecCoin{{Denom: "umee", Amount: sdk.NewDec(-11123123)}}
19+
gs.Outflows = []sdk.DecCoin{{Denom: "umee", Amount: sdk.NewDec(-11123123)}}
2020
err = gs.Validate()
2121
assert.ErrorContains(t, err, "amount cannot be negative")
2222
}

x/uibc/keys.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const (
1616
)
1717

1818
var (
19-
KeyPrefixDenomQuota = []byte{0x01}
19+
KeyPrefixDenomOutflows = []byte{0x01}
2020
KeyPrefixTotalOutflows = []byte{0x02}
2121
// KeyPrefixParams is the key to query all gov params
2222
KeyPrefixParams = []byte{0x03}
@@ -26,5 +26,5 @@ var (
2626

2727
func KeyTotalOutflows(ibcDenom string) []byte {
2828
// KeyPrefixDenomQuota| denom
29-
return util.ConcatBytes(0, KeyPrefixDenomQuota, []byte(ibcDenom))
29+
return util.ConcatBytes(0, KeyPrefixDenomOutflows, []byte(ibcDenom))
3030
}

x/uibc/module/abci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func BeginBlock(ctx sdk.Context, keeper keeper.Keeper) {
1414

1515
// reset quotas
1616
if quotaExpires == nil || quotaExpires.Before(ctx.BlockTime()) {
17-
util.Panic(keeper.ResetQuota(ctx))
17+
util.Panic(keeper.ResetAllQuotas(ctx))
1818
}
1919
}
2020

0 commit comments

Comments
 (0)