github.com/amazechain/amc@v0.1.3/internal/tracers/native/gen_account_json.go (about) 1 // Code generated by github.com/fjl/gencodec. DO NOT EDIT. 2 3 package native 4 5 import ( 6 "encoding/json" 7 "math/big" 8 9 "github.com/amazechain/amc/common/hexutil" 10 "github.com/amazechain/amc/common/types" 11 ) 12 13 var _ = (*accountMarshaling)(nil) 14 15 // MarshalJSON marshals as JSON. 16 func (a account) MarshalJSON() ([]byte, error) { 17 type account struct { 18 Balance *hexutil.Big `json:"balance,omitempty"` 19 Code hexutil.Bytes `json:"code,omitempty"` 20 Nonce uint64 `json:"nonce,omitempty"` 21 Storage map[types.Hash]types.Hash `json:"storage,omitempty"` 22 } 23 var enc account 24 enc.Balance = (*hexutil.Big)(a.Balance) 25 enc.Code = a.Code 26 enc.Nonce = a.Nonce 27 enc.Storage = a.Storage 28 return json.Marshal(&enc) 29 } 30 31 // UnmarshalJSON unmarshals from JSON. 32 func (a *account) UnmarshalJSON(input []byte) error { 33 type account struct { 34 Balance *hexutil.Big `json:"balance,omitempty"` 35 Code *hexutil.Bytes `json:"code,omitempty"` 36 Nonce *uint64 `json:"nonce,omitempty"` 37 Storage map[types.Hash]types.Hash `json:"storage,omitempty"` 38 } 39 var dec account 40 if err := json.Unmarshal(input, &dec); err != nil { 41 return err 42 } 43 if dec.Balance != nil { 44 a.Balance = (*big.Int)(dec.Balance) 45 } 46 if dec.Code != nil { 47 a.Code = *dec.Code 48 } 49 if dec.Nonce != nil { 50 a.Nonce = *dec.Nonce 51 } 52 if dec.Storage != nil { 53 a.Storage = dec.Storage 54 } 55 return nil 56 }