-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* export genesis * update query api * fix bug * can not issue lpt token * fix test error * fix test error
- Loading branch information
Zhiqiang Zhang
committed
Aug 16, 2021
1 parent
713067d
commit ce9657b
Showing
16 changed files
with
280 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package keeper | ||
|
||
import ( | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/irisnet/irismod/modules/coinswap/types" | ||
) | ||
|
||
// InitGenesis initializes the coinswap module's state from a given genesis state. | ||
func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { | ||
if err := types.ValidateGenesis(genState); err != nil { | ||
panic(fmt.Errorf("panic for ValidateGenesis,%v", err)) | ||
} | ||
k.SetParams(ctx, genState.Params) | ||
k.SetStandardDenom(ctx, genState.StandardDenom) | ||
k.setSequence(ctx, genState.Sequence) | ||
for _, pool := range genState.Pool { | ||
k.setPool(ctx, &pool) | ||
} | ||
} | ||
|
||
// ExportGenesis returns the coinswap module's genesis state. | ||
func (k Keeper) ExportGenesis(ctx sdk.Context) types.GenesisState { | ||
return types.GenesisState{ | ||
Params: k.GetParams(ctx), | ||
StandardDenom: k.GetStandardDenom(ctx), | ||
Pool: k.GetAllPools(ctx), | ||
Sequence: k.getSequence(ctx), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/irisnet/irismod/modules/coinswap/types" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
func TestGenesisSuite(t *testing.T) { | ||
suite.Run(t, new(TestSuite)) | ||
} | ||
|
||
func (suite *TestSuite) TestInitGenesisAndExportGenesis() { | ||
expGenesis := types.GenesisState{ | ||
Params: types.Params{ | ||
Fee: sdk.NewDecWithPrec(4, 3), | ||
}, | ||
StandardDenom: denomStandard, | ||
Pool: []types.Pool{{ | ||
Id: types.GetPoolId(denomETH), | ||
StandardDenom: denomStandard, | ||
CounterpartyDenom: denomETH, | ||
EscrowAddress: types.GetReservePoolAddr("lpt-1").String(), | ||
LptDenom: "lpt-1", | ||
}}, | ||
Sequence: 2, | ||
} | ||
suite.app.CoinswapKeeper.InitGenesis(suite.ctx, expGenesis) | ||
actGenesis := suite.app.CoinswapKeeper.ExportGenesis(suite.ctx) | ||
suite.Require().Equal(expGenesis, actGenesis) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.