github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/ibc-go/testing/simapp/genesis_account.go (about)

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