github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/simapp/genesis_account.go (about) 1 package simapp 2 3 import ( 4 "errors" 5 6 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 7 authexported "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/exported" 8 authtypes "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/auth/types" 9 "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/x/supply" 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.OriginalVesting.IsAnyGT(sga.Coins) { 35 return errors.New("vesting amount cannot be greater than total amount") 36 } 37 if sga.StartTime >= sga.EndTime { 38 return errors.New("vesting start-time cannot be before end-time") 39 } 40 } 41 42 if sga.ModuleName != "" { 43 ma := supply.ModuleAccount{ 44 BaseAccount: sga.BaseAccount, Name: sga.ModuleName, Permissions: sga.ModulePermissions, 45 } 46 if err := ma.Validate(); err != nil { 47 return err 48 } 49 } 50 51 return sga.BaseAccount.Validate() 52 }