Skip to content

Commit

Permalink
change author json (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDenver007 authored and erickyan86 committed May 5, 2019
1 parent 4e25606 commit 67cdfa9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions common/author.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ type StorageAuthor struct {
}

type AuthorJSON struct {
Type AuthorType
OwnerStr string
Weight uint64
authorType AuthorType
OwnerStr string `json:"owner"`
Weight uint64 `json:"weight"`
}

func NewAuthor(owner Owner, weight uint64) *Author {
Expand Down Expand Up @@ -135,11 +135,11 @@ func (a *Author) decode(sa *StorageAuthor) error {
func (a *Author) MarshalJSON() ([]byte, error) {
switch aTy := a.Owner.(type) {
case Name:
return json.Marshal(&AuthorJSON{Type: AccountNameType, OwnerStr: aTy.String(), Weight: a.Weight})
return json.Marshal(&AuthorJSON{authorType: AccountNameType, OwnerStr: aTy.String(), Weight: a.Weight})
case PubKey:
return json.Marshal(&AuthorJSON{Type: PubKeyType, OwnerStr: aTy.String(), Weight: a.Weight})
return json.Marshal(&AuthorJSON{authorType: PubKeyType, OwnerStr: aTy.String(), Weight: a.Weight})
case Address:
return json.Marshal(&AuthorJSON{Type: AddressType, OwnerStr: aTy.String(), Weight: a.Weight})
return json.Marshal(&AuthorJSON{authorType: AddressType, OwnerStr: aTy.String(), Weight: a.Weight})
}
return nil, errors.New("Author marshal failed")
}
Expand All @@ -149,7 +149,7 @@ func (a *Author) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, aj); err != nil {
return err
}
switch aj.Type {
switch aj.authorType {
case AccountNameType:
a.Owner = Name(aj.OwnerStr)
a.Weight = aj.Weight
Expand Down

0 comments on commit 67cdfa9

Please sign in to comment.