116de54617
Closes #452 fix unit tests changelog and fix lint fix unit test Update ethereum/rpc/backend/backend.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> Update ethereum/rpc/backend/utils.go Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com> changelog Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package types
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
ethermint "github.com/tharsis/ethermint/types"
|
|
)
|
|
|
|
// Validate performs a basic validation of a GenesisAccount fields.
|
|
func (ga GenesisAccount) Validate() error {
|
|
if err := ethermint.ValidateAddress(ga.Address); err != nil {
|
|
return err
|
|
}
|
|
return ga.Storage.Validate()
|
|
}
|
|
|
|
// DefaultGenesisState sets default evm genesis state with empty accounts and default params and
|
|
// chain config values.
|
|
func DefaultGenesisState() *GenesisState {
|
|
return &GenesisState{
|
|
Accounts: []GenesisAccount{},
|
|
Params: DefaultParams(),
|
|
}
|
|
}
|
|
|
|
// Validate performs basic genesis state validation returning an error upon any
|
|
// failure.
|
|
func (gs GenesisState) Validate() error {
|
|
seenAccounts := make(map[string]bool)
|
|
for _, acc := range gs.Accounts {
|
|
if seenAccounts[acc.Address] {
|
|
return fmt.Errorf("duplicated genesis account %s", acc.Address)
|
|
}
|
|
if err := acc.Validate(); err != nil {
|
|
return fmt.Errorf("invalid genesis account %s: %w", acc.Address, err)
|
|
}
|
|
seenAccounts[acc.Address] = true
|
|
}
|
|
|
|
return gs.Params.Validate()
|
|
}
|