mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
Moved schema into its own source file
This commit is contained in:
parent
32068e0e31
commit
c3387f8d0c
1 changed files with 2 additions and 128 deletions
|
|
@ -1083,137 +1083,11 @@ func (r *Resolver) Syncing() (*SyncState, error) {
|
||||||
func NewHandler(n *node.Node) (http.Handler, error) {
|
func NewHandler(n *node.Node) (http.Handler, error) {
|
||||||
q := Resolver{n}
|
q := Resolver{n}
|
||||||
|
|
||||||
s := `
|
s, err := graphql.ParseSchema(schema, &q)
|
||||||
scalar Bytes32
|
|
||||||
scalar Address
|
|
||||||
scalar Bytes
|
|
||||||
scalar BigInt
|
|
||||||
scalar Long
|
|
||||||
|
|
||||||
schema {
|
|
||||||
query: Query
|
|
||||||
mutation: Mutation
|
|
||||||
}
|
|
||||||
|
|
||||||
type Account {
|
|
||||||
address: Address!
|
|
||||||
balance: BigInt!
|
|
||||||
transactionCount: Long!
|
|
||||||
code: Bytes!
|
|
||||||
storage(slot: Bytes32!): Bytes32!
|
|
||||||
}
|
|
||||||
|
|
||||||
type Log {
|
|
||||||
index: Int!
|
|
||||||
account(block: Long): Account!
|
|
||||||
topics: [Bytes32!]!
|
|
||||||
data: Bytes!
|
|
||||||
transaction: Transaction!
|
|
||||||
}
|
|
||||||
|
|
||||||
type Transaction {
|
|
||||||
hash: Bytes32!
|
|
||||||
nonce: Long!
|
|
||||||
index: Int
|
|
||||||
from(block: Long): Account!
|
|
||||||
to(block: Long): Account
|
|
||||||
value: BigInt!
|
|
||||||
gasPrice: BigInt!
|
|
||||||
gas: Long!
|
|
||||||
inputData: Bytes!
|
|
||||||
block: Block
|
|
||||||
|
|
||||||
status: Long
|
|
||||||
gasUsed: Long
|
|
||||||
cumulativeGasUsed: Long
|
|
||||||
createdContract(block: Long): Account
|
|
||||||
logs: [Log!]
|
|
||||||
}
|
|
||||||
|
|
||||||
input BlockFilterCriteria {
|
|
||||||
addresses: [Address!]
|
|
||||||
topics: [[Bytes32!]!]
|
|
||||||
}
|
|
||||||
|
|
||||||
type Block {
|
|
||||||
number: Long!
|
|
||||||
hash: Bytes32!
|
|
||||||
parent: Block
|
|
||||||
nonce: Bytes!
|
|
||||||
transactionsRoot: Bytes32!
|
|
||||||
transactionCount: Int
|
|
||||||
stateRoot: Bytes32!
|
|
||||||
receiptsRoot: Bytes32!
|
|
||||||
miner(block: Long): Account!
|
|
||||||
extraData: Bytes!
|
|
||||||
gasLimit: Long!
|
|
||||||
gasUsed: Long!
|
|
||||||
timestamp: BigInt!
|
|
||||||
logsBloom: Bytes!
|
|
||||||
mixHash: Bytes32!
|
|
||||||
difficulty: BigInt!
|
|
||||||
totalDifficulty: BigInt!
|
|
||||||
ommerCount: Int
|
|
||||||
ommers: [Block]
|
|
||||||
ommerAt(index: Int!): Block
|
|
||||||
ommerHash: Bytes32!
|
|
||||||
transactions: [Transaction!]
|
|
||||||
transactionAt(index: Int!): Transaction
|
|
||||||
logs(filter: BlockFilterCriteria!): [Log!]!
|
|
||||||
}
|
|
||||||
|
|
||||||
input CallData {
|
|
||||||
from: Address
|
|
||||||
to: Address
|
|
||||||
gas: Long
|
|
||||||
gasPrice: BigInt
|
|
||||||
value: BigInt
|
|
||||||
data: Bytes
|
|
||||||
}
|
|
||||||
|
|
||||||
type CallResult {
|
|
||||||
data: Bytes!
|
|
||||||
gasUsed: Long!
|
|
||||||
status: Long!
|
|
||||||
}
|
|
||||||
|
|
||||||
input FilterCriteria {
|
|
||||||
fromBlock: Long
|
|
||||||
toBlock: Long
|
|
||||||
addresses: [Address!]
|
|
||||||
topics: [[Bytes32!]!]
|
|
||||||
}
|
|
||||||
|
|
||||||
type SyncState{
|
|
||||||
startingBlock: Long!
|
|
||||||
currentBlock: Long!
|
|
||||||
highestBlock: Long!
|
|
||||||
pulledStates: Long
|
|
||||||
knownStates: Long
|
|
||||||
}
|
|
||||||
|
|
||||||
type Query {
|
|
||||||
account(address: Address!, blockNumber: Long): Account!
|
|
||||||
block(number: Long, hash: Bytes32): Block
|
|
||||||
blocks(from: Long!, to: Long): [Block!]!
|
|
||||||
transaction(hash: Bytes32!): Transaction
|
|
||||||
call(data: CallData!, blockNumber: Long): CallResult
|
|
||||||
estimateGas(data: CallData!, blockNumber: Long): Long!
|
|
||||||
logs(filter: FilterCriteria!): [Log!]!
|
|
||||||
gasPrice: BigInt!
|
|
||||||
protocolVersion: Int!
|
|
||||||
syncing: SyncState
|
|
||||||
}
|
|
||||||
|
|
||||||
type Mutation {
|
|
||||||
sendRawTransaction(data: Bytes!): Bytes32!
|
|
||||||
}
|
|
||||||
`
|
|
||||||
schema, err := graphql.ParseSchema(s, &q)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
h := &relay.Handler{Schema: schema}
|
h := &relay.Handler{Schema: s}
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
mux.Handle("/", GraphiQL{})
|
mux.Handle("/", GraphiQL{})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue