Skip to content

Commit

Permalink
feat: extend UCDAO cli commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kioqq committed Oct 22, 2024
1 parent dfda1a3 commit e014c7e
Show file tree
Hide file tree
Showing 21 changed files with 196 additions and 93 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ lint-fix-contracts:

format:
find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./.direnv/*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs codespell -w
# find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./.direnv/*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs codespell -w
find . -name '*.go' -type f -not -path "./.devenv/*" -not -path "./vendor*" -not -path "*.git*" -not -path "./.direnv/*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' | xargs goimports -w -local github.com/haqq-network/haqq

.PHONY: format
Expand Down
2 changes: 1 addition & 1 deletion app/ante/evm/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (egcd EthGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula
if ctx.IsReCheckTx() {
// Use new context with gasWanted = 0
// Otherwise, there's an error on txmempool.postCheck (tendermint)
// that is not bubbled up. Thus, the Tx never runs on DeliverMode
// that is not bubbled up. Thus, the Tx never runs on deliverymode
// Error: "gas wanted -1 is negative"
// For more information, see issue #1554
// https://github.com/evmos/ethermint/issues/1554
Expand Down
2 changes: 1 addition & 1 deletion app/ante/evm/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ func (suite *AnteTestSuite) CreateTestSingleSignedTx(privKey cryptotypes.PrivKey
return txBuilder
}

// prepareAccount is a helper function that asigns the corresponding
// prepareAccount is a helper function that assigns the corresponding
// balance and rewards to the provided account
func (suite *AnteTestSuite) prepareAccount(ctx sdk.Context, addr sdk.AccAddress, balance, rewards math.Int) sdk.Context {
ctx, err := testutil.PrepareAccountsForDelegationRewards(
Expand Down
2 changes: 1 addition & 1 deletion client/block/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Cmd() *cobra.Command {

store, err := newStore(home, server.GetAppDBBackend(serverCtx.Viper))
if err != nil {
return fmt.Errorf("error while openning db: %w", err)
return fmt.Errorf("error while opening db: %w", err)
}

state, err := store.state()
Expand Down
6 changes: 3 additions & 3 deletions precompiles/ics20/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ var _ = Describe("Calling ICS20 precompile from another contract", func() {
// finalBalance := s.app.BankKeeper.GetBalance(s.chainA.GetContext(), s.address.Bytes(), s.bondDenom)
// Expect(finalBalance.Amount).To(Equal(initialBalance.Amount.Sub(fees)))

// check IBC coins balance remains unchaged
// check IBC coins balance remains unchanged
finalOsmoBalance := s.app.BankKeeper.GetBalance(s.chainA.GetContext(), s.address.Bytes(), ibcDenom)
Expect(finalOsmoBalance.Amount).To(Equal(initialOsmoBalance.Amount))
})
Expand Down Expand Up @@ -1407,7 +1407,7 @@ var _ = Describe("Calling ICS20 precompile from another contract", func() {
// finalBalance := s.app.BankKeeper.GetBalance(s.chainA.GetContext(), s.address.Bytes(), s.bondDenom)
// Expect(finalBalance.Amount).To(Equal(initialBalance.Amount.Sub(fees)))

// check Erc20 balance remained unchaged by sent amount
// check Erc20 balance remained unchanged by sent amount
balance := s.app.Erc20Keeper.BalanceOf(
s.chainA.GetContext(),
haqqcontracts.ERC20MinterBurnerDecimalsContract.ABI,
Expand Down Expand Up @@ -1492,7 +1492,7 @@ var _ = Describe("Calling ICS20 precompile from another contract", func() {
})
})

Context("tranfer a contract's funds", func() {
Context("transfer a contract's funds", func() {
var defaultTransferArgs contracts.CallArgs

BeforeEach(func() {
Expand Down
2 changes: 1 addition & 1 deletion precompiles/ics20/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ func (s *PrecompileTestSuite) setupERC20ContractTests(amount *big.Int) common.Ad
}

// makePacket is a helper function to build the sent IBC packet
// to perform an ICS20 tranfer.
// to perform an ICS20 transfer.
// This packet is then used to test the IBC callbacks (Timeout, Ack)
func (s *PrecompileTestSuite) makePacket(
senderAddr,
Expand Down
4 changes: 2 additions & 2 deletions rpc/backend/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ func TestRegisterBlockResults(t *testing.T) {
require.NoError(t, err)

res, err := client.BlockResults(rpc.ContextWithHeight(height), &height)
expRes := &tmrpctypes.ResultBlockResults{
expResult := &tmrpctypes.ResultBlockResults{
Height: height,
TxsResults: []*abci.ResponseDeliverTx{{Code: 0, GasUsed: 0}},
}
require.Equal(t, expRes, res)
require.Equal(t, expResult, res)
require.NoError(t, err)
}

Expand Down
2 changes: 1 addition & 1 deletion testutil/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func CommitAndCreateNewCtx(ctx sdk.Context, app *app.Haqq, t time.Duration, vs *
// but resets other context fields
// GasMeter is set as InfiniteGasMeter
newCtx := app.BaseApp.NewContext(false, header)
// set the reseted fields to keep the current ctx settings
// reset fields to keep the current ctx settings
newCtx = newCtx.WithMinGasPrices(ctx.MinGasPrices())
newCtx = newCtx.WithEventManager(ctx.EventManager())
newCtx = newCtx.WithKVGasConfig(ctx.KVGasConfig())
Expand Down
2 changes: 1 addition & 1 deletion testutil/integration/haqq/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (n *IntegrationNetwork) configureAndInitChain() error {

// Set networks global parameters
n.app = haqqApp
// TODO - this might not be the best way to initilize the context
// TODO - this might not be the best way to initialize the context
n.ctx = haqqApp.BaseApp.NewContext(false, header)
n.validators = validators
n.valSet = valSet
Expand Down
22 changes: 11 additions & 11 deletions x/epochs/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

func (suite *KeeperTestSuite) TestEpochInfo() {
var (
req *types.QueryEpochsInfoRequest
expRes *types.QueryEpochsInfoResponse
req *types.QueryEpochsInfoRequest
expResult *types.QueryEpochsInfoResponse
)

testCases := []struct {
Expand Down Expand Up @@ -50,7 +50,7 @@ func (suite *KeeperTestSuite) TestEpochInfo() {
week.StartTime = suite.ctx.BlockTime()
week.CurrentEpochStartHeight = suite.ctx.BlockHeight()

expRes = &types.QueryEpochsInfoResponse{
expResult = &types.QueryEpochsInfoResponse{
Epochs: []types.EpochInfo{day, week},
Pagination: &query.PageResponse{
NextKey: nil,
Expand Down Expand Up @@ -102,7 +102,7 @@ func (suite *KeeperTestSuite) TestEpochInfo() {
suite.Commit()

req = &types.QueryEpochsInfoRequest{}
expRes = &types.QueryEpochsInfoResponse{
expResult = &types.QueryEpochsInfoResponse{
Epochs: []types.EpochInfo{day, quarter, week},
Pagination: &query.PageResponse{
NextKey: nil,
Expand All @@ -123,7 +123,7 @@ func (suite *KeeperTestSuite) TestEpochInfo() {
res, err := suite.queryClient.EpochInfos(ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().Equal(expRes, res)
suite.Require().Equal(expResult, res)
} else {
suite.Require().Error(err)
}
Expand All @@ -133,8 +133,8 @@ func (suite *KeeperTestSuite) TestEpochInfo() {

func (suite *KeeperTestSuite) TestCurrentEpoch() {
var (
req *types.QueryCurrentEpochRequest
expRes *types.QueryCurrentEpochResponse
req *types.QueryCurrentEpochRequest
expResult *types.QueryCurrentEpochResponse
)

testCases := []struct {
Expand All @@ -147,7 +147,7 @@ func (suite *KeeperTestSuite) TestCurrentEpoch() {
func() {
defaultCurrentEpoch := int64(0)
req = &types.QueryCurrentEpochRequest{Identifier: "second"}
expRes = &types.QueryCurrentEpochResponse{
expResult = &types.QueryCurrentEpochResponse{
CurrentEpoch: defaultCurrentEpoch,
}
},
Expand All @@ -158,7 +158,7 @@ func (suite *KeeperTestSuite) TestCurrentEpoch() {
func() {
defaultCurrentEpoch := int64(0)
req = &types.QueryCurrentEpochRequest{Identifier: types.WeekEpochID}
expRes = &types.QueryCurrentEpochResponse{
expResult = &types.QueryCurrentEpochResponse{
CurrentEpoch: defaultCurrentEpoch,
}
},
Expand All @@ -169,7 +169,7 @@ func (suite *KeeperTestSuite) TestCurrentEpoch() {
func() {
defaultCurrentEpoch := int64(0)
req = &types.QueryCurrentEpochRequest{Identifier: types.DayEpochID}
expRes = &types.QueryCurrentEpochResponse{
expResult = &types.QueryCurrentEpochResponse{
CurrentEpoch: defaultCurrentEpoch,
}
},
Expand All @@ -186,7 +186,7 @@ func (suite *KeeperTestSuite) TestCurrentEpoch() {
res, err := suite.queryClient.CurrentEpoch(ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().Equal(expRes, res)
suite.Require().Equal(expResult, res)
} else {
suite.Require().Error(err)
}
Expand Down
28 changes: 14 additions & 14 deletions x/erc20/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (

func (suite *KeeperTestSuite) TestTokenPairs() {
var (
req *types.QueryTokenPairsRequest
expRes *types.QueryTokenPairsResponse
req *types.QueryTokenPairsRequest
expResult *types.QueryTokenPairsResponse
)

testCases := []struct {
Expand All @@ -25,7 +25,7 @@ func (suite *KeeperTestSuite) TestTokenPairs() {
"no pairs registered",
func() {
req = &types.QueryTokenPairsRequest{}
expRes = &types.QueryTokenPairsResponse{Pagination: &query.PageResponse{}}
expResult = &types.QueryTokenPairsResponse{Pagination: &query.PageResponse{}}
},
true,
},
Expand All @@ -38,7 +38,7 @@ func (suite *KeeperTestSuite) TestTokenPairs() {
pair := types.NewTokenPair(utiltx.GenerateAddress(), "coin", types.OWNER_MODULE)
suite.app.Erc20Keeper.SetTokenPair(suite.ctx, pair)

expRes = &types.QueryTokenPairsResponse{
expResult = &types.QueryTokenPairsResponse{
Pagination: &query.PageResponse{Total: 1},
TokenPairs: []types.TokenPair{pair},
}
Expand All @@ -54,7 +54,7 @@ func (suite *KeeperTestSuite) TestTokenPairs() {
suite.app.Erc20Keeper.SetTokenPair(suite.ctx, pair)
suite.app.Erc20Keeper.SetTokenPair(suite.ctx, pair2)

expRes = &types.QueryTokenPairsResponse{
expResult = &types.QueryTokenPairsResponse{
Pagination: &query.PageResponse{Total: 2},
TokenPairs: []types.TokenPair{pair, pair2},
}
Expand All @@ -72,8 +72,8 @@ func (suite *KeeperTestSuite) TestTokenPairs() {
res, err := suite.queryClient.TokenPairs(ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().Equal(expRes.Pagination, res.Pagination)
suite.Require().ElementsMatch(expRes.TokenPairs, res.TokenPairs)
suite.Require().Equal(expResult.Pagination, res.Pagination)
suite.Require().ElementsMatch(expResult.TokenPairs, res.TokenPairs)
} else {
suite.Require().Error(err)
}
Expand All @@ -83,8 +83,8 @@ func (suite *KeeperTestSuite) TestTokenPairs() {

func (suite *KeeperTestSuite) TestTokenPair() {
var (
req *types.QueryTokenPairRequest
expRes *types.QueryTokenPairResponse
req *types.QueryTokenPairRequest
expResult *types.QueryTokenPairResponse
)

testCases := []struct {
Expand All @@ -96,7 +96,7 @@ func (suite *KeeperTestSuite) TestTokenPair() {
"invalid token address",
func() {
req = &types.QueryTokenPairRequest{}
expRes = &types.QueryTokenPairResponse{}
expResult = &types.QueryTokenPairResponse{}
},
false,
},
Expand All @@ -106,7 +106,7 @@ func (suite *KeeperTestSuite) TestTokenPair() {
req = &types.QueryTokenPairRequest{
Token: utiltx.GenerateAddress().Hex(),
}
expRes = &types.QueryTokenPairResponse{}
expResult = &types.QueryTokenPairResponse{}
},
false,
},
Expand All @@ -122,7 +122,7 @@ func (suite *KeeperTestSuite) TestTokenPair() {
req = &types.QueryTokenPairRequest{
Token: pair.Erc20Address,
}
expRes = &types.QueryTokenPairResponse{TokenPair: pair}
expResult = &types.QueryTokenPairResponse{TokenPair: pair}
},
true,
},
Expand All @@ -137,7 +137,7 @@ func (suite *KeeperTestSuite) TestTokenPair() {
req = &types.QueryTokenPairRequest{
Token: pair.Erc20Address,
}
expRes = &types.QueryTokenPairResponse{TokenPair: pair}
expResult = &types.QueryTokenPairResponse{TokenPair: pair}
},
false,
},
Expand All @@ -152,7 +152,7 @@ func (suite *KeeperTestSuite) TestTokenPair() {
res, err := suite.queryClient.TokenPair(ctx, req)
if tc.expPass {
suite.Require().NoError(err)
suite.Require().Equal(expRes, res)
suite.Require().Equal(expResult, res)
} else {
suite.Require().Error(err)
}
Expand Down
24 changes: 12 additions & 12 deletions x/erc20/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeCoin() {

tc.extra()
res, err := suite.app.Erc20Keeper.ConvertCoin(ctx, msg)
expRes := &types.MsgConvertCoinResponse{}
expResult := &types.MsgConvertCoinResponse{}
suite.Commit()
balance := suite.BalanceOf(common.HexToAddress(pair.Erc20Address), suite.address)
cosmosBalance := suite.app.BankKeeper.GetBalance(suite.ctx, sender, metadataCoin.Base)
Expand All @@ -199,7 +199,7 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeCoin() {
_, found := suite.app.Erc20Keeper.GetTokenPair(suite.ctx, id)
suite.Require().False(found)
} else {
suite.Require().Equal(expRes, res)
suite.Require().Equal(expResult, res)
suite.Require().Equal(cosmosBalance.Amount.Int64(), math.NewInt(tc.mint-tc.burn).Int64())
suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.burn).Int64())
}
Expand Down Expand Up @@ -382,13 +382,13 @@ func (suite *KeeperTestSuite) TestConvertERC20NativeCoin() {

tc.malleate()
res, err := suite.app.Erc20Keeper.ConvertERC20(ctx, msgConvertERC20)
expRes := &types.MsgConvertERC20Response{}
expResult := &types.MsgConvertERC20Response{}
suite.Commit()
balance = suite.BalanceOf(contractAddr, suite.address)
cosmosBalance = suite.app.BankKeeper.GetBalance(suite.ctx, sender, pair.Denom)
if tc.expPass {
suite.Require().NoError(err, tc.name)
suite.Require().Equal(expRes, res)
suite.Require().Equal(expResult, res)
suite.Require().Equal(cosmosBalance.Amount.Int64(), math.NewInt(tc.mint-tc.burn+tc.reconvert).Int64())
suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.burn-tc.reconvert).Int64())
} else {
Expand Down Expand Up @@ -727,7 +727,7 @@ func (suite *KeeperTestSuite) TestConvertERC20NativeERC20() {
tc.extra()
res, err := suite.app.Erc20Keeper.ConvertERC20(ctx, msg)

expRes := &types.MsgConvertERC20Response{}
expResult := &types.MsgConvertERC20Response{}
suite.Commit()
balance := suite.BalanceOf(contractAddr, suite.address)
cosmosBalance := suite.app.BankKeeper.GetBalance(suite.ctx, sender, coinName)
Expand All @@ -746,7 +746,7 @@ func (suite *KeeperTestSuite) TestConvertERC20NativeERC20() {
_, found := suite.app.Erc20Keeper.GetTokenPair(suite.ctx, id)
suite.Require().False(found)
} else {
suite.Require().Equal(expRes, res)
suite.Require().Equal(expResult, res)
suite.Require().Equal(cosmosBalance.Amount, math.NewInt(tc.transfer))
suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.mint-tc.transfer).Int64())
}
Expand Down Expand Up @@ -966,13 +966,13 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeERC20() {
tc.extra()
res, err := suite.app.Erc20Keeper.ConvertCoin(ctx, msg)

expRes := &types.MsgConvertCoinResponse{}
expResult := &types.MsgConvertCoinResponse{}
suite.Commit()
tokenBalance = suite.BalanceOf(contractAddr, suite.address)
cosmosBalance = suite.app.BankKeeper.GetBalance(suite.ctx, sender, coinName)
if tc.expPass {
suite.Require().NoError(err, tc.name)
suite.Require().Equal(expRes, res)
suite.Require().Equal(expResult, res)
suite.Require().Equal(math.NewInt(tc.mint-tc.convert), cosmosBalance.Amount)
suite.Require().Equal(big.NewInt(tc.convert), tokenBalance.(*big.Int))
} else {
Expand Down Expand Up @@ -1195,7 +1195,7 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeIBCVoucher() {

tc.extra()
res, err := suite.app.Erc20Keeper.ConvertCoin(ctx, msg)
expRes := &types.MsgConvertCoinResponse{}
expResult := &types.MsgConvertCoinResponse{}
suite.Commit()
balance := suite.BalanceOf(common.HexToAddress(pair.Erc20Address), suite.address)
cosmosBalance := suite.app.BankKeeper.GetBalance(suite.ctx, sender, metadataIbc.Base)
Expand All @@ -1215,7 +1215,7 @@ func (suite *KeeperTestSuite) TestConvertCoinNativeIBCVoucher() {
_, found := suite.app.Erc20Keeper.GetTokenPair(suite.ctx, id)
suite.Require().False(found)
} else {
suite.Require().Equal(expRes, res)
suite.Require().Equal(expResult, res)
suite.Require().Equal(cosmosBalance.Amount.Int64(), math.NewInt(tc.mint-tc.burn).Int64())
suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.burn).Int64())
}
Expand Down Expand Up @@ -1399,13 +1399,13 @@ func (suite *KeeperTestSuite) TestConvertERC20NativeIBCVoucher() {

tc.malleate()
res, err := suite.app.Erc20Keeper.ConvertERC20(ctx, msgConvertERC20)
expRes := &types.MsgConvertERC20Response{}
expResult := &types.MsgConvertERC20Response{}
suite.Commit()
balance = suite.BalanceOf(contractAddr, suite.address)
cosmosBalance = suite.app.BankKeeper.GetBalance(suite.ctx, sender, pair.Denom)
if tc.expPass {
suite.Require().NoError(err, tc.name)
suite.Require().Equal(expRes, res)
suite.Require().Equal(expResult, res)
suite.Require().Equal(cosmosBalance.Amount.Int64(), math.NewInt(tc.mint-tc.burn+tc.reconvert).Int64())
suite.Require().Equal(balance.(*big.Int).Int64(), big.NewInt(tc.burn-tc.reconvert).Int64())
} else {
Expand Down
Loading

0 comments on commit e014c7e

Please sign in to comment.