From 8f719202f16c5bc2fe5f0731f3a401590ceb2c38 Mon Sep 17 00:00:00 2001 From: Moonyongjung Date: Fri, 8 Sep 2023 16:12:46 +0900 Subject: [PATCH 1/3] refactor: remove unused functions which are used to test --- util/testutil/test_helper.go | 236 ----------------------------------- 1 file changed, 236 deletions(-) diff --git a/util/testutil/test_helper.go b/util/testutil/test_helper.go index 9a835e0..e4e6659 100644 --- a/util/testutil/test_helper.go +++ b/util/testutil/test_helper.go @@ -1,29 +1,14 @@ package testutil import ( - "bytes" - "encoding/hex" "encoding/json" - "math/rand" - "strconv" - "time" - xgoerrors "github.com/xpladev/xpla.go/types/errors" - "github.com/xpladev/xpla.go/util" - - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - authsign "github.com/cosmos/cosmos-sdk/x/auth/signing" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - simutil "github.com/cosmos/cosmos-sdk/x/simulation" "github.com/cosmos/go-bip39" evmhd "github.com/evmos/ethermint/crypto/hd" abci "github.com/tendermint/tendermint/abci/types" @@ -82,112 +67,6 @@ func setup(withGenesis bool, invCheckPeriod uint) (*xapp.XplaApp, xapp.GenesisSt return app, xapp.GenesisState{} } -// GenAndDeliverTxWithRandFees generates a transaction with a random fee and delivers it. -func GenAndDeliverTxWithRandFees(txCtx simutil.OperationInput) (simulation.OperationMsg, []simulation.FutureOperation, error) { - account := txCtx.AccountKeeper.GetAccount(txCtx.Context, txCtx.SimAccount.Address) - spendable := txCtx.Bankkeeper.SpendableCoins(txCtx.Context, account.GetAddress()) - - var fees sdk.Coins - var err error - - coins, hasNeg := spendable.SafeSub(txCtx.CoinsSpentInMsg) - if hasNeg { - return simulation.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "message doesn't leave room for fees"), nil, err - } - - fees, err = simulation.RandomFees(txCtx.R, txCtx.Context, coins) - if err != nil { - return simulation.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "unable to generate fees"), nil, err - } - return GenAndDeliverTx(txCtx, fees) -} - -// GenAndDeliverTx generates a transactions and delivers it. -func GenAndDeliverTx(txCtx simutil.OperationInput, fees sdk.Coins) (simulation.OperationMsg, []simulation.FutureOperation, error) { - account := txCtx.AccountKeeper.GetAccount(txCtx.Context, txCtx.SimAccount.Address) - tx, err := GenTx( - txCtx.TxGen, - []sdk.Msg{txCtx.Msg}, - fees, - DefaultTestGenTxGas, - TestChainId, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - txCtx.SimAccount.PrivKey, - ) - if err != nil { - return simulation.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "unable to generate mock tx"), nil, err - } - - _, _, err = txCtx.App.Deliver(txCtx.TxGen.TxEncoder(), tx) - if err != nil { - return simulation.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "unable to deliver tx"), nil, err - } - - return simulation.NewOperationMsg(txCtx.Msg, true, "", txCtx.Cdc), nil, nil -} - -// GenTx generates a signed mock transaction. -func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { - sigs := make([]signing.SignatureV2, len(priv)) - - // create a random length memo - r := rand.New(rand.NewSource(time.Now().UnixNano())) - - memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100)) - - signMode := gen.SignModeHandler().DefaultMode() - - // 1st round: set SignatureV2 with empty signatures, to set correct - // signer infos. - for i, p := range priv { - sigs[i] = signing.SignatureV2{ - PubKey: p.PubKey(), - Data: &signing.SingleSignatureData{ - SignMode: signMode, - }, - Sequence: accSeqs[i], - } - } - - tx := gen.NewTxBuilder() - err := tx.SetMsgs(msgs...) - if err != nil { - return nil, err - } - err = tx.SetSignatures(sigs...) - if err != nil { - return nil, err - } - tx.SetMemo(memo) - tx.SetFeeAmount(feeAmt) - tx.SetGasLimit(gas) - - // 2nd round: once all signer infos are set, every signer can sign. - for i, p := range priv { - signerData := authsign.SignerData{ - ChainID: chainID, - AccountNumber: accNums[i], - Sequence: accSeqs[i], - } - signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx()) - if err != nil { - panic(err) - } - sig, err := p.Sign(signBytes) - if err != nil { - panic(err) - } - sigs[i].Data.(*signing.SingleSignatureData).Signature = sig - err = tx.SetSignatures(sigs...) - if err != nil { - panic(err) - } - } - - return tx.GetTx(), nil -} - // FundAccount is a utility function that funds an account by minting and // sending the coins to the address. This should be used for testing purposes // only! @@ -202,121 +81,6 @@ func FundAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, addr sdk.AccAddr return bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, amounts) } -func TestAddr(addr string, bech string) (sdk.AccAddress, error) { - res, err := sdk.AccAddressFromHex(addr) - if err != nil { - return nil, err - } - bechexpected := res.String() - if bech != bechexpected { - return nil, util.LogErr(xgoerrors.ErrInvalidRequest, "bech encoding doesn't match reference") - } - - bechres, err := sdk.AccAddressFromBech32(bech) - if err != nil { - return nil, err - } - if !bytes.Equal(bechres, res) { - return nil, err - } - - return res, nil -} - -type GenerateAccountStrategy func(int) []sdk.AccAddress - -// AddTestAddrs constructs and returns accNum amount of accounts with an -// initial balance of accAmt in random order -func AddTestAddrsIncremental(app *xapp.XplaApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress { - return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts) -} - -func addTestAddrs(app *xapp.XplaApp, ctx sdk.Context, accNum int, accAmt sdk.Int, strategy GenerateAccountStrategy) []sdk.AccAddress { - testAddrs := strategy(accNum) - - initCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), accAmt)) - - for _, addr := range testAddrs { - initAccountWithCoins(app, ctx, addr, initCoins) - } - - return testAddrs -} - -func initAccountWithCoins(app *xapp.XplaApp, ctx sdk.Context, addr sdk.AccAddress, coins sdk.Coins) { - err := app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) - if err != nil { - panic(err) - } - - err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) - if err != nil { - panic(err) - } -} - -// createIncrementalAccounts is a strategy used by addTestAddrs() in order to generated addresses in ascending order. -func createIncrementalAccounts(accNum int) []sdk.AccAddress { - var addresses []sdk.AccAddress - var buffer bytes.Buffer - - // start at 100 so we can make up to 999 test addresses with valid test addresses - for i := 100; i < (accNum + 100); i++ { - numString := strconv.Itoa(i) - buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string - - buffer.WriteString(numString) // adding on final two digits to make addresses unique - res, _ := sdk.AccAddressFromHex(buffer.String()) - bech := res.String() - addr, _ := TestAddr(buffer.String(), bech) - - addresses = append(addresses, addr) - buffer.Reset() - } - - return addresses -} - -// ConvertAddrsToValAddrs converts the provided addresses to ValAddress. -func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { - valAddrs := make([]sdk.ValAddress, len(addrs)) - - for i, addr := range addrs { - valAddrs[i] = sdk.ValAddress(addr) - } - - return valAddrs -} - -// CreateTestPubKeys returns a total of numPubKeys public keys in ascending order. -func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey { - var publicKeys []cryptotypes.PubKey - var buffer bytes.Buffer - - // start at 10 to avoid changing 1 to 01, 2 to 02, etc - for i := 100; i < (numPubKeys + 100); i++ { - numString := strconv.Itoa(i) - buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") // base pubkey string - buffer.WriteString(numString) // adding on final two digits to make pubkeys unique - publicKeys = append(publicKeys, NewPubKeyFromHex(buffer.String())) - buffer.Reset() - } - - return publicKeys -} - -// NewPubKeyFromHex returns a PubKey from a hex string. -func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) { - pkBytes, err := hex.DecodeString(pk) - if err != nil { - panic(err) - } - if len(pkBytes) != ed25519.PubKeySize { - panic(errors.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")) - } - return &ed25519.PubKey{Key: pkBytes} -} - func NewTestMnemonic(entropy []byte) (string, error) { mnemonic, err := bip39.NewMnemonic(entropy) if err != nil { From 562db26bfb2ce2becd76379fe59cf1ada32929b7 Mon Sep 17 00:00:00 2001 From: Moonyongjung Date: Fri, 8 Sep 2023 16:13:38 +0900 Subject: [PATCH 2/3] style: change style of functions --- client/xplaclient.go | 154 ++++++++------------------------------- controller/controller.go | 47 ++++++------ 2 files changed, 53 insertions(+), 148 deletions(-) diff --git a/client/xplaclient.go b/client/xplaclient.go index b246ba3..6debce5 100644 --- a/client/xplaclient.go +++ b/client/xplaclient.go @@ -93,6 +93,8 @@ func (xplac *xplaClient) WithOptions( } // List of core modules. +// If new modules are implemented, regist ModuleExternal structure with +// receiver method in externalCoreModule. type externalCoreModule struct { auth.AuthExternal authz.AuthzExternal @@ -114,7 +116,7 @@ type externalCoreModule struct { wasm.WasmExternal } -// Update xpla client if data in the client are changed. +// Update xpla client if data in the xplaClient are changed. func (xplac *xplaClient) UpdateXplacInCoreModule() provider.XplaClient { xplac.externalCoreModule = externalCoreModule{ auth.NewAuthExternal(xplac), @@ -302,127 +304,29 @@ func (xplac *xplaClient) WithErr(err error) provider.XplaClient { return xplac.UpdateXplacInCoreModule() } -// Get chain ID -func (xplac *xplaClient) GetChainId() string { - return xplac.chainId -} - -// Get private key -func (xplac *xplaClient) GetPrivateKey() key.PrivateKey { - return xplac.opts.PrivateKey -} - -// Get encoding configuration -func (xplac *xplaClient) GetEncoding() paramsapp.EncodingConfig { - return xplac.encodingConfig -} - -// Get xpla client context -func (xplac *xplaClient) GetContext() context.Context { - return xplac.context -} - -// Get LCD URL -func (xplac *xplaClient) GetLcdURL() string { - return xplac.opts.LcdURL -} - -// Get GRPC URL to query or broadcast tx -func (xplac *xplaClient) GetGrpcUrl() string { - return xplac.opts.GrpcURL -} - -// Get GRPC client connector -func (xplac *xplaClient) GetGrpcClient() grpc1.ClientConn { - return xplac.grpc -} - -// Get RPC URL of tendermint core -func (xplac *xplaClient) GetRpc() string { - return xplac.opts.RpcURL -} - -// Get RPC URL for evm module -func (xplac *xplaClient) GetEvmRpc() string { - return xplac.opts.EvmRpcURL -} - -// Get broadcast mode -func (xplac *xplaClient) GetBroadcastMode() string { - return xplac.opts.BroadcastMode -} - -// Get account number -func (xplac *xplaClient) GetAccountNumber() string { - return xplac.opts.AccountNumber -} - -// Get account sequence -func (xplac *xplaClient) GetSequence() string { - return xplac.opts.Sequence -} - -// Get gas limit -func (xplac *xplaClient) GetGasLimit() string { - return xplac.opts.GasLimit -} - -// Get Gas price -func (xplac *xplaClient) GetGasPrice() string { - return xplac.opts.GasPrice -} - -// Get Gas adjustment -func (xplac *xplaClient) GetGasAdjustment() string { - return xplac.opts.GasAdjustment -} - -// Get fee amount -func (xplac *xplaClient) GetFeeAmount() string { - return xplac.opts.FeeAmount -} - -// Get transaction sign mode -func (xplac *xplaClient) GetSignMode() signing.SignMode { - return xplac.opts.SignMode -} - -// Get fee granter -func (xplac *xplaClient) GetFeeGranter() sdk.AccAddress { - return xplac.opts.FeeGranter -} - -// Get timeout block height -func (xplac *xplaClient) GetTimeoutHeight() string { - return xplac.opts.TimeoutHeight -} - -// Get pagination -func (xplac *xplaClient) GetPagination() *query.PageRequest { - return core.PageRequest -} - -// Get output document name -func (xplac *xplaClient) GetOutputDocument() string { - return xplac.opts.OutputDocument -} - -// Get module name -func (xplac *xplaClient) GetModule() string { - return xplac.module -} - -// Get message type of modules -func (xplac *xplaClient) GetMsgType() string { - return xplac.msgType -} - -// Get message -func (xplac *xplaClient) GetMsg() interface{} { - return xplac.msg -} - -// Get error -func (xplac *xplaClient) GetErr() error { - return xplac.err -} +// Get parameters of the xpla client +func (xplac *xplaClient) GetChainId() string { return xplac.chainId } +func (xplac *xplaClient) GetPrivateKey() key.PrivateKey { return xplac.opts.PrivateKey } +func (xplac *xplaClient) GetEncoding() paramsapp.EncodingConfig { return xplac.encodingConfig } +func (xplac *xplaClient) GetContext() context.Context { return xplac.context } +func (xplac *xplaClient) GetLcdURL() string { return xplac.opts.LcdURL } +func (xplac *xplaClient) GetGrpcUrl() string { return xplac.opts.GrpcURL } +func (xplac *xplaClient) GetGrpcClient() grpc1.ClientConn { return xplac.grpc } +func (xplac *xplaClient) GetRpc() string { return xplac.opts.RpcURL } +func (xplac *xplaClient) GetEvmRpc() string { return xplac.opts.EvmRpcURL } +func (xplac *xplaClient) GetBroadcastMode() string { return xplac.opts.BroadcastMode } +func (xplac *xplaClient) GetAccountNumber() string { return xplac.opts.AccountNumber } +func (xplac *xplaClient) GetSequence() string { return xplac.opts.Sequence } +func (xplac *xplaClient) GetGasLimit() string { return xplac.opts.GasLimit } +func (xplac *xplaClient) GetGasPrice() string { return xplac.opts.GasPrice } +func (xplac *xplaClient) GetGasAdjustment() string { return xplac.opts.GasAdjustment } +func (xplac *xplaClient) GetFeeAmount() string { return xplac.opts.FeeAmount } +func (xplac *xplaClient) GetSignMode() signing.SignMode { return xplac.opts.SignMode } +func (xplac *xplaClient) GetFeeGranter() sdk.AccAddress { return xplac.opts.FeeGranter } +func (xplac *xplaClient) GetTimeoutHeight() string { return xplac.opts.TimeoutHeight } +func (xplac *xplaClient) GetPagination() *query.PageRequest { return core.PageRequest } +func (xplac *xplaClient) GetOutputDocument() string { return xplac.opts.OutputDocument } +func (xplac *xplaClient) GetModule() string { return xplac.module } +func (xplac *xplaClient) GetMsgType() string { return xplac.msgType } +func (xplac *xplaClient) GetMsg() interface{} { return xplac.msg } +func (xplac *xplaClient) GetErr() error { return xplac.err } diff --git a/controller/controller.go b/controller/controller.go index d13ad49..5f5d6d8 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -40,32 +40,32 @@ func init() { // Set core controller only once as singleton, and get core controller. func Controller() *coreController { - once.Do( - func() { - cc = NewCoreController( - auth.NewCoreModule(), - authz.NewCoreModule(), - bank.NewCoreModule(), - base.NewCoreModule(), - crisis.NewCoreModule(), - distribution.NewCoreModule(), - evidence.NewCoreModule(), - evm.NewCoreModule(), - feegrant.NewCoreModule(), - gov.NewCoreModule(), - ibc.NewCoreModule(), - mint.NewCoreModule(), - params.NewCoreModule(), - reward.NewCoreModule(), - slashing.NewCoreModule(), - staking.NewCoreModule(), - upgrade.NewCoreModule(), - wasm.NewCoreModule(), - ) - }) + once.Do(func() { + cc = NewCoreController( + auth.NewCoreModule(), + authz.NewCoreModule(), + bank.NewCoreModule(), + base.NewCoreModule(), + crisis.NewCoreModule(), + distribution.NewCoreModule(), + evidence.NewCoreModule(), + evm.NewCoreModule(), + feegrant.NewCoreModule(), + gov.NewCoreModule(), + ibc.NewCoreModule(), + mint.NewCoreModule(), + params.NewCoreModule(), + reward.NewCoreModule(), + slashing.NewCoreModule(), + staking.NewCoreModule(), + upgrade.NewCoreModule(), + wasm.NewCoreModule(), + ) + }) return cc } +// Register routing info of core modules in the hash map. func NewCoreController(coreModules ...core.CoreModule) *coreController { m := make(map[string]core.CoreModule) for _, coreModule := range coreModules { @@ -77,6 +77,7 @@ func NewCoreController(coreModules ...core.CoreModule) *coreController { } } +// Get info of each module by its name. func (c coreController) Get(moduleName string) core.CoreModule { return c.cores[moduleName] } From 3cf51c75a7c2f85d591e70935962761b7c2a9110 Mon Sep 17 00:00:00 2001 From: Moonyongjung Date: Fri, 8 Sep 2023 16:14:22 +0900 Subject: [PATCH 3/3] docs: add comments and modify readme --- README.md | 2 +- core/core.go | 7 +++++++ provider/provider.go | 40 ++++++++++++++++++++++++++++++++++++- provider/provider_helper.go | 3 +++ util/testutil/account.go | 3 ++- 5 files changed, 52 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2070f9e..3c12c33 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Xpla.go is a Golang SDK for writing applications that interact with the Xpla blo |xpla.go|XPLA|Note| |:---:|:---:|:---:| -|v0.1.1|[v1.2.3](https://github.com/xpladev/xpla/tree/v1.2.3)|| +|v0.1.1-v0.1.2|[v1.2.3](https://github.com/xpladev/xpla/tree/v1.2.3)|| |v0.1.0|[v1.2.2](https://github.com/xpladev/xpla/tree/v1.2.2)|| diff --git a/core/core.go b/core/core.go index 24b814a..b682c1b 100644 --- a/core/core.go +++ b/core/core.go @@ -3,8 +3,15 @@ package core import cmclient "github.com/cosmos/cosmos-sdk/client" // The standard form for a module in the core package. +// Every modules are enrolled to the controller by using this interface. type CoreModule interface { + // Name of a core module must not be duplicated previous names. Name() string + + // Routed transaction messages are built in the TxBuilder of Cosmos-SDK. NewTxRouter(cmclient.TxBuilder, string, interface{}) (cmclient.TxBuilder, error) + + // Route query requests by gRPC or HTTP. + // Queries are returned with string type regardless of communication protocol. NewQueryRouter(QueryClient) (string, error) } diff --git a/provider/provider.go b/provider/provider.go index 5ad0bf1..2c7937e 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -17,6 +17,35 @@ import ( ) // The standard form of XPLA client is interface type. +// XplaClient is endpoint in order to access xpla.go from external packages. +// If new modules are implemeted, external functions that are used to send tx or query state should be +// enrolled in XplaClient interface. +// +// e.g. - enroll bank module +// +// type TxMsgProvider interface { +// ... +// BankSend(types.BankSendMsg) XplaClient +// ... +// } +// +// type QueryMsgProvider interface { +// ... +// BankBalances(types.BankBalancesMsg) XplaClient +// DenomMetadata(...types.DenomMetadataMsg) XplaClient +// Total(...types.TotalMsg) XplaClient +// ... +// } +// +// The return type of these methods must be always the XplaClient because the client uses mehod chaining. +// +// e.g. - create and sign transaction +// +// txbytes, err := xplac.BankSend(bankSendMsg).CreateAndSignTx() +// +// e.g. - query +// +// res, err := xplac.BankBalances(bankBalancesMsg).Query() type XplaClient interface { WithProvider GetProvider @@ -29,7 +58,7 @@ type XplaClient interface { HelperProvider } -// Optional parameters of xpla client. +// Optional parameters of client.xplaClient. type Options struct { PrivateKey key.PrivateKey AccountNumber string @@ -50,6 +79,7 @@ type Options struct { OutputDocument string } +// Methods set params of client.xplaClient. type WithProvider interface { UpdateXplacInCoreModule() XplaClient WithOptions(Options) XplaClient @@ -79,6 +109,7 @@ type WithProvider interface { WithErr(err error) XplaClient } +// Methods get params of client.xplaClient. type GetProvider interface { GetChainId() string GetPrivateKey() key.PrivateKey @@ -107,6 +138,7 @@ type GetProvider interface { GetErr() error } +// Methods handle transaction. type TxProvider interface { CreateAndSignTx() ([]byte, error) CreateUnsignedTx() ([]byte, error) @@ -117,21 +149,25 @@ type TxProvider interface { ValidateSignatures(types.ValidateSignaturesMsg) (string, error) } +// Method handles query functions. type QueryProvider interface { Query() (string, error) } +// Methods handle functions of broadcasting. type BroadcastProvider interface { Broadcast([]byte) (*types.TxRes, error) BroadcastBlock([]byte) (*types.TxRes, error) BroadcastAsync([]byte) (*types.TxRes, error) } +// Methods get information from XPLA chain. type InfoRequestProvider interface { LoadAccount(sdk.AccAddress) (authtypes.AccountI, error) Simulate(cmclient.TxBuilder) (*sdktx.SimulateResponse, error) } +// Methods are external functions of each module for sending transaction. type TxMsgProvider interface { // authz AuthzGrant(types.AuthzGrantMsg) XplaClient @@ -195,6 +231,7 @@ type TxMsgProvider interface { Migrate(types.MigrateMsg) XplaClient } +// Methods are external functions of each module for querying. type QueryMsgProvider interface { // auth AuthParams() XplaClient @@ -339,6 +376,7 @@ type QueryMsgProvider interface { LibwasmvmVersion() XplaClient } +// Method of helper. type HelperProvider interface { EncodedTxbytesToJsonTx([]byte) ([]byte, error) } diff --git a/provider/provider_helper.go b/provider/provider_helper.go index ad4c297..2096f4b 100644 --- a/provider/provider_helper.go +++ b/provider/provider_helper.go @@ -1,11 +1,14 @@ package provider +// Reset XplaClient. +// Remove recorded all parameters. func ResetXplac(xplac XplaClient) XplaClient { return ResetModuleAndMsgXplac(xplac). WithOptions(Options{}). WithErr(nil) } +// Reset XplaClient with removing module name and message. func ResetModuleAndMsgXplac(xplac XplaClient) XplaClient { return xplac. WithModule(""). diff --git a/util/testutil/account.go b/util/testutil/account.go index b62150d..f70cf66 100644 --- a/util/testutil/account.go +++ b/util/testutil/account.go @@ -8,7 +8,7 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" ) -// RandomAccounts generates n random accounts +// RandomAccounts generates n random accounts. func RandomAccounts(r *rand.Rand, n int) []simtypes.Account { accs := make([]simtypes.Account, n) @@ -30,6 +30,7 @@ func RandomAccounts(r *rand.Rand, n int) []simtypes.Account { return accs } +// RandomSecp256k1Accounts is prepared func for test. func RandomSecp256k1Accounts(r *rand.Rand, n int) []simtypes.Account { accs := make([]simtypes.Account, n)