Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

graphql: add Tx Receipts Logs to output #7059

Merged
merged 4 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
graphql: more work to match geth graphql output
  • Loading branch information
SLoeuillet committed Mar 9, 2023
commit a117596ce52199c6da8d515490e83f6a700774ad
1 change: 0 additions & 1 deletion cmd/rpcdaemon/commands/graphql_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func (api *GraphQLAPIImpl) GetBlockDetails(ctx context.Context, blockNumber rpc.
transaction["nonce"] = txn.GetNonce()
transaction["value"] = txn.GetValue()
transaction["data"] = txn.GetData()
transaction["gasPrice"] = txn.GetPrice()
transaction["logs"] = receipt.Logs
result = append(result, transaction)
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/rpcdaemon/graphql/graph/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions cmd/rpcdaemon/graphql/graph/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@ import (
func convertDataToStringP(abstractMap map[string]interface{}, field string) *string {
var result string

if reflect.ValueOf(abstractMap[field]).IsZero() {
return nil
}

switch v := abstractMap[field].(type) {
case int64:
result = strconv.FormatInt(v, 10)
case *hexutil.Big:
if reflect.ValueOf(abstractMap[field]).IsZero() {
return nil
}
result = v.String()
case hexutil.Bytes:
result = v.String()
Expand All @@ -31,6 +30,9 @@ func convertDataToStringP(abstractMap map[string]interface{}, field string) *str
case hexutil.Uint64:
result = v.String()
case *libcommon.Address:
if reflect.ValueOf(abstractMap[field]).IsZero() {
return nil
}
result = v.String()
case libcommon.Address:
result = v.String()
Expand All @@ -39,11 +41,16 @@ func convertDataToStringP(abstractMap map[string]interface{}, field string) *str
case types.Bloom:
result = hex.EncodeToString(v.Bytes())
case types.BlockNonce:
result = "0x" + strconv.FormatInt(int64(v.Uint64()), 16)
result = "0x" + fmt.Sprintf("%016x", int64(v.Uint64()))
case []uint8:
result = "0x" + hex.EncodeToString(v)
case *uint256.Int:
if reflect.ValueOf(abstractMap[field]).IsZero() {
return nil
}
result = v.Hex()
case uint64:
result = "0x" + strconv.FormatInt(int64(v), 16)
default:
fmt.Println("unhandled/string", reflect.TypeOf(abstractMap[field]), field, abstractMap[field])
result = "unhandled"
Expand Down
4 changes: 2 additions & 2 deletions cmd/rpcdaemon/graphql/graph/model/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions cmd/rpcdaemon/graphql/graph/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# Hash is the hash of this transaction.
hash: Bytes32!
# Nonce is the nonce of the account this transaction was generated with.
nonce: Long!
nonce: BigInt!
# Index is the index of this transaction in the parent block. This will
# be null if the transaction has not yet been mined.
index: Int
Expand Down Expand Up @@ -161,7 +161,7 @@
# Parent is the parent block of this block.
parent: Block
# Nonce is the block nonce, an 8 byte sequence determined by the miner.
nonce: Bytes!
nonce: BigInt!
# TransactionsRoot is the keccak256 hash of the root of the trie of transactions in this block.
transactionsRoot: Bytes32!
# TransactionCount is the number of transactions in this block. if
Expand All @@ -184,7 +184,7 @@
# NextBaseFeePerGas is the fee per unit of gas which needs to be burned in the next block.
nextBaseFeePerGas: BigInt
# Timestamp is the unix timestamp at which this block was mined.
timestamp: Long!
timestamp: BigInt!
# LogsBloom is a bloom filter that can be used to check if a block may
# contain log entries matching a filter.
logsBloom: Bytes!
Expand Down
26 changes: 15 additions & 11 deletions cmd/rpcdaemon/graphql/graph/schema.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.