-
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.
feat: wip, done(keeper, query, msg_server)
- Loading branch information
1 parent
fd4945a
commit 435c7f4
Showing
33 changed files
with
903 additions
and
376 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package config | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/Finschia/finschia-sdk/types" | ||
) | ||
|
||
type FswapConfig interface { | ||
OldDenom() string | ||
NewDenom() string | ||
SwapCap() types.Int | ||
SwapMultiple() types.Int | ||
} | ||
|
||
func DefaultConfig() *Config { | ||
oldDenom := "cony" | ||
newDenom := "peb" | ||
defaultCap, _ := big.NewInt(0).SetString("1151185567094084523856000000", 10) | ||
swapCap := types.NewIntFromBigInt(defaultCap) | ||
num, _ := big.NewInt(0).SetString("148079656000000", 10) | ||
swapMultiple := types.NewIntFromBigInt(num) | ||
|
||
return &Config{ | ||
oldDenom, | ||
newDenom, | ||
swapCap, | ||
swapMultiple, | ||
} | ||
} | ||
|
||
type Config struct { | ||
oldDenom string | ||
newDenom string | ||
swapCap types.Int | ||
swapMultiple types.Int | ||
} | ||
|
||
func (c Config) OldDenom() string { | ||
return c.oldDenom | ||
} | ||
|
||
func (c Config) NewDenom() string { | ||
return c.newDenom | ||
} | ||
|
||
func (c Config) SwapCap() types.Int { | ||
return c.swapCap | ||
} | ||
|
||
func (c Config) SwapMultiple() types.Int { | ||
return c.swapMultiple | ||
} |
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/Finschia/finschia-sdk/types" | ||
"github.com/Finschia/finschia-sdk/x/fswap/types" | ||
) | ||
|
||
// InitGenesis initializes the module's state accWithOldCoin a provided genesis | ||
// state. | ||
func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { | ||
if err := k.SetParams(ctx, genState.Params); err != nil { | ||
panic(err) | ||
} | ||
if err := k.SetSwapped(ctx, genState.Swapped); err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
// ExportGenesis returns the capability module's exported genesis. | ||
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { | ||
params, err := k.GetParams(ctx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
swapped, err := k.GetSwapped(ctx) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return &types.GenesisState{ | ||
Params: params, | ||
Swapped: swapped, | ||
} | ||
} |
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,13 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"github.com/Finschia/finschia-sdk/x/fswap/types" | ||
) | ||
|
||
func (s *KeeperTestSuite) TestInitAndExportGenesis() { | ||
s.keeper.InitGenesis(s.ctx, *types.DefaultGenesis()) | ||
got := s.keeper.ExportGenesis(s.ctx) | ||
s.Require().NotNil(got) | ||
s.Require().Equal(types.DefaultParams(), got.Params) | ||
s.Require().Equal(types.DefaultSwapped(), got.Swapped) | ||
} |
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.
Oops, something went wrong.