fixes some of graphql resolver
following recent fixes in upstream hive, we also update our graphql resolvers
This commit is contained in:
parent
eb7c0be3d4
commit
d0782cdb0d
|
@ -2,8 +2,10 @@
|
||||||
"request": "{block (number: 25) {account(address: \"0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef\") { balance } }}",
|
"request": "{block (number: 25) {account(address: \"0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef\") { balance } }}",
|
||||||
"responses": [{
|
"responses": [{
|
||||||
"data": {
|
"data": {
|
||||||
"account": {
|
"block": {
|
||||||
"balance": "0x"
|
"account": {
|
||||||
|
"balance": "0x0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
"request": "{block{account(address: \"0xdeaff00ddeaff00ddeaff00ddeaff00ddeaff00d\") { balance } }}",
|
"request": "{block{account(address: \"0xdeaff00ddeaff00ddeaff00ddeaff00ddeaff00d\") { balance } }}",
|
||||||
"responses": [{
|
"responses": [{
|
||||||
"data": {
|
"data": {
|
||||||
"account": {
|
"block": {
|
||||||
"balance": "0x"
|
"account": {
|
||||||
|
"balance": "0x0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
{
|
{
|
||||||
"request" :"{ account(address: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\") { storage(slot: \"0x00000000000000000000000000000021\") } }",
|
"request": "{block{ account(address: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\") { storage(slot: \"0x0000000000000000000000000000000000000000000000000000000000000021\") } }}",
|
||||||
|
"responses": [
|
||||||
"responses":[{
|
{
|
||||||
"data" : {
|
"data": {
|
||||||
"account" : {
|
"block": {
|
||||||
"storage" : "0x0000000000000000000000000000000000000000000000000000000000000000"
|
"account": {
|
||||||
|
"storage": "0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
],
|
||||||
|
|
||||||
"statusCode": 200
|
"statusCode": 200
|
||||||
}
|
}
|
|
@ -1,13 +1,15 @@
|
||||||
{
|
{
|
||||||
"request" :"{ account(address: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\") { storage(slot: \"0x00000000000000000000000000000004\") } }",
|
"request": "{block{ account(address: \"0x6295ee1b4f6dd65047762f924ecd367c17eabf8f\") { storage(slot: \"0x0000000000000000000000000000000000000000000000000000000000000004\") } }}",
|
||||||
|
"responses": [
|
||||||
"responses": [{
|
{
|
||||||
"data" : {
|
"data": {
|
||||||
"account" :{
|
"block": {
|
||||||
"storage" :"0xaabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee"
|
"account": {
|
||||||
|
"storage": "0xaabbccffffffffffffffffffffffffffffffffffffffffffffffffffffffffee"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
],
|
||||||
|
|
||||||
"statusCode": 200
|
"statusCode": 200
|
||||||
}
|
}
|
|
@ -1,13 +1,24 @@
|
||||||
{
|
{
|
||||||
"request" :"{ account(address: \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\") { transactionCount } }",
|
"request": "{block{ account(address: \"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b\") { transactionCount } }}",
|
||||||
|
"responses": [
|
||||||
"responses": [{
|
{
|
||||||
"data" : {
|
"data": {
|
||||||
"account" :{
|
"block": {
|
||||||
"transactionCount" : 32
|
"account": {
|
||||||
|
"transactionCount": 32
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"block": {
|
||||||
|
"account": {
|
||||||
|
"transactionCount": "0x20"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
],
|
||||||
|
|
||||||
"statusCode": 200
|
"statusCode": 200
|
||||||
}
|
}
|
|
@ -1,27 +1,52 @@
|
||||||
{
|
{
|
||||||
"request": "{ transaction(hash: \"0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed\") {block{hash logsBloom} hash createdContract{address} cumulativeGasUsed gas gasUsed logs{topics} from{address} to{address} index } }",
|
"request": "{ transaction(hash: \"0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed\") {block{hash logsBloom} hash createdContract{address} cumulativeGasUsed gas gasUsed logs{topics} from{address} to{address} index } }",
|
||||||
"responses": [{
|
"responses": [
|
||||||
"data": {
|
{
|
||||||
"transaction": {
|
"data": {
|
||||||
"block": {
|
"transaction": {
|
||||||
"hash": "0x10aaf14a53caf27552325374429d3558398a36d3682ede6603c2c6511896e9f9",
|
"block": {
|
||||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
"hash": "0x10aaf14a53caf27552325374429d3558398a36d3682ede6603c2c6511896e9f9",
|
||||||
},
|
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||||
"createdContract": {
|
},
|
||||||
"address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f"
|
"createdContract": {
|
||||||
},
|
"address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f"
|
||||||
"cumulativeGasUsed": 493172,
|
},
|
||||||
"from": {
|
"cumulativeGasUsed": 493172,
|
||||||
"address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"
|
"from": {
|
||||||
},
|
"address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"
|
||||||
"gas": 3141592,
|
},
|
||||||
"gasUsed": 493172,
|
"gas": 3141592,
|
||||||
"hash": "0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed",
|
"gasUsed": 493172,
|
||||||
"index": 0,
|
"hash": "0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed",
|
||||||
"logs": [],
|
"index": 0,
|
||||||
"to": null
|
"logs": [],
|
||||||
|
"to": null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"transaction": {
|
||||||
|
"block": {
|
||||||
|
"hash": "0x10aaf14a53caf27552325374429d3558398a36d3682ede6603c2c6511896e9f9",
|
||||||
|
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
|
||||||
|
},
|
||||||
|
"createdContract": {
|
||||||
|
"address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f"
|
||||||
|
},
|
||||||
|
"cumulativeGasUsed": 493172,
|
||||||
|
"from": {
|
||||||
|
"address": "0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"
|
||||||
|
},
|
||||||
|
"gas": "0x2fefd8",
|
||||||
|
"gasUsed": 493172,
|
||||||
|
"hash": "0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed",
|
||||||
|
"index": 0,
|
||||||
|
"logs": [],
|
||||||
|
"to": null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
],
|
||||||
"statusCode": 200
|
"statusCode": 200
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,8 +169,11 @@ proc stripLeadingZeros(x: string): string =
|
||||||
strip(x, leading = true, trailing = false, chars = {'0'})
|
strip(x, leading = true, trailing = false, chars = {'0'})
|
||||||
|
|
||||||
proc bigIntNode(val: UInt256): RespResult =
|
proc bigIntNode(val: UInt256): RespResult =
|
||||||
let hex = stripLeadingZeros(val.toHex)
|
if val == 0.u256:
|
||||||
ok(Node(kind: nkString, stringVal: "0x" & hex, pos: Pos()))
|
ok(Node(kind: nkString, stringVal: "0x0", pos: Pos()))
|
||||||
|
else:
|
||||||
|
let hex = stripLeadingZeros(val.toHex)
|
||||||
|
ok(Node(kind: nkString, stringVal: "0x" & hex, pos: Pos()))
|
||||||
|
|
||||||
proc bigIntNode(x: uint64 | int64): RespResult =
|
proc bigIntNode(x: uint64 | int64): RespResult =
|
||||||
# stdlib toHex is not suitable for hive
|
# stdlib toHex is not suitable for hive
|
||||||
|
@ -218,8 +221,11 @@ proc getOmmerCount(ctx: GraphqlContextRef, ommersHash: Hash256): RespResult =
|
||||||
proc getOmmers(ctx: GraphqlContextRef, ommersHash: Hash256): RespResult =
|
proc getOmmers(ctx: GraphqlContextRef, ommersHash: Hash256): RespResult =
|
||||||
try:
|
try:
|
||||||
let uncles = getUncles(ctx.chainDB, ommersHash)
|
let uncles = getUncles(ctx.chainDB, ommersHash)
|
||||||
if uncles.len == 0:
|
when false:
|
||||||
return ok(respNull())
|
# EIP 1767 says no ommers == null
|
||||||
|
# but hive test case want empty array []
|
||||||
|
if uncles.len == 0:
|
||||||
|
return ok(respNull())
|
||||||
var list = respList()
|
var list = respList()
|
||||||
for n in uncles:
|
for n in uncles:
|
||||||
list.add headerNode(ctx, n)
|
list.add headerNode(ctx, n)
|
||||||
|
@ -301,8 +307,11 @@ proc getTxByHash(ctx: GraphqlContextRef, hash: Hash256): RespResult =
|
||||||
|
|
||||||
proc accountNode(ctx: GraphqlContextRef, header: BlockHeader, address: EthAddress): RespResult =
|
proc accountNode(ctx: GraphqlContextRef, header: BlockHeader, address: EthAddress): RespResult =
|
||||||
let db = getAccountDb(ctx.chainDB, header)
|
let db = getAccountDb(ctx.chainDB, header)
|
||||||
if not db.accountExists(address):
|
when false:
|
||||||
return ok(respNull())
|
# EIP 1767 unclear about non existent account
|
||||||
|
# but hive test case demand something
|
||||||
|
if not db.accountExists(address):
|
||||||
|
return ok(respNull())
|
||||||
let acc = db.getAccount(address)
|
let acc = db.getAccount(address)
|
||||||
ok(accountNode(ctx, acc, address, db))
|
ok(accountNode(ctx, acc, address, db))
|
||||||
|
|
||||||
|
@ -637,8 +646,7 @@ proc txCreatedContract(ud: RootRef, params: Args, parent: Node): RespResult {.ap
|
||||||
return hres
|
return hres
|
||||||
let h = HeaderNode(hres.get())
|
let h = HeaderNode(hres.get())
|
||||||
let db = getAccountDb(ctx.chainDB, h.header)
|
let db = getAccountDb(ctx.chainDB, h.header)
|
||||||
let creationNonce = db.getNonce(sender)
|
let contractAddress = generateAddress(sender, tx.tx.nonce)
|
||||||
let contractAddress = generateAddress(sender, creationNonce)
|
|
||||||
ctx.accountNode(h.header, contractAddress)
|
ctx.accountNode(h.header, contractAddress)
|
||||||
|
|
||||||
proc txLogs(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} =
|
proc txLogs(ud: RootRef, params: Args, parent: Node): RespResult {.apiPragma.} =
|
||||||
|
|
|
@ -154,7 +154,7 @@
|
||||||
"code":"0x",
|
"code":"0x",
|
||||||
"storage":"0x0000000000000000000000000000000000000000000000000000000000000000"
|
"storage":"0x0000000000000000000000000000000000000000000000000000000000000000"
|
||||||
},
|
},
|
||||||
"nullAccount":null
|
"nullAccount":{"__typename":"Account"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue