func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error {
	var alias moduleAccountPretty
	if err := json.Unmarshal(bz, &alias); err != nil {
		return err
	}
	name, err := types.NewName(alias.Name)
	if err != nil {
		return err
	}
	newAccount := NewKuAccount(NewAccountIDFromName(name))
	if err := newAccount.SetAuth(alias.Address); err != nil {
		panic(err)
	}
	if err := newAccount.SetAccountNumber(alias.AccountNumber); err != nil {
		panic(err)
	}
	ma.KuAccount = *newAccount
	ma.Permissions = alias.Permissions
	return nil
}
UnmarshalJSON unmarshal raw JSON bytes into a ModuleAccount.
package types
import (
	"encoding/json"
	"errors"
	"fmt"
	"github.com/KuChainNetwork/kuchain/chain/types"
	"github.com/KuChainNetwork/kuchain/x/account/exported"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/tendermint/tendermint/crypto"
	"gopkg.in/yaml.v2"
)
var (
	_ exported.GenesisAccount = (*ModuleAccount)(nil)
	_ exported.Account        = (*ModuleAccount)(nil)
)
type ModuleAccount struct {
	KuAccount
	Permissions []string `json:"permissions,omitempty"`
}
func NewModuleAddress(name string) sdk.AccAddress {
	return sdk.AccAddress(crypto.AddressHash([]byte(name)))
}
func NewEmptyModuleAccount(name string, permissions ...string) *ModuleAccount {
	n, err := types.NewName(name)
	if err != nil {
		panic(err)
	}
	baseAccount := NewKuAccount(types.NewAccountIDFromName(n))
	if err := validatePermissions(permissions...); err != nil {
		panic(err)
	}
	return &ModuleAccount{
		KuAccount:   *baseAccount,
		Permissions: permissions,
	}
}
func NewModuleAccount(ba KuAccount, name string, permissions ...string) *ModuleAccount {
	if err := validatePermissions(permissions...); err != nil {
		panic(err)
	}
	return &ModuleAccount{
		KuAccount:   ba,
		Permissions: permissions,
	}
}
func (ma ModuleAccount) HasPermission(permission string) bool {
	for _, perm := range ma.Permissions {
		if perm == permission {
			return true
		}
	}
	return false
}
func (ma ModuleAccount) GetPermissions() []string {
	return ma.Permissions
}
func (ma ModuleAccount) GetAddress() sdk.AccAddress {
	return ma.GetAuth()
}
func (ma ModuleAccount) SetPubKey(pubKey crypto.PubKey) error {
	return fmt.Errorf("not supported for module accounts")
}
func (ma ModuleAccount) SetSequence(seq uint64) error {
	return fmt.Errorf("not supported for module accounts")
}
func (ma ModuleAccount) Validate() error {
	if ma.GetName().Empty() {
		return errors.New("module account name cannot be blank")
	}
	return ma.KuAccount.Validate()
}
type moduleAccountPretty struct {
	Address       sdk.AccAddress `json:"address" yaml:"address"`
	PubKey        string         `json:"public_key" yaml:"public_key"`
	AccountNumber uint64         `json:"account_number" yaml:"account_number"`
	Name          string         `json:"name" yaml:"name"`
	Permissions   []string       `json:"permissions" yaml:"permissions"`
}
func (ma ModuleAccount) String() string {
	out, _ := ma.MarshalYAML()
	return out.(string)
}
func (ma ModuleAccount) MarshalYAML() (interface{}, error) {
	add := types.AccAddress{}
	if len(ma.Auths) > 0 {
		add = ma.GetAuth()
	}
	bs, err := yaml.Marshal(moduleAccountPretty{
		Address:       add,
		PubKey:        "",
		AccountNumber: ma.AccountNumber,
		Name:          ma.Id.String(),
		Permissions:   ma.Permissions,
	})
	if err != nil {
		return nil, err
	}
	return string(bs), nil
}
func (ma ModuleAccount) MarshalJSON() ([]byte, error) {
	add := types.AccAddress{}
	if len(ma.Auths) > 0 {
		add = ma.GetAuth()
	}
	return json.Marshal(moduleAccountPretty{
		Address:       add,
		PubKey:        "",
		AccountNumber: ma.AccountNumber,
		Name:          ma.Id.String(),
		Permissions:   ma.Permissions,
	})
}