github.com/okex/exchain@v1.8.0/libs/ibc-go/testing/simapp/genesis_account.go (about) 1 package simapp 2 3 import ( 4 "errors" 5 authexported "github.com/okex/exchain/libs/cosmos-sdk/x/auth/exported" 6 "github.com/okex/exchain/libs/cosmos-sdk/x/supply" 7 8 sdk "github.com/okex/exchain/libs/cosmos-sdk/types" 9 authtypes "github.com/okex/exchain/libs/cosmos-sdk/x/auth/types" 10 ) 11 12 var _ authexported.GenesisAccount = (*SimGenesisAccount)(nil) 13 14 // SimGenesisAccount defines a type that implements the GenesisAccount interface 15 // to be used for simulation accounts in the genesis state. 16 type SimGenesisAccount struct { 17 *authtypes.BaseAccount 18 19 // vesting account fields 20 OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` // total vesting coins upon initialization 21 DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` // delegated vested coins at time of delegation 22 DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` // delegated vesting coins at time of delegation 23 StartTime int64 `json:"start_time" yaml:"start_time"` // vesting start time (UNIX Epoch time) 24 EndTime int64 `json:"end_time" yaml:"end_time"` // vesting end time (UNIX Epoch time) 25 26 // module account fields 27 ModuleName string `json:"module_name" yaml:"module_name"` // name of the module account 28 ModulePermissions []string `json:"module_permissions" yaml:"module_permissions"` // permissions of module account 29 } 30 31 // Validate checks for errors on the vesting and module account parameters 32 func (sga SimGenesisAccount) Validate() error { 33 if !sga.OriginalVesting.IsZero() { 34 if sga.StartTime >= sga.EndTime { 35 return errors.New("vesting start-time cannot be before end-time") 36 } 37 } 38 39 if sga.ModuleName != "" { 40 ma := supply.NewModuleAccount(sga.BaseAccount, sga.ModuleName, sga.ModulePermissions...) 41 if err := ma.Validate(); err != nil { 42 return err 43 } 44 } 45 46 return sga.BaseAccount.Validate() 47 }