diff --git a/client/graphql_types.go b/client/graphql_types.go index 1774438..359f652 100644 --- a/client/graphql_types.go +++ b/client/graphql_types.go @@ -18,7 +18,7 @@ type Block struct { type Transaction struct { Hash types.Hash - Status string + Status types.HexNumber Index uint64 Nonce types.HexNumber From Address diff --git a/core/monitor/transaction.go b/core/monitor/transaction.go index e85053a..391ec76 100644 --- a/core/monitor/transaction.go +++ b/core/monitor/transaction.go @@ -45,7 +45,7 @@ func (tm *DefaultTransactionMonitor) fetchTransaction(block *types.Block, hash t tx := &types.Transaction{ Hash: hash, - Status: txOrigin.Status == "0x1", + Status: txOrigin.Status == 1, BlockNumber: block.Number, BlockHash: block.Hash, Index: txOrigin.Index, diff --git a/types/eth.go b/types/eth.go index c1b128a..ad3d9ab 100644 --- a/types/eth.go +++ b/types/eth.go @@ -173,18 +173,29 @@ func (num HexNumber) MarshalJSON() ([]byte, error) { } func (num *HexNumber) UnmarshalJSON(input []byte) error { + // check for integer first + var unwrappedUint uint64 var unwrapped string - if err := json.Unmarshal(input, &unwrapped); err != nil { - return err - } - out, err := strconv.ParseUint(unwrapped, 0, 64) - if err != nil { - return err + if err:= json.Unmarshal(input,&unwrappedUint); err!=nil{ + //check for string later + if err := json.Unmarshal(input, &unwrapped); err != nil { + return err + } + //String if fine + out, err := strconv.ParseUint(unwrapped, 0, 64) + if err != nil { + return err + } + // returning number from String + *num = HexNumber(out) + return nil } - *num = HexNumber(out) + // returning number from number + *num = HexNumber(unwrappedUint) return nil } + func (num *HexNumber) ToUint64() uint64 { return uint64(*num) }