-
Notifications
You must be signed in to change notification settings - Fork 826
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Genesis draft * revert evm params * revert evm params -2 * working simple test * linting * addressing linter errors * remove creating address for now
- Loading branch information
Showing
16 changed files
with
723 additions
and
170 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,54 @@ | ||
package keeper | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/store/prefix" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/query" | ||
"github.com/sei-protocol/sei-chain/x/confidentialtransfers/types" | ||
) | ||
|
||
func (k BaseKeeper) InitGenesis(ctx sdk.Context, gs *types.GenesisState) { | ||
k.SetParams(ctx, gs.Params) | ||
for i := range gs.Accounts { | ||
genesisCtAccount := gs.Accounts[i] | ||
store := ctx.KVStore(k.storeKey) | ||
bz := k.cdc.MustMarshal(&genesisCtAccount.Account) // Marshal the Account object into bytes | ||
store.Set(genesisCtAccount.Key, bz) | ||
} | ||
} | ||
|
||
func (k BaseKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { | ||
genesisCtAccounts, _, err := k.GetPaginatedAccounts(ctx, &query.PageRequest{Limit: query.MaxLimit}) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to fetch genesis ct accounts: %w", err)) | ||
} | ||
return types.NewGenesisState( | ||
k.GetParams(ctx), | ||
genesisCtAccounts, | ||
) | ||
} | ||
|
||
func (k BaseKeeper) GetPaginatedAccounts(ctx sdk.Context, pagination *query.PageRequest) ([]types.GenesisCtAccount, *query.PageResponse, error) { | ||
store := ctx.KVStore(k.storeKey) | ||
supplyStore := prefix.NewStore(store, types.AccountsKey) | ||
|
||
genesisAccounts := make([]types.GenesisCtAccount, 0) | ||
pageRes, err := query.Paginate(supplyStore, pagination, func(key, value []byte) error { | ||
var ctAccount types.CtAccount | ||
err := ctAccount.Unmarshal(value) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
genesisAccounts = append(genesisAccounts, types.GenesisCtAccount{Key: key, Account: ctAccount}) | ||
return nil | ||
}) | ||
|
||
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
||
return genesisAccounts, pageRes, nil | ||
} |
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,18 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"github.com/sei-protocol/sei-chain/x/confidentialtransfers/types" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
) | ||
|
||
func (suite *KeeperTestSuite) TestDefaultGenesisState() { | ||
genesisState := types.DefaultGenesisState() | ||
|
||
app := suite.App | ||
suite.Ctx = app.BaseApp.NewContext(false, tmproto.Header{}) | ||
|
||
suite.App.ConfidentialTransfersKeeper.InitGenesis(suite.Ctx, genesisState) | ||
exportedGenesis := suite.App.ConfidentialTransfersKeeper.ExportGenesis(suite.Ctx) | ||
suite.Require().NotNil(exportedGenesis) | ||
suite.Require().Equal(genesisState, exportedGenesis) | ||
} |
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,35 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"github.com/sei-protocol/sei-chain/app/apptesting" | ||
"github.com/sei-protocol/sei-chain/x/confidentialtransfers/keeper" | ||
"github.com/sei-protocol/sei-chain/x/confidentialtransfers/types" | ||
"github.com/stretchr/testify/suite" | ||
"testing" | ||
) | ||
|
||
type KeeperTestSuite struct { | ||
apptesting.KeeperTestHelper | ||
|
||
queryClient types.QueryClient | ||
msgServer types.MsgServer | ||
// defaultDenom is on the suite, as it depends on the creator test address. | ||
defaultDenom string | ||
} | ||
|
||
func TestKeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(KeeperTestSuite)) | ||
} | ||
|
||
func (suite *KeeperTestSuite) SetupTest() { | ||
suite.Setup() | ||
|
||
suite.queryClient = types.NewQueryClient(suite.QueryHelper) | ||
// TODO: remove this once the app initializes confidentialtransfers keeper | ||
suite.App.ConfidentialTransfersKeeper = keeper.NewKeeper( | ||
suite.App.AppCodec(), | ||
suite.App.GetKey(types.StoreKey), | ||
suite.App.GetSubspace(types.ModuleName), | ||
suite.App.AccountKeeper) | ||
suite.msgServer = keeper.NewMsgServerImpl(suite.App.ConfidentialTransfersKeeper) | ||
} |
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 |
---|---|---|
@@ -1,15 +1,49 @@ | ||
package keeper | ||
|
||
import "github.com/sei-protocol/sei-chain/x/confidentialtransfers/types" | ||
import ( | ||
"context" | ||
|
||
"github.com/sei-protocol/sei-chain/x/confidentialtransfers/types" | ||
) | ||
|
||
type msgServer struct { | ||
Keeper | ||
} | ||
|
||
func (m msgServer) Transfer(ctx context.Context, transfer *types.MsgTransfer) (*types.MsgTransferResponse, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (m msgServer) InitializeAccount(ctx context.Context, account *types.MsgInitializeAccount) (*types.MsgInitializeAccountResponse, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (m msgServer) Deposit(ctx context.Context, deposit *types.MsgDeposit) (*types.MsgDepositResponse, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (m msgServer) Withdraw(ctx context.Context, withdraw *types.MsgWithdraw) (*types.MsgWithdrawResponse, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (m msgServer) ApplyPendingBalance(ctx context.Context, balance *types.MsgApplyPendingBalance) (*types.MsgApplyPendingBalanceResponse, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
func (m msgServer) CloseAccount(ctx context.Context, account *types.MsgCloseAccount) (*types.MsgCloseAccountResponse, error) { | ||
//TODO implement me | ||
panic("implement me") | ||
} | ||
|
||
// NewMsgServerImpl returns an implementation of the MsgServer interface | ||
// for the provided Keeper. | ||
func NewMsgServerImpl(keeper Keeper) types.MsgServer { | ||
return &msgServer{Keeper: keeper} | ||
return msgServer{keeper} | ||
} | ||
|
||
var _ types.MsgServer = msgServer{} |
Oops, something went wrong.