Skip to content

Commit 47dc3bc

Browse files
author
Sahith Reddy Narahari
committed
Fixed proto issues
1 parent dbdd13b commit 47dc3bc

File tree

10 files changed

+263
-170
lines changed

10 files changed

+263
-170
lines changed

codec/std/codec.pb.go

+102-76
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codec/std/codec.proto

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ message Content {
100100
// FeeAllowance defines the application-level fee allowance to be used in
101101
// feegrant module
102102
message FeeAllowance {
103+
option (gogoproto.equal) = true;
103104
option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/x/feegrant/exported.FeeAllowance";
104105

105106
oneof sum{
@@ -111,7 +112,6 @@ message FeeAllowance {
111112
// MsgGrantFeeAllowance adds permission for Grantee to spend up to Allowance
112113
// of fees from the account of Granter.
113114
message MsgGrantFeeAllowance{
114-
option (gogoproto.equal) = true;
115115
option (gogoproto.goproto_getters) = false;
116116

117117
FeeAllowance Allowance = 1;
@@ -120,9 +120,9 @@ message MsgGrantFeeAllowance{
120120

121121
// FeeAllowanceGrant is stored in the KVStore to record a grant with full context
122122
message FeeAllowanceGrant{
123-
option (gogoproto.equal) = true;
124123
option (gogoproto.goproto_getters) = false;
125124

126125
FeeAllowance Allowance = 3;
127126
cosmos_sdk.x.feegrant.v1.FeeAllowanceGrantBase base = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
127+
128128
}

codec/std/msgs.go

+36-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package std
22

33
import (
4+
"time"
5+
46
sdk "github.com/cosmos/cosmos-sdk/types"
57
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
68
"github.com/cosmos/cosmos-sdk/x/evidence"
@@ -116,8 +118,30 @@ func (msg MsgGrantFeeAllowance) GetGranter() sdk.AccAddress {
116118
return msg.Granter
117119
}
118120

119-
func (grant FeeAllowanceGrant) ValidateBasic() error {
120-
return nil
121+
// PrepareForExport will make all needed changes to the allowance to prepare to be
122+
// re-imported at height 0, and return a copy of this grant.
123+
func (a MsgGrantFeeAllowance) PrepareForExport(dumpTime time.Time, dumpHeight int64) feeexported.FeeAllowanceGrant {
124+
err := a.GetFeeGrant().PrepareForExport(dumpTime, dumpHeight)
125+
if err != nil {
126+
//TODO handle this error
127+
}
128+
return a
129+
}
130+
131+
// ValidateBasic performs basic validation on
132+
// FeeAllowanceGrant
133+
func (a FeeAllowanceGrant) ValidateBasic() error {
134+
if a.Granter.Empty() {
135+
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing granter address")
136+
}
137+
if a.Grantee.Empty() {
138+
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "missing grantee address")
139+
}
140+
if a.Grantee.Equals(a.Granter) {
141+
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, "cannot self-grant fee authorization")
142+
}
143+
144+
return a.ValidateBasic()
121145
}
122146

123147
func (grant FeeAllowanceGrant) GetFeeGrant() feeexported.FeeAllowance {
@@ -131,3 +155,13 @@ func (grant FeeAllowanceGrant) GetGrantee() sdk.AccAddress {
131155
func (grant FeeAllowanceGrant) GetGranter() sdk.AccAddress {
132156
return grant.Granter
133157
}
158+
159+
// PrepareForExport will make all needed changes to the allowance to prepare to be
160+
// re-imported at height 0, and return a copy of this grant.
161+
func (a FeeAllowanceGrant) PrepareForExport(dumpTime time.Time, dumpHeight int64) feeexported.FeeAllowanceGrant {
162+
err := a.GetFeeGrant().PrepareForExport(dumpTime, dumpHeight)
163+
if err != nil {
164+
//TODO handle this error
165+
}
166+
return a
167+
}

x/feegrant/exported/external.go

+6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package exported
22

33
import (
4+
"time"
5+
46
sdk "github.com/cosmos/cosmos-sdk/types"
57
auth "github.com/cosmos/cosmos-sdk/x/auth/exported"
68
supply "github.com/cosmos/cosmos-sdk/x/supply/exported"
@@ -26,10 +28,14 @@ type MsgGrantFeeAllowance interface {
2628
GetFeeGrant() FeeAllowance
2729
GetGranter() sdk.AccAddress
2830
GetGrantee() sdk.AccAddress
31+
PrepareForExport(time.Time, int64) FeeAllowanceGrant
2932
}
3033

3134
type FeeAllowanceGrant interface {
3235
GetFeeGrant() FeeAllowance
3336
GetGranter() sdk.AccAddress
3437
GetGrantee() sdk.AccAddress
38+
39+
ValidateBasic() error
40+
PrepareForExport(time.Time, int64) FeeAllowanceGrant
3541
}

x/feegrant/genesis.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func ExportGenesis(ctx sdk.Context, k Keeper) (GenesisState, error) {
3838
var grants []exported.FeeAllowanceGrant
3939

4040
err := k.IterateAllFeeAllowances(ctx, func(grant exported.FeeAllowanceGrant) bool {
41-
grants = append(grants, grant.GetFeeGrant().PrepareForExport(time, height))
41+
grants = append(grants, grant.PrepareForExport(time, height))
4242
return false
4343
})
4444

0 commit comments

Comments
 (0)