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": {
|
||||||
|
"block": {
|
||||||
"account": {
|
"account": {
|
||||||
"balance": "0x"
|
"balance": "0x0"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
"request": "{block{account(address: \"0xdeaff00ddeaff00ddeaff00ddeaff00ddeaff00d\") { balance } }}",
|
"request": "{block{account(address: \"0xdeaff00ddeaff00ddeaff00ddeaff00ddeaff00d\") { balance } }}",
|
||||||
"responses": [{
|
"responses": [{
|
||||||
"data": {
|
"data": {
|
||||||
|
"block": {
|
||||||
"account": {
|
"account": {
|
||||||
"balance": "0x"
|
"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,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"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": {
|
"data": {
|
||||||
"transaction": {
|
"transaction": {
|
||||||
"block": {
|
"block": {
|
||||||
|
@ -22,6 +23,30 @@
|
||||||
"to": null
|
"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,6 +169,9 @@ 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 =
|
||||||
|
if val == 0.u256:
|
||||||
|
ok(Node(kind: nkString, stringVal: "0x0", pos: Pos()))
|
||||||
|
else:
|
||||||
let hex = stripLeadingZeros(val.toHex)
|
let hex = stripLeadingZeros(val.toHex)
|
||||||
ok(Node(kind: nkString, stringVal: "0x" & hex, pos: Pos()))
|
ok(Node(kind: nkString, stringVal: "0x" & hex, pos: Pos()))
|
||||||
|
|
||||||
|
@ -218,6 +221,9 @@ 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)
|
||||||
|
when false:
|
||||||
|
# EIP 1767 says no ommers == null
|
||||||
|
# but hive test case want empty array []
|
||||||
if uncles.len == 0:
|
if uncles.len == 0:
|
||||||
return ok(respNull())
|
return ok(respNull())
|
||||||
var list = respList()
|
var list = respList()
|
||||||
|
@ -301,6 +307,9 @@ 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)
|
||||||
|
when false:
|
||||||
|
# EIP 1767 unclear about non existent account
|
||||||
|
# but hive test case demand something
|
||||||
if not db.accountExists(address):
|
if not db.accountExists(address):
|
||||||
return ok(respNull())
|
return ok(respNull())
|
||||||
let acc = db.getAccount(address)
|
let acc = db.getAccount(address)
|
||||||
|
@ -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