Skip to content

Commit

Permalink
go lint & protobuf lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewozniak committed Sep 30, 2024
1 parent 6ea5f0f commit c549b49
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 51 deletions.
29 changes: 14 additions & 15 deletions app/preblocker.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,22 @@ func (app *App) PreBlocker(ctx sdk.Context, req *cometabci.RequestFinalizeBlock)
if err := injectedVoteExtTx.Unmarshal(tx); err != nil {
app.Logger().Error("failed to decode injected vote extension tx", "err", err)
return nil, err
} else {
for _, exchangeRateVote := range injectedVoteExtTx.ExchangeRateVotes {
valAddr, err := sdk.ValAddressFromBech32(exchangeRateVote.Voter)
if err != nil {
app.Logger().Error("failed to get voter address", "err", err)
continue
}
app.OracleKeeper.SetAggregateExchangeRateVote(ctx, valAddr, exchangeRateVote)
}
for _, gasEstimate := range injectedVoteExtTx.GasEstimateMedians {
app.GasEstimateKeeper.SetGasEstimate(ctx, gasestimatetypes.GasEstimate{
Network: gasEstimate.Network,
GasEstimate: gasEstimate.GasEstimation,
})
}
for _, exchangeRateVote := range injectedVoteExtTx.ExchangeRateVotes {
valAddr, err := sdk.ValAddressFromBech32(exchangeRateVote.Voter)
if err != nil {
app.Logger().Error("failed to get voter address", "err", err)
continue
}
app.Logger().Info("gas estimates updated", "gasestimates", injectedVoteExtTx.GasEstimateMedians)
app.OracleKeeper.SetAggregateExchangeRateVote(ctx, valAddr, exchangeRateVote)
}
for _, gasEstimate := range injectedVoteExtTx.GasEstimateMedians {
app.GasEstimateKeeper.SetGasEstimate(ctx, gasestimatetypes.GasEstimate{
Network: gasEstimate.Network,
GasEstimate: gasEstimate.GasEstimation,
})
}
app.Logger().Info("gas estimates updated", "gasestimates", injectedVoteExtTx.GasEstimateMedians)
}
}

Expand Down
1 change: 0 additions & 1 deletion proto/ojo/gasestimate/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "gogoproto/gogo.proto";
import "ojo/gasestimate/v1/gasestimate.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/ojo-network/ojo/x/gasestimate/types";

Expand Down
1 change: 1 addition & 0 deletions proto/ojo/oracle/v1/abci.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ message InjectedVoteExtensionTx {
repeated GasEstimate gas_estimate_medians = 3 [(gogoproto.nullable) = false];
}

// GasEstimate defines a gas estimate for a given network.
message GasEstimate {
int64 gas_estimation = 1;
string network = 2;
Expand Down
4 changes: 3 additions & 1 deletion x/gasestimate/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ func GetCmdQueryGasEstimate() *cobra.Command {
Short: "Query the current gas-estimate for a network",
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.GasEstimate(cmd.Context(), &types.GasEstimateRequest{Network: args[0]})
return cli.PrintOrErr(res, err, clientCtx)
},
Expand Down
15 changes: 12 additions & 3 deletions x/gasestimate/types/expected_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
)


type IBCTransferKeeper interface {
Transfer(goCtx context.Context, msg *ibctransfertypes.MsgTransfer) (*ibctransfertypes.MsgTransferResponse, error)
}
Expand All @@ -19,6 +18,16 @@ type BankKeeper interface {
SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error
GetDenomMetaData(ctx context.Context, denom string) (banktypes.Metadata, bool)
SetDenomMetaData(ctx context.Context, denomMetaData banktypes.Metadata)
SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(
ctx context.Context,
senderAddr sdk.AccAddress,
recipientModule string,
amt sdk.Coins,
) error
SendCoinsFromModuleToAccount(
ctx context.Context,
senderModule string,
recipientAddr sdk.AccAddress,
amt sdk.Coins,
) error
}
46 changes: 22 additions & 24 deletions x/gasestimate/types/tx.pb.go

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

14 changes: 12 additions & 2 deletions x/gmp/types/expected_keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,18 @@ type BankKeeper interface {
SendCoinsFromModuleToModule(ctx context.Context, senderModule, recipientModule string, amt sdk.Coins) error
GetDenomMetaData(ctx context.Context, denom string) (banktypes.Metadata, bool)
SetDenomMetaData(ctx context.Context, denomMetaData banktypes.Metadata)
SendCoinsFromAccountToModule(ctx context.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
SendCoinsFromModuleToAccount(ctx context.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
SendCoinsFromAccountToModule(
ctx context.Context,
senderAddr sdk.AccAddress,
recipientModule string,
amt sdk.Coins,
) error
SendCoinsFromModuleToAccount(
ctx context.Context,
senderModule string,
recipientAddr sdk.AccAddress,
amt sdk.Coins,
) error
}

type GasEstimateKeeper interface {
Expand Down
3 changes: 3 additions & 0 deletions x/gmp/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,8 @@ func (p Params) Validate() error {
if p.FeeRecipient == "" {
return fmt.Errorf("fee recipient can not be empty")
}
if p.DefaultGasEstimate < 1 {
return fmt.Errorf("default gas estimate can not be less than 1")
}
return nil
}
5 changes: 4 additions & 1 deletion x/oracle/abci/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ func (h *ProposalHandler) ProcessProposalHandler() sdk.ProcessProposalHandler {
}
if !(oracleRateFound) {
h.logger.Error("failed to decode injected vote extension tx")
return &cometabci.ResponseProcessProposal{Status: cometabci.ResponseProcessProposal_REJECT}, fmt.Errorf("failed to decode injected vote extension tx")
return &cometabci.ResponseProcessProposal{
Status: cometabci.ResponseProcessProposal_REJECT,
},
fmt.Errorf("failed to decode injected vote extension tx")
}

var extendedCommitInfo cometabci.ExtendedCommitInfo
Expand Down
8 changes: 4 additions & 4 deletions x/oracle/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ type Keeper struct {
storeKey storetypes.StoreKey
paramSpace paramstypes.Subspace

accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
distrKeeper types.DistributionKeeper
StakingKeeper types.StakingKeeper
accountKeeper types.AccountKeeper
bankKeeper types.BankKeeper
distrKeeper types.DistributionKeeper
StakingKeeper types.StakingKeeper
GasEstimateKeeper types.GasEstimateKeeper

PriceFeeder *pricefeeder.PriceFeeder
Expand Down
1 change: 1 addition & 0 deletions x/oracle/types/abci.pb.go

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

0 comments on commit c549b49

Please sign in to comment.