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

chore: format once with gofumpt (backport #797) #800

Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (s *IntegrationTestSuite) SetupTest() {
}

// CreateTestTx is a helper function to create a tx given multiple inputs.
func (suite *IntegrationTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) {
func (suite *IntegrationTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) {
var sigsV2 []signing.SignatureV2
for i, priv := range privs {
sigV2 := signing.SignatureV2{
Expand Down
1 change: 0 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ func (app *UmeeApp) ExportAppStateAndValidators(
forZeroHeight bool,
jailAllowedAddrs []string,
) (servertypes.ExportedApp, error) {

// as if they could withdraw from the start of the next block
ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()})

Expand Down
1 change: 0 additions & 1 deletion app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ func (GenutilModule) ValidateGenesis(
encCfg client.TxEncodingConfig,
bz json.RawMessage,
) error {

var genState genutiltypes.GenesisState
if err := cdc.UnmarshalJSON(bz, &genState); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", genutiltypes.ModuleName, err)
Expand Down
2 changes: 0 additions & 2 deletions cmd/umeed/cmd/app_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func (ac appCreator) newApp(
traceStore io.Writer,
appOpts servertypes.AppOptions,
) servertypes.Application {

var cache sdk.MultiStorePersistentCache

if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
Expand Down Expand Up @@ -99,7 +98,6 @@ func (ac appCreator) appExport(
jailAllowedAddrs []string,
appOpts servertypes.AppOptions,
) (servertypes.ExportedApp, error) {

homePath, ok := appOpts.Get(flags.FlagHome).(string)
if !ok || homePath == "" {
return servertypes.ExportedApp{}, errors.New("application home is not set")
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (r *passReader) Read(p []byte) (n int, err error) {
// BroadcastTx attempts to broadcast a signed transaction. If it fails, a few re-attempts
// will be made until the transaction succeeds or ultimately times out or fails.
// Ref: https://github.com/terra-money/oracle-feeder/blob/baef2a4a02f57a2ffeaa207932b2e03d7fb0fb25/feeder/src/vote.ts#L230
func (oc OracleClient) BroadcastTx(nextBlockHeight int64, timeoutHeight int64, msgs ...sdk.Msg) error {
func (oc OracleClient) BroadcastTx(nextBlockHeight, timeoutHeight int64, msgs ...sdk.Msg) error {
maxBlockHeight := nextBlockHeight + timeoutHeight
lastCheckHeight := nextBlockHeight - 1

Expand Down
6 changes: 2 additions & 4 deletions price-feeder/oracle/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ import (
"github.com/umee-network/umee/price-feeder/oracle/provider"
)

var (
minimumTimeWeight = sdk.MustNewDecFromStr("0.2")
)
var minimumTimeWeight = sdk.MustNewDecFromStr("0.2")

const (
// tvwapCandlePeriod represents the time period we use for tvwap in minutes
tvwapCandlePeriod = 3 * time.Minute
)

// compute VWAP for each base by dividing the Σ {P * V} by Σ {V}
func vwap(weightedPrices map[string]sdk.Dec, volumeSum map[string]sdk.Dec) (map[string]sdk.Dec, error) {
func vwap(weightedPrices, volumeSum map[string]sdk.Dec) (map[string]sdk.Dec, error) {
vwap := make(map[string]sdk.Dec)

for base, p := range weightedPrices {
Expand Down
7 changes: 3 additions & 4 deletions tests/e2e/e2e_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ func (s *IntegrationTestSuite) runGanacheContainer() {
// Wait for Ganache to start running.
s.Require().Eventually(
func() bool {

err := s.dkrPool.Client.Logs(
docker.LogsOptions{
Container: s.ethResource.Container.ID,
Expand Down Expand Up @@ -585,7 +584,7 @@ func (s *IntegrationTestSuite) runGaiaNetwork() {
gaiaVal := s.chain.gaiaValidators[0]

gaiaCfgPath := path.Join(tmpDir, "cfg")
s.Require().NoError(os.MkdirAll(gaiaCfgPath, 0755))
s.Require().NoError(os.MkdirAll(gaiaCfgPath, 0o755))

_, err = copyFile(
filepath.Join("./scripts/", "gaia_bootstrap.sh"),
Expand Down Expand Up @@ -662,7 +661,7 @@ func (s *IntegrationTestSuite) runIBCRelayer() {
umeeVal := s.chain.validators[0]
hermesCfgPath := path.Join(tmpDir, "hermes")

s.Require().NoError(os.MkdirAll(hermesCfgPath, 0755))
s.Require().NoError(os.MkdirAll(hermesCfgPath, 0o755))
_, err = copyFile(
filepath.Join("./scripts/", "hermes_bootstrap.sh"),
filepath.Join(hermesCfgPath, "hermes_bootstrap.sh"),
Expand Down Expand Up @@ -922,7 +921,7 @@ func (s *IntegrationTestSuite) runPriceFeeder() {

priceFeederCfgPath := path.Join(tmpDir, "price-feeder")

s.Require().NoError(os.MkdirAll(priceFeederCfgPath, 0755))
s.Require().NoError(os.MkdirAll(priceFeederCfgPath, 0o755))
_, err = copyFile(
filepath.Join("./scripts/", "price_feeder_bootstrap.sh"),
filepath.Join(priceFeederCfgPath, "price_feeder_bootstrap.sh"),
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ func writeFile(path string, body []byte) error {
return err
}

return ioutil.WriteFile(path, body, 0600)
return ioutil.WriteFile(path, body, 0o600)
}
6 changes: 3 additions & 3 deletions tests/e2e/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (v *validator) configDir() string {

func (v *validator) createConfig() error {
p := path.Join(v.configDir(), "config")
return os.MkdirAll(p, 0755)
return os.MkdirAll(p, 0o755)
}

func (v *validator) init() error {
Expand Down Expand Up @@ -110,12 +110,12 @@ func (v *validator) createConsensusKey() error {
config.Moniker = v.moniker

pvKeyFile := config.PrivValidatorKeyFile()
if err := tmos.EnsureDir(filepath.Dir(pvKeyFile), 0777); err != nil {
if err := tmos.EnsureDir(filepath.Dir(pvKeyFile), 0o777); err != nil {
return err
}

pvStateFile := config.PrivValidatorStateFile()
if err := tmos.EnsureDir(filepath.Dir(pvStateFile), 0777); err != nil {
if err := tmos.EnsureDir(filepath.Dir(pvStateFile), 0o777); err != nil {
return err
}

Expand Down
1 change: 1 addition & 0 deletions tools/tools.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

// This file uses the recommended method for tracking developer tools in a Go
Expand Down
3 changes: 0 additions & 3 deletions x/ibctransfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (k Keeper) SendTransfer(
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
) error {

// first, relay the SendTransfer to the real (embedded) ICS-20 transfer keeper
if err := k.Keeper.SendTransfer(
ctx,
Expand Down Expand Up @@ -86,7 +85,6 @@ func (k Keeper) OnRecvPacket(
packet channeltypes.Packet,
data ibctransfertypes.FungibleTokenPacketData,
) error {

if err := k.Keeper.OnRecvPacket(ctx, packet, data); err != nil {
return err
}
Expand All @@ -105,7 +103,6 @@ func (k Keeper) PostOnRecvPacket(
packet channeltypes.Packet,
data ibctransfertypes.FungibleTokenPacketData,
) {

var denomTrace ibctransfertypes.DenomTrace

if ibctransfertypes.ReceiverChainIsSource(packet.GetSourcePort(), packet.GetSourceChannel(), data.Denom) {
Expand Down
1 change: 0 additions & 1 deletion x/ibctransfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ func (am AppModule) OnRecvPacket(
packet channeltypes.Packet,
relayer sdk.AccAddress,
) ibcexported.Acknowledgement {

ack := am.AppModule.OnRecvPacket(ctx, packet, relayer)
if ack.Success() {
var data ibctransfertypes.FungibleTokenPacketData
Expand Down
4 changes: 2 additions & 2 deletions x/leverage/client/cli/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestParseUpdateRegistryProposal(t *testing.T) {
bz := []byte(`
foo
`)
os.WriteFile(filePath, bz, 0644)
os.WriteFile(filePath, bz, 0o644)

_, err := cli.ParseUpdateRegistryProposal(encCfg.Marshaler, filePath)
require.Error(t, err)
Expand All @@ -44,7 +44,7 @@ func TestParseUpdateRegistryProposal(t *testing.T) {
}
]
}`)
os.WriteFile(filePath, bz, 0644)
os.WriteFile(filePath, bz, 0o644)

_, err = cli.ParseUpdateRegistryProposal(encCfg.Marshaler, filePath)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion x/leverage/client/tests/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (s *IntegrationTestSuite) UpdateRegistry(

bz, err := clientCtx.Codec.MarshalJSON(content)
s.Require().NoError(err)
s.Require().NoError(ioutil.WriteFile(path, bz, 0600))
s.Require().NoError(ioutil.WriteFile(path, bz, 0o600))

cmd := cli.NewCmdSubmitUpdateRegistryProposal()
flags.AddTxFlagsToCmd(cmd) // add flags manually since the gov workflow adds them automatically
Expand Down
6 changes: 0 additions & 6 deletions x/leverage/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ func ReserveAmountInvariant(k Keeper) sdk.Invariant {
}
return nil
})

if err != nil {
msg += fmt.Sprintf("\tSome error occurred while iterating through the reserve amount %+v\n", err)
}
Expand Down Expand Up @@ -134,7 +133,6 @@ func CollateralAmountInvariant(k Keeper) sdk.Invariant {
}
return nil
})

if err != nil {
msg += fmt.Sprintf("\tSome error occurred while iterating through the collateral amount %+v\n", err)
}
Expand Down Expand Up @@ -179,7 +177,6 @@ func BorrowAmountInvariant(k Keeper) sdk.Invariant {
}
return nil
})

if err != nil {
msg += fmt.Sprintf("\tSome error occurred while iterating through adjusted borrow amounts %+v\n", err)
}
Expand Down Expand Up @@ -216,7 +213,6 @@ func BorrowAPYInvariant(k Keeper) sdk.Invariant {
}
return nil
})

if err != nil {
msg += fmt.Sprintf("\tSome error occurred while iterating through the borrow APY %+v\n", err)
}
Expand Down Expand Up @@ -253,7 +249,6 @@ func LendAPYInvariant(k Keeper) sdk.Invariant {
}
return nil
})

if err != nil {
msg += fmt.Sprintf("\tSome error occurred while iterating through the lend APY %+v\n", err)
}
Expand Down Expand Up @@ -290,7 +285,6 @@ func InterestScalarsInvariant(k Keeper) sdk.Invariant {
}
return nil
})

if err != nil {
msg += fmt.Sprintf("\tSome error occurred while iterating through the interest scalars %+v\n", err)
}
Expand Down
3 changes: 1 addition & 2 deletions x/leverage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func NewKeeper(
bk types.BankKeeper,
ok types.OracleKeeper,
) Keeper {

// set KeyTable if it has not already been set
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
Expand Down Expand Up @@ -396,7 +395,7 @@ func (k Keeper) GetCollateralSetting(ctx sdk.Context, borrowerAddr sdk.AccAddres
// Because partial liquidation is possible and exchange rates vary, LiquidateBorrow returns the actual
// amount of tokens repaid and uTokens rewarded (in that order).
func (k Keeper) LiquidateBorrow(
ctx sdk.Context, liquidatorAddr, borrowerAddr sdk.AccAddress, desiredRepayment sdk.Coin, desiredReward sdk.Coin,
ctx sdk.Context, liquidatorAddr, borrowerAddr sdk.AccAddress, desiredRepayment, desiredReward sdk.Coin,
) (sdk.Int, sdk.Int, error) {
if !desiredRepayment.IsValid() {
return sdk.ZeroInt(), sdk.ZeroInt(), sdkerrors.Wrap(types.ErrInvalidAsset, desiredRepayment.String())
Expand Down
1 change: 0 additions & 1 deletion x/leverage/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,6 @@ func (s *IntegrationTestSuite) TestRepayAsset_Valid() {
// verify lender's uToken collateral remains at 1000 u/umee from initial conditions
collateralBalance = s.app.LeverageKeeper.GetCollateralAmount(s.ctx, lenderAddr, "u/"+umeeapp.BondDenom)
s.Require().Equal(collateralBalance, sdk.NewInt64Coin("u/"+umeeapp.BondDenom, 1000000000))

}

func (s *IntegrationTestSuite) TestRepayAsset_Overpay() {
Expand Down
6 changes: 0 additions & 6 deletions x/leverage/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func (s msgServer) LendAsset(
goCtx context.Context,
msg *types.MsgLendAsset,
) (*types.MsgLendAssetResponse, error) {

ctx := sdk.UnwrapSDKContext(goCtx)

lenderAddr, err := sdk.AccAddressFromBech32(msg.Lender)
Expand Down Expand Up @@ -63,7 +62,6 @@ func (s msgServer) WithdrawAsset(
goCtx context.Context,
msg *types.MsgWithdrawAsset,
) (*types.MsgWithdrawAssetResponse, error) {

ctx := sdk.UnwrapSDKContext(goCtx)

lenderAddr, err := sdk.AccAddressFromBech32(msg.Lender)
Expand Down Expand Up @@ -101,7 +99,6 @@ func (s msgServer) SetCollateral(
goCtx context.Context,
msg *types.MsgSetCollateral,
) (*types.MsgSetCollateralResponse, error) {

ctx := sdk.UnwrapSDKContext(goCtx)

borrowerAddr, err := sdk.AccAddressFromBech32(msg.Borrower)
Expand Down Expand Up @@ -141,7 +138,6 @@ func (s msgServer) BorrowAsset(
goCtx context.Context,
msg *types.MsgBorrowAsset,
) (*types.MsgBorrowAssetResponse, error) {

ctx := sdk.UnwrapSDKContext(goCtx)

borrowerAddr, err := sdk.AccAddressFromBech32(msg.Borrower)
Expand Down Expand Up @@ -179,7 +175,6 @@ func (s msgServer) RepayAsset(
goCtx context.Context,
msg *types.MsgRepayAsset,
) (*types.MsgRepayAssetResponse, error) {

ctx := sdk.UnwrapSDKContext(goCtx)

borrowerAddr, err := sdk.AccAddressFromBech32(msg.Borrower)
Expand Down Expand Up @@ -224,7 +219,6 @@ func (s msgServer) Liquidate(
goCtx context.Context,
msg *types.MsgLiquidate,
) (*types.MsgLiquidateResponse, error) {

ctx := sdk.UnwrapSDKContext(goCtx)

liquidatorAddr, err := sdk.AccAddressFromBech32(msg.Liquidator)
Expand Down
1 change: 0 additions & 1 deletion x/leverage/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func (AppModuleBasic) ValidateGenesis(
config client.TxEncodingConfig,
bz json.RawMessage,
) error {

var genState types.GenesisState
if err := cdc.UnmarshalJSON(bz, &genState); err != nil {
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
Expand Down
6 changes: 3 additions & 3 deletions x/leverage/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ const (

// GenCompleteLiquidationThreshold produces a randomized CompleteLiquidationThreshold in the range of [0.050, 0.100]
func GenCompleteLiquidationThreshold(r *rand.Rand) sdk.Dec {
return sdk.NewDecWithPrec(050, 3).Add(sdk.NewDecWithPrec(int64(r.Intn(950)), 3))
return sdk.NewDecWithPrec(50, 3).Add(sdk.NewDecWithPrec(int64(r.Intn(950)), 3))
}

// GenMinimumCloseFactor produces a randomized MinimumCloseFactor in the range of [0.001, 0.047]
func GenMinimumCloseFactor(r *rand.Rand) sdk.Dec {
return sdk.NewDecWithPrec(001, 3).Add(sdk.NewDecWithPrec(int64(r.Intn(046)), 3))
return sdk.NewDecWithPrec(1, 3).Add(sdk.NewDecWithPrec(int64(r.Intn(46)), 3))
}

// GenOracleRewardFactor produces a randomized OracleRewardFactor in the range of [0.005, 0.100]
func GenOracleRewardFactor(r *rand.Rand) sdk.Dec {
return sdk.NewDecWithPrec(005, 3).Add(sdk.NewDecWithPrec(int64(r.Intn(995)), 3))
return sdk.NewDecWithPrec(5, 3).Add(sdk.NewDecWithPrec(int64(r.Intn(995)), 3))
}

// GenSmallLiquidationSize produces a randomized SmallLiquidationSize in the range of [0, 1000]
Expand Down
1 change: 0 additions & 1 deletion x/leverage/simulation/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func WeightedOperations(
appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk types.BankKeeper,
lk keeper.Keeper,
) simulation.WeightedOperations {

var (
weightMsgLend int
weightMsgWithdraw int
Expand Down
2 changes: 1 addition & 1 deletion x/leverage/types/expected_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type BankKeeper interface {
SendCoinsFromModuleToModule(
ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins,
) error
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error
SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin
GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
Expand Down
6 changes: 3 additions & 3 deletions x/leverage/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,20 @@ func CreateUTokenSupplyKey(uTokenDenom string) []byte {

// AddressFromKey extracts address from a key with the form
// prefix | lengthPrefixed(addr) | ...
func AddressFromKey(key []byte, prefix []byte) sdk.AccAddress {
func AddressFromKey(key, prefix []byte) sdk.AccAddress {
addrLength := int(key[len(prefix)])
return key[len(prefix)+1 : len(prefix)+1+addrLength]
}

// DenomFromKeyWithAddress extracts denom from a key with the form
// prefix | lengthPrefixed(addr) | denom | 0x00
func DenomFromKeyWithAddress(key []byte, prefix []byte) string {
func DenomFromKeyWithAddress(key, prefix []byte) string {
addrLength := int(key[len(prefix)])
return string(key[len(prefix)+addrLength+1 : len(key)-1])
}

// DenomFromKey extracts denom from a key with the form
// prefix | denom | 0x00
func DenomFromKey(key []byte, prefix []byte) string {
func DenomFromKey(key, prefix []byte) string {
return string(key[len(prefix) : len(key)-1])
}
2 changes: 1 addition & 1 deletion x/leverage/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (msg *MsgRepayAsset) GetSignBytes() []byte {
return sdk.MustSortJSON(bz)
}

func NewMsgLiquidate(liquidator, borrower sdk.AccAddress, repayment sdk.Coin, reward sdk.Coin) *MsgLiquidate {
func NewMsgLiquidate(liquidator, borrower sdk.AccAddress, repayment, reward sdk.Coin) *MsgLiquidate {
return &MsgLiquidate{
Liquidator: borrower.String(),
Borrower: borrower.String(),
Expand Down
Loading