Skip to content

Commit

Permalink
feat: add msg mint (#784)
Browse files Browse the repository at this point in the history
* feat: integrated feemarket

* chore: updated anteHandler and postHandler

* chore: use replace for feemarket in go.mod

* chore: changed go version in docker file

* fix : fix testing in antehandler

* fix: fix lint issues

* chore: updated antehandler

* fix: fix lint issues

* fix: fix lint issues

* fix: lint issus

* chore: updated ante and fix test cases

* fix: gofumt errors

* fix: golint issues

* chore: updated postHandler

* testing

* chore: added test cases

* fix

* fix

* fix: golint issues

* fix : fix testcase

* fix: fix lint issues

* disable update tests

* disable report test

* fix: added response check in tests

* fix

* chore: added param subsace for feemarket

* addressed review comments

* fix

* fix

* fix

* TODO in app.go

* fix: golint error

* feat: add msg mint

* fix lint

* chore: added tests for mintMsg

* Temporarily disabled upgrade test runs + references

* chore: added upgradeHandler and upgraded the store loader

* chore: added integration test for mint msg

* fix: gofumpt issue

* fix: lint issue

* Removed stale replacement statement

* fixes

* fix

* testing

* lint fix

* fix

* remove build tag

* fix:gas issue

* fix tests

* fix: fix lint

* added gobuild tag

* test

* try fixing mint

* try fixing test

* try fix

* try fix

* try fix

* try trace

* try fix

* try fix

* fix tests

* fix tests

* try fix

* try fix

* fix lint

* push integartion build

* keys tests

* add query

* lint

* try fix

* cheqd home

* tests

* add git flow

* try fix

* try fix

* docker

* mainnet

* remove keys list

* fix setup

* fix

* ci

* ci

* ci

* remove home path

* tests

* tests

* tests

* ci

* tests

* add home

* changes

* changes

* try fix

* try fix

* fix test

* testing

* testing

* testing

* fix lint

* fix

* restored build tag

* testing

* fix

* added queryBalance to test minting

* buildtag

* fix

* chore: addressed review comments

* nits

* nit

* Aligned literals

* Removed redundant

* Aligned references

* Removed redundant

---------

Co-authored-by: vishal <[email protected]>
Co-authored-by: Tasos Derisiotis <[email protected]>
  • Loading branch information
3 people authored Oct 8, 2024
1 parent 26d77d1 commit bdbde82
Show file tree
Hide file tree
Showing 39 changed files with 2,640 additions and 185 deletions.
7 changes: 0 additions & 7 deletions ante/ante_feeabs_feemarket.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package ante

import (
"fmt"

feeabskeeper "github.com/osmosis-labs/fee-abstraction/v7/x/feeabs/keeper"
feeabstypes "github.com/osmosis-labs/fee-abstraction/v7/x/feeabs/types"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"
Expand All @@ -24,7 +22,6 @@ var _ feemarkettypes.DenomResolver = &DenomResolverImpl{}
// If the denom is not the bond denom, convert the `coin` to the given denom. return error if denom is not in the allowed list
func (r *DenomResolverImpl) ConvertToDenom(ctx sdk.Context, coin sdk.DecCoin, denom string) (sdk.DecCoin, error) {
bondDenom := r.StakingKeeper.BondDenom(ctx)
fmt.Println("Here>>>>>>>>>>>>>>>> ConvertToDenom and bondDenom and denom", bondDenom, denom, coin)
if denom != bondDenom && coin.Denom != bondDenom {
return sdk.DecCoin{}, ErrNeitherNativeDenom(coin.Denom, denom)
}
Expand All @@ -34,16 +31,13 @@ func (r *DenomResolverImpl) ConvertToDenom(ctx sdk.Context, coin sdk.DecCoin, de
var err error

if denom == bondDenom {

fmt.Println("Here<<<<<<<<<<<<<<<<<<< in if statement")
hostZoneConfig, found = r.FeeabsKeeper.GetHostZoneConfig(ctx, coin.Denom)
if !found {
return sdk.DecCoin{}, ErrDenomNotRegistered(coin.Denom)
}
amount, err = r.getIBCCoinFromNative(ctx, sdk.NewCoins(sdk.NewCoin(coin.
Denom, coin.Amount.TruncateInt())), hostZoneConfig)
} else if coin.Denom == bondDenom {
fmt.Println("here in elseif>>>>>>>>>>", coin.Denom, bondDenom)
hostZoneConfig, found := r.FeeabsKeeper.GetHostZoneConfig(ctx, denom)
if !found {
return sdk.DecCoin{}, ErrDenomNotRegistered(denom)
Expand All @@ -54,7 +48,6 @@ func (r *DenomResolverImpl) ConvertToDenom(ctx sdk.Context, coin sdk.DecCoin, de
if err != nil {
return sdk.DecCoin{}, err
}
fmt.Println(">>>>>>>>>>>>>>>>>>>", sdk.NewDecCoinFromDec(denom, amount[0].Amount.ToLegacyDec()))
return sdk.NewDecCoinFromDec(denom, amount[0].Amount.ToLegacyDec()), nil
}

Expand Down
28 changes: 14 additions & 14 deletions ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ var _ = Describe("Fee abstraction", func() {

It("should fail with empty fee", func() {
feeAmount := sdk.Coins{}
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin("ncheq", 100))...)
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 100))...)
suite.txBuilder.SetGasLimit(gasLimit)
suite.txBuilder.SetFeeAmount(feeAmount)
suite.ctx = suite.ctx.WithMinGasPrices(minGasPrice)
Expand All @@ -504,8 +504,8 @@ var _ = Describe("Fee abstraction", func() {
})

It("should fail with insufficient native fee", func() {
feeAmount := sdk.NewCoins(sdk.NewInt64Coin("ncheq", 100))
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin("ncheq", 1000))...)
feeAmount := sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 100))
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 1000))...)
suite.txBuilder.SetGasLimit(gasLimit)
suite.txBuilder.SetFeeAmount(feeAmount)
suite.ctx = suite.ctx.WithMinGasPrices(minGasPrice)
Expand All @@ -523,8 +523,8 @@ var _ = Describe("Fee abstraction", func() {
})

It("should pass with sufficient native fee", func() {
feeAmount := sdk.NewCoins(sdk.NewInt64Coin("ncheq", 1000*int64(gasLimit)))
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin("ncheq", 1000))...)
feeAmount := sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 1000*int64(gasLimit)))
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 1000))...)
suite.txBuilder.SetGasLimit(gasLimit)
suite.txBuilder.SetFeeAmount(feeAmount)
suite.ctx = suite.ctx.WithMinGasPrices(minGasPrice)
Expand All @@ -542,7 +542,7 @@ var _ = Describe("Fee abstraction", func() {

It("should fail with unknown ibc fee denom", func() {
feeAmount := sdk.NewCoins(sdk.NewInt64Coin("ibcfee", 1000*int64(gasLimit)))
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin("ncheq", 1000))...)
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 1000))...)
suite.txBuilder.SetGasLimit(gasLimit)
suite.txBuilder.SetFeeAmount(feeAmount)
suite.ctx = suite.ctx.WithMinGasPrices(minGasPrice)
Expand Down Expand Up @@ -596,8 +596,8 @@ var _ = Describe("DeductFeeDecorator", func() {
// Setup the common test data
BeforeEach(func() {
gasLimit = 200000
minGasPrice = sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin("ncheq", 1000))...)
feeAmount = sdk.NewCoins(sdk.NewInt64Coin("ncheq", 1000*int64(gasLimit)))
minGasPrice = sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 1000))...)
feeAmount = sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 1000*int64(gasLimit)))
ibcFeeAmount = sdk.NewCoins(sdk.NewInt64Coin("ibcfee", 1000*int64(gasLimit)))

mockHostZoneConfig = types.HostChainFeeAbsConfig{
Expand All @@ -624,7 +624,7 @@ var _ = Describe("DeductFeeDecorator", func() {
// minFee, _ := minGasPrice.TruncateDecimal()

params := suite.app.StakingKeeper.GetParams(suite.ctx)
params.BondDenom = "ncheq"
params.BondDenom = didtypes.BaseMinimalDenom
err = suite.app.StakingKeeper.SetParams(suite.ctx, params)
Expect(err).To(BeNil(), "Error setting the params")

Expand Down Expand Up @@ -1144,7 +1144,7 @@ var _ = Describe("Fee abstraction along with fee market", func() {
s := new(AnteTestSuite)
gasLimit := 200000
ibcFeeAmount := sdk.NewCoins(sdk.NewInt64Coin("ibcfee", 1000*int64(gasLimit)))
feeAmount := sdk.NewCoins(sdk.NewInt64Coin("ncheq", 1000*int64(gasLimit)))
feeAmount := sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 1000*int64(gasLimit)))

mockHostZoneConfig := types.HostChainFeeAbsConfig{
IbcDenom: "ibcfee",
Expand Down Expand Up @@ -1186,7 +1186,7 @@ var _ = Describe("Fee abstraction along with fee market", func() {
s.app.AccountKeeper.SetModuleAccount(s.ctx, feeabsModAcc)

params := s.app.StakingKeeper.GetParams(s.ctx)
params.BondDenom = "ncheq"
params.BondDenom = didtypes.BaseMinimalDenom
err = s.app.StakingKeeper.SetParams(s.ctx, params)
Expect(err).To(BeNil(), "Error setting the params")
})
Expand Down Expand Up @@ -1221,7 +1221,7 @@ var _ = Describe("Fee abstraction along with fee market", func() {
err := s.app.FeeabsKeeper.SetHostZoneConfig(s.ctx, mockHostZoneConfig)
Expect(err).ToNot(HaveOccurred())
s.app.FeeabsKeeper.SetTwapRate(s.ctx, "ibcfee", sdk.NewDec(1))
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin("ncheq", 100))...)
minGasPrice := sdk.NewDecCoinsFromCoins(sdk.NewCoins(sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 100))...)
s.ctx = s.ctx.WithMinGasPrices(minGasPrice)

anteHandler := sdk.ChainAnteDecorators(decorators...)
Expand Down Expand Up @@ -1281,7 +1281,7 @@ var _ = Describe("Fee abstraction along with fee market", func() {
err = testutil.FundAccount(s.app.BankKeeper, s.ctx, addr1, sdk.NewCoins(sdk.NewCoin(ibcDenom, amount)))
Expect(err).To(BeNil())

err = testutil.FundModuleAccount(s.app.BankKeeper, s.ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin("ncheq", amount)))
err = testutil.FundModuleAccount(s.app.BankKeeper, s.ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(didtypes.BaseMinimalDenom, amount)))
Expect(err).To(BeNil())

taxDecorator := cheqdpost.NewTaxDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.DidKeeper, s.app.ResourceKeeper, s.app.FeeMarketKeeper)
Expand Down Expand Up @@ -1350,7 +1350,7 @@ var _ = Describe("Fee abstraction along with fee market", func() {
err = testutil.FundAccount(s.app.BankKeeper, s.ctx, addr1, sdk.NewCoins(sdk.NewCoin(ibcDenom, amount)))
Expect(err).To(BeNil())

err = testutil.FundModuleAccount(s.app.BankKeeper, s.ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin("ncheq", amount)))
err = testutil.FundModuleAccount(s.app.BankKeeper, s.ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(didtypes.BaseMinimalDenom, amount)))
Expect(err).To(BeNil())

taxDecorator := cheqdpost.NewTaxDecorator(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, s.app.DidKeeper, s.app.ResourceKeeper, s.app.FeeMarketKeeper)
Expand Down
2 changes: 1 addition & 1 deletion ante/testutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (s *AnteTestSuite) CreateTestAccounts(numAccs int) ([]TestAccount, error) {
}
s.app.AccountKeeper.SetAccount(s.ctx, acc)
someCoins := sdk.Coins{
sdk.NewInt64Coin("ncheq", 1000000*1e9), // 1mn CHEQ
sdk.NewInt64Coin(didtypes.BaseMinimalDenom, 1000000*1e9), // 1mn CHEQ
}
err = s.app.BankKeeper.MintCoins(s.ctx, minttypes.ModuleName, someCoins)
if err != nil {
Expand Down
Loading

0 comments on commit bdbde82

Please sign in to comment.