Skip to content

Commit

Permalink
chore: run make format (#5103)
Browse files Browse the repository at this point in the history
* this pr only runs make format

* run make format

* correct comment for PoolsKey

* restore grpc_query.go to same style as found in main

* correct changelog formatting

---------

Co-authored-by: Ruslan Akhtariev <[email protected]>
  • Loading branch information
faddat and pysel authored May 8, 2023
1 parent 1afdd6a commit 7cc0090
Show file tree
Hide file tree
Showing 89 changed files with 213 additions and 236 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Misc Improvements

* [#5103](https://github.com/osmosis-labs/osmosis/pull/5103) Run `make format`
* [#5105](https://github.com/osmosis-labs/osmosis/pull/5105) Lint stableswap in the same manner as all of Osmosis
* [#5065](https://github.com/osmosis-labs/osmosis/pull/5065) Use cosmossdk.io/errors
* [#4549](https://github.com/osmosis-labs/osmosis/pull/4549) Add single pool price estimate queries
Expand Down
15 changes: 8 additions & 7 deletions app/upgrades/v13/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package v13_test

import (
"fmt"
ibchookstypes "github.com/osmosis-labs/osmosis/x/ibc-hooks/types"
"testing"

ibchookstypes "github.com/osmosis-labs/osmosis/x/ibc-hooks/types"

ibcratelimittypes "github.com/osmosis-labs/osmosis/v15/x/ibc-rate-limit/types"

"github.com/cosmos/cosmos-sdk/store/prefix"
Expand Down Expand Up @@ -55,8 +56,8 @@ func (suite *UpgradeTestSuite) TestUpgrade() {
"Test that the upgrade succeeds",
func() {
// The module doesn't need an account anymore, but when the upgrade happened we did:
//acc := suite.App.AccountKeeper.GetAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr)
//suite.App.AccountKeeper.RemoveAccount(suite.Ctx, acc)
// acc := suite.App.AccountKeeper.GetAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr)
// suite.App.AccountKeeper.RemoveAccount(suite.Ctx, acc)

// Because of SDK version map bug, we can't do the following, and instaed do a massive hack
// vm := suite.App.UpgradeKeeper.GetModuleVersionMap(suite.Ctx)
Expand All @@ -70,15 +71,15 @@ func (suite *UpgradeTestSuite) TestUpgrade() {
versionStore.Delete([]byte(ibchookstypes.ModuleName))

// Same comment as above: this was the case when the upgrade happened, but we don't have accounts anymore
//hasAcc := suite.App.AccountKeeper.HasAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr)
//suite.Require().False(hasAcc)
// hasAcc := suite.App.AccountKeeper.HasAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr)
// suite.Require().False(hasAcc)

},
func() { dummyUpgrade(suite) },
func() {
// Same comment as pre-upgrade. We had an account, but now we don't anymore
//hasAcc := suite.App.AccountKeeper.HasAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr)
//suite.Require().True(hasAcc)
// hasAcc := suite.App.AccountKeeper.HasAccount(suite.Ctx, ibc_hooks.WasmHookModuleAccountAddr)
// suite.Require().True(hasAcc)
},
},
{
Expand Down
8 changes: 5 additions & 3 deletions app/upgrades/v15/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import (
const UpgradeName = "v15"

// pool ids to migrate
const stOSMO_OSMOPoolId = 833
const stJUNO_JUNOPoolId = 817
const stSTARS_STARSPoolId = 810
const (
stOSMO_OSMOPoolId = 833
stJUNO_JUNOPoolId = 817
stSTARS_STARSPoolId = 810
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
Expand Down
5 changes: 1 addition & 4 deletions app/upgrades/v15/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ func (suite *UpgradeTestSuite) TestMigrateNextPoolIdAndCreatePool() {
expectedNextPoolId uint64 = 1
)

var (
gammKeeperType = reflect.TypeOf(&gamm.Keeper{})
)
gammKeeperType := reflect.TypeOf(&gamm.Keeper{})

ctx := suite.Ctx
gammKeeper := suite.App.GAMMKeeper
Expand Down Expand Up @@ -249,7 +247,6 @@ func (suite *UpgradeTestSuite) TestSetRateLimits() {
// This is the last one. If the others failed the upgrade would've panicked before adding this one
state, err = suite.App.WasmKeeper.QuerySmart(suite.Ctx, addr, []byte(`{"get_quotas": {"channel_id": "any", "denom": "ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1"}}`))
suite.Require().Greaterf(len(state), 0, "state should not be empty")

}

func (suite *UpgradeTestSuite) validateCons(coinsA, coinsB sdk.Coins) {
Expand Down
9 changes: 3 additions & 6 deletions tests/cl-genesis-positions/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ type OsmosisApp struct {
TestAccs []sdk.AccAddress
}

var (
osmosisPrecision = 6
)
var osmosisPrecision = 6

func ReadSubgraphDataFromDisk(subgraphFilePath string) []SubgraphPosition {
// read in the data from file
Expand Down Expand Up @@ -193,7 +191,6 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress,
TokenMinAmount0: sdk.ZeroInt(),
TokenMinAmount1: sdk.ZeroInt(),
})

if err != nil {
fmt.Printf("\n\n\nWARNING: Failed to create position: %v\n\n\n", err)
fmt.Printf("attempted creation between ticks (%s) and (%s), desired amount 0: (%s), desired amount 1 (%s)\n", lowerTickOsmosis, upperTickOsmosis, depositedAmount0, depositedAmount1)
Expand Down Expand Up @@ -273,7 +270,7 @@ func writeStateToDisk(state map[string]json.RawMessage) {
panic(err)
}

err = os.WriteFile(pathToFilesFromRoot+osmosisGenesisFileName, stateBz, 0644)
err = os.WriteFile(pathToFilesFromRoot+osmosisGenesisFileName, stateBz, 0o644)
if err != nil {
panic(err)
}
Expand All @@ -287,7 +284,7 @@ func writeBigBangPositionsToState(positions []BigBangPosition) {
if err != nil {
panic(err)
}
err = os.WriteFile(pathToFilesFromRoot+bigbangPosiionsFileName, positionsBytes, 0644)
err = os.WriteFile(pathToFilesFromRoot+bigbangPosiionsFileName, positionsBytes, 0o644)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/cl-genesis-positions/get_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func GetUniV3SubgraphData(pathToSaveAt string) {
return
}

if err := os.WriteFile(pathToSaveAt, jsonData, 0644); err != nil {
if err := os.WriteFile(pathToSaveAt, jsonData, 0o644); err != nil {
fmt.Println("Error writing JSON file:", err)
return
}
Expand Down
7 changes: 3 additions & 4 deletions tests/cl-genesis-positions/local_accounts.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package main

import (
"context"
"fmt"
"log"
"os/user"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ignite/cli/ignite/pkg/cosmosaccount"
"github.com/ignite/cli/ignite/pkg/cosmosclient"

"context"
"fmt"
"log"
)

const (
Expand Down
1 change: 0 additions & 1 deletion tests/cl-go-client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ func createPosition(client cosmosclient.Client, poolId uint64, senderKeyringAcco
TokenMinAmount1: tokenMinAmount1,
}
txResp, err := client.BroadcastTx(senderKeyringAccountName, msg)

if err != nil {
log.Fatal(err)
}
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/configurer/chain/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ func (n *NodeConfig) QueryConcentratedPositions(address string) []model.Position
require.NoError(n.t, err)
return positionsResponse.Positions
}

func (n *NodeConfig) QueryConcentratedPool(poolId uint64) (cltypes.ConcentratedPoolExtension, error) {
path := fmt.Sprintf("/osmosis/poolmanager/v1beta1/pools/%d", poolId)
bz, err := n.QueryGRPCGateway(path)
Expand Down
16 changes: 5 additions & 11 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,8 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() {

// Withdraw Position

var (
// Withdraw Position parameters
defaultLiquidityRemoval string = "1000"
)
// Withdraw Position parameters
var defaultLiquidityRemoval string = "1000"

chainA.WaitForNumHeights(2)

Expand Down Expand Up @@ -977,7 +975,7 @@ func (s *IntegrationTestSuite) TestIBCTokenTransferRateLimiting() {

// Removing the rate limit so it doesn't affect other tests
node.WasmExecute(contract, `{"remove_path": {"channel_id": "channel-0", "denom": "uosmo"}}`, initialization.ValidatorWalletName)
//reset the param to the original contract if it existed
// reset the param to the original contract if it existed
if param != "" {
err = chainA.SubmitParamChangeProposal(
ibcratelimittypes.ModuleName,
Expand All @@ -991,7 +989,6 @@ func (s *IntegrationTestSuite) TestIBCTokenTransferRateLimiting() {
}, time.Second*30, time.Millisecond*500)

}

}

func (s *IntegrationTestSuite) TestLargeWasmUpload() {
Expand Down Expand Up @@ -1161,7 +1158,6 @@ func (s *IntegrationTestSuite) TestAddToExistingLock() {
// because twap keep time = epoch time / 4 and we use a timer
// to wait for at least the twap keep time.
func (s *IntegrationTestSuite) TestArithmeticTWAP() {

s.T().Skip("TODO: investigate further: https://github.com/osmosis-labs/osmosis/issues/4342")

const (
Expand Down Expand Up @@ -1559,10 +1555,8 @@ func (s *IntegrationTestSuite) TestAConcentratedLiquidity_CanonicalPool_And_Para
s.T().Skip("Skipping v16 canonical pool creation test because upgrade is not enabled")
}

var (
// Taken from: https://app.osmosis.zone/pool/674
expectedFee = sdk.MustNewDecFromStr("0.002")
)
// Taken from: https://app.osmosis.zone/pool/674
expectedFee := sdk.MustNewDecFromStr("0.002")

chainA := s.configurer.GetChainConfig(0)
chainANode, err := chainA.GetDefaultNode()
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/initialization/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func updateTWAPGenesis(appGenState map[string]json.RawMessage) func(twapGenState
Asset0Denom: denomPair.Denom0,
Asset1Denom: denomPair.Denom0,
Height: 1,
Time: time.Date(2023, 02, 1, 0, 0, 0, 0, time.UTC), // some time in the past.
Time: time.Date(2023, 0o2, 1, 0, 0, 0, 0, time.UTC), // some time in the past.
P0LastSpotPrice: sp0,
P1LastSpotPrice: sp1,
P0ArithmeticTwapAccumulator: sdk.ZeroDec(),
Expand Down
14 changes: 4 additions & 10 deletions tests/ibc-hooks/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package ibc_hooks_test
import (
"encoding/json"
"fmt"
"github.com/tidwall/gjson"
"strings"
"testing"
"time"

"github.com/tidwall/gjson"

"github.com/CosmWasm/wasmd/x/wasm/types"

ibchookskeeper "github.com/osmosis-labs/osmosis/x/ibc-hooks/keeper"
Expand Down Expand Up @@ -608,7 +609,6 @@ func (suite *HooksTestSuite) TestAcks() {
&suite.Suite, addr,
[]byte(fmt.Sprintf(`{"get_count": {"addr": "%s"}}`, addr)))
suite.Require().Equal(`{"count":2}`, state)

}

func (suite *HooksTestSuite) TestTimeouts() {
Expand Down Expand Up @@ -641,7 +641,6 @@ func (suite *HooksTestSuite) TestTimeouts() {
&suite.Suite, addr,
[]byte(fmt.Sprintf(`{"get_count": {"addr": "%s"}}`, addr)))
suite.Require().Equal(`{"count":10}`, state)

}

func (suite *HooksTestSuite) TestSendWithoutMemo() {
Expand Down Expand Up @@ -1200,7 +1199,6 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCBadAck() {
// Calling recovery again should fail
_, err = contractKeeper.Execute(suite.chainA.GetContext(), crosschainAddr, recoverAddr2, []byte(recoverMsg), sdk.NewCoins())
suite.Require().Error(err)

}

// CrosschainSwapsViaIBCBadSwap tests that if the crosschain-swap fails, the tokens are returned to the sender
Expand Down Expand Up @@ -1363,7 +1361,6 @@ func (suite *HooksTestSuite) SetupIBCRouteOnChain(swaprouterAddr, owner sdk.AccA
suite.Require().NoError(err)
err = suite.pathAB.EndpointB.UpdateClient()
suite.Require().NoError(err)

}

func (suite *HooksTestSuite) SetupIBCSimpleRouteOnChain(swaprouterAddr, owner sdk.AccAddress, poolId uint64, chainName Chain, denom1, denom2 string) {
Expand All @@ -1390,7 +1387,6 @@ func (suite *HooksTestSuite) SetupIBCSimpleRouteOnChain(swaprouterAddr, owner sd
suite.Require().NoError(err)
err = suite.pathAB.EndpointB.UpdateClient()
suite.Require().NoError(err)

}

// TestCrosschainForwardWithMemo tests the that the next_memo field is correctly forwarded to the other chain on the IBC transfer.
Expand Down Expand Up @@ -1418,7 +1414,7 @@ func (suite *HooksTestSuite) TestCrosschainForwardWithMemo() {
fmt.Println("receiver now has: ", balanceToken0IBCBefore)
suite.Require().Equal(int64(0), balanceToken0IBCBefore.Amount.Int64())

//suite.Require().Equal(int64(0), balanceToken1.Amount.Int64())
// suite.Require().Equal(int64(0), balanceToken1.Amount.Int64())

// Generate swap instructions for the contract
//
Expand Down Expand Up @@ -1788,9 +1784,7 @@ func (suite *HooksTestSuite) TestMultiHopXCS() {

receivedTokenAfter := receiverChain.GetOsmosisApp().BankKeeper.GetBalance(receiverChain.GetContext(), tc.receiver.address, tc.receivedToken)
suite.Require().True(receivedTokenAfter.Amount.GT(receivedTokenBalance.Amount))

})

}
}

Expand Down Expand Up @@ -1853,7 +1847,7 @@ func (suite *HooksTestSuite) ExecuteOutpostSwap(initializer, receiverAddr sdk.Ac

// But the receiver now has some token1IBC
balanceToken1After := osmosisAppB.BankKeeper.GetBalance(suite.chainB.GetContext(), receiverAddr, token1IBC)
//fmt.Println("receiver now has: ", balanceToken1After)
// fmt.Println("receiver now has: ", balanceToken1After)
suite.Require().Greater(balanceToken1After.Amount.Int64(), int64(0))
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ibc-hooks/xcs_cw20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"

wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
Expand Down Expand Up @@ -175,5 +176,4 @@ func (suite *HooksTestSuite) TestCW20ICS20() {
// Check that the receiver has more cw20 tokens than before
newCw20Balance := suite.getCW20Balance(chainB, cw20Addr, receiver2)
suite.Require().Greater(newCw20Balance.Int64(), cw20Balance.Int64())

}
12 changes: 8 additions & 4 deletions x/concentrated-liquidity/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func GetUserPositions() (*osmocli.QueryDescriptor, *queryproto.UserPositionsRequ
Long: `{{.Short}}{{.ExampleHeader}}
{{.CommandPrefix}} user-positions osmo12smx2wdlyttvyzvzg54y2vnqwq2qjateuf7thj`,
Flags: osmocli.FlagDesc{OptionalFlags: []*flag.FlagSet{FlagSetJustPoolId()}},
CustomFlagOverrides: poolIdFlagOverride},
CustomFlagOverrides: poolIdFlagOverride,
},
&queryproto.UserPositionsRequest{}
}

Expand All @@ -39,21 +40,24 @@ func GetCmdPools() (*osmocli.QueryDescriptor, *queryproto.PoolsRequest) {
Use: "pools",
Short: "Query pools",
Long: `{{.Short}}{{.ExampleHeader}}
{{.CommandPrefix}} pools`}, &queryproto.PoolsRequest{}
{{.CommandPrefix}} pools`,
}, &queryproto.PoolsRequest{}
}

func GetClaimableFees() (*osmocli.QueryDescriptor, *queryproto.ClaimableFeesRequest) {
return &osmocli.QueryDescriptor{
Use: "claimable-fees [positionID]",
Short: "Query claimable fees",
Long: `{{.Short}}{{.ExampleHeader}}
{{.CommandPrefix}} claimable-fees 53`}, &queryproto.ClaimableFeesRequest{}
{{.CommandPrefix}} claimable-fees 53`,
}, &queryproto.ClaimableFeesRequest{}
}

func GetClaimableIncentives() (*osmocli.QueryDescriptor, *queryproto.ClaimableIncentivesRequest) {
return &osmocli.QueryDescriptor{
Use: "claimable-incentives [positionID]",
Short: "Query claimable incentives",
Long: `{{.Short}}{{.ExampleHeader}}
{{.CommandPrefix}} claimable-fees 53`}, &queryproto.ClaimableIncentivesRequest{}
{{.CommandPrefix}} claimable-fees 53`,
}, &queryproto.ClaimableIncentivesRequest{}
}
1 change: 1 addition & 0 deletions x/concentrated-liquidity/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ func parseCreateConcentratedLiquidityPoolArgsToContent(cmd *cobra.Command, denom

return content, nil
}

func parsePoolIdToTickSpacingRecordsArgsToContent(cmd *cobra.Command) (govtypes.Content, error) {
title, err := cmd.Flags().GetString(govcli.FlagTitle)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion x/concentrated-liquidity/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ func (s *KeeperTestSuite) validateListenerCallCount(
expectedPoolCreatedListenerCallCount,
expectedInitialPositionCreationListenerCallCount,
expectedLastPositionWithdrawalListenerCallCount,
expectedSwapListenerCallCount int) {
expectedSwapListenerCallCount int,
) {
// Validate that listeners were called the desired number of times
listeners := s.App.ConcentratedLiquidityKeeper.GetListenersUnsafe()
s.Require().Len(listeners, 1)
Expand Down
Loading

0 comments on commit 7cc0090

Please sign in to comment.