func (acc Account) GetPubKey() crypto.PubKey {
	return acc.PubKey
}
GetPubKey - Implements sdk.Account.
package types
import (
	"encoding/json"
	"fmt"
	"time"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/tendermint/tendermint/crypto"
)
type AccountRole string
const (
	Vendor                AccountRole = "Vendor"
	TestHouse             AccountRole = "TestHouse"
	ZBCertificationCenter AccountRole = "ZBCertificationCenter"
	Trustee               AccountRole = "Trustee"
	NodeAdmin             AccountRole = "NodeAdmin"
)
var Roles = AccountRoles{Vendor, TestHouse, ZBCertificationCenter, Trustee, NodeAdmin}
func (role AccountRole) Validate() sdk.Error {
	for _, r := range Roles {
		if role == r {
			return nil
		}
	}
	return sdk.ErrUnknownRequest(fmt.Sprintf("Invalid Account Role: %v. Supported roles: [%v]", role, Roles))
}
type AccountRoles []AccountRole
func (roles AccountRoles) Validate() sdk.Error {
	for _, role := range roles {
		if err := role.Validate(); err != nil {
			return err
		}
	}
	return nil
}
type PendingAccount struct {
	Address   sdk.AccAddress   `json:"address"`
	PubKey    crypto.PubKey    `json:"public_key"`
	Roles     AccountRoles     `json:"roles"`
	Approvals []sdk.AccAddress `json:"approvals"`
}
func NewPendingAccount(address sdk.AccAddress, pubKey crypto.PubKey,
	roles AccountRoles, approval sdk.AccAddress) PendingAccount {
	return PendingAccount{
		Address:   address,
		PubKey:    pubKey,
		Roles:     roles,
		Approvals: []sdk.AccAddress{approval},
	}
}
func (pendAcc PendingAccount) String() string {
	bytes, err := json.Marshal(pendAcc)
	if err != nil {
		panic(err)
	}
	return string(bytes)
}
func (pendAcc PendingAccount) Validate() sdk.Error {
	if pendAcc.Address == nil {
		return sdk.ErrUnknownRequest(
			fmt.Sprintf("Invalid Pending Account: Value: %s. Error: Missing Address", pendAcc.Address))
	}
	if pendAcc.PubKey == nil {
		return sdk.ErrUnknownRequest(
			fmt.Sprintf("Invalid Pending Account: Value: %s. Error: Missing PubKey", pendAcc.PubKey))
	}
	if err := pendAcc.Roles.Validate(); err != nil {
		return err
	}
	return nil
}
func (pendAcc PendingAccount) HasApprovalFrom(address sdk.AccAddress) bool {
	for _, approval := range pendAcc.Approvals {
		if approval.Equals(address) {
			return true
		}
	}
	return false
}
type Account struct {
	Address       sdk.AccAddress `json:"address"`
	PubKey        crypto.PubKey  `json:"public_key"`
	AccountNumber uint64         `json:"account_number"`
	Sequence      uint64         `json:"sequence"`
	Roles         AccountRoles   `json:"roles"`
}
func NewAccount(address sdk.AccAddress, pubKey crypto.PubKey, roles AccountRoles) Account {
	return Account{
		Address: address,
		PubKey:  pubKey,
		Roles:   roles,
	}
}
func (acc Account) String() string {
	bytes, err := json.Marshal(acc)
	if err != nil {
		panic(err)
	}
	return string(bytes)
}
func (acc Account) Validate() error {
	if acc.Address == nil {
		return sdk.ErrUnknownRequest(
			fmt.Sprintf("Invalid Account: Value: %s. Error: Missing Address", acc.Address))
	}
	if acc.PubKey == nil {
		return sdk.ErrUnknownRequest(
			fmt.Sprintf("Invalid Account: Value: %s. Error: Missing PubKey", acc.PubKey))
	}
	if err := acc.Roles.Validate(); err != nil {
		return err
	}
	return nil
}
func (acc Account) HasRole(targetRole AccountRole) bool {
	for _, role := range acc.Roles {
		if role == targetRole {
			return true
		}
	}
	return false
}
func (acc Account) GetAddress() sdk.AccAddress {
	return acc.Address
}
func (acc *Account) SetAddress(addr sdk.AccAddress) error {
	if len(acc.Address) != 0 {
		return sdk.ErrInvalidAddress("Cannot override Account address")
	}
	acc.Address = addr
	return nil
}