github.com/core-coin/go-core/v2@v2.1.9/graphql/schema.go (about)

     1  // Copyright 2019 by the Authors
     2  // This file is part of the go-core library.
     3  //
     4  // The go-core library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-core library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-core library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package graphql
    18  
    19  const schema string = `
    20      # Bytes32 is a 32 byte binary string, represented as 0x-prefixed hexadecimal.
    21      scalar Bytes32
    22      # Address is a 20 byte Core address, represented as 0x-prefixed hexadecimal.
    23      scalar Address
    24      # Bytes is an arbitrary length binary string, represented as 0x-prefixed hexadecimal.
    25      # An empty byte string is represented as '0x'. Byte strings must have an even number of hexadecimal nybbles.
    26      scalar Bytes
    27      # BigInt is a large integer. Input is accepted as either a JSON number or as a string.
    28      # Strings may be either decimal or 0x-prefixed hexadecimal. Output values are all
    29      # 0x-prefixed hexadecimal.
    30      scalar BigInt
    31      # Long is a 64 bit unsigned integer.
    32      scalar Long
    33  
    34      schema {
    35          query: Query
    36          mutation: Mutation
    37      }
    38  
    39      # Account is an Core account at a particular block.
    40      type Account {
    41          # Address is the address owning the account.
    42          address: Address!
    43          # Balance is the balance of the account, in ore.
    44          balance: BigInt!
    45          # TransactionCount is the number of transactions sent from this account,
    46          # or in the case of a contract, the number of contracts created. Otherwise
    47          # known as the nonce.
    48          transactionCount: Long!
    49          # Code contains the smart contract code for this account, if the account
    50          # is a (non-self-destructed) contract.
    51          code: Bytes!
    52          # Storage provides access to the storage of a contract account, indexed
    53          # by its 32 byte slot identifier.
    54          storage(slot: Bytes32!): Bytes32!
    55      }
    56  
    57      # Log is an Core event log.
    58      type Log {
    59          # Index is the index of this log in the block.
    60          index: Int!
    61          # Account is the account which generated this log - this will always
    62          # be a contract account.
    63          account(block: Long): Account!
    64          # Topics is a list of 0-4 indexed topics for the log.
    65          topics: [Bytes32!]!
    66          # Data is unindexed data for this log.
    67          data: Bytes!
    68          # Transaction is the transaction that generated this log entry.
    69          transaction: Transaction!
    70      }
    71  
    72      # Transaction is an Core transaction.
    73      type Transaction {
    74          # Hash is the hash of this transaction.
    75          hash: Bytes32!
    76          # Nonce is the nonce of the account this transaction was generated with.
    77          nonce: Long!
    78          # Index is the index of this transaction in the parent block. This will
    79          # be null if the transaction has not yet been mined.
    80          index: Int
    81          # From is the account that sent this transaction - this will always be
    82          # an externally owned account.
    83          from(block: Long): Account!
    84          # To is the account the transaction was sent to. This is null for
    85          # contract-creating transactions.
    86          to(block: Long): Account
    87          # Value is the value, in ore, sent along with this transaction.
    88          value: BigInt!
    89          # EnergyPrice is the price offered to miners for energy, in ore per unit.
    90          energyPrice: BigInt!
    91          # Energy is the maximum amount of energy this transaction can consume.
    92          energy: Long!
    93          # InputData is the data supplied to the target of the transaction.
    94          inputData: Bytes!
    95          # Block is the block this transaction was mined in. This will be null if
    96          # the transaction has not yet been mined.
    97          block: Block
    98  
    99          # Status is the return status of the transaction. This will be 1 if the
   100          # transaction succeeded, or 0 if it failed (due to a revert, or due to
   101          # running out of energy). If the transaction has not yet been mined, this
   102          # field will be null.
   103          status: Long
   104          # EnergyUsed is the amount of energy that was used processing this transaction.
   105          # If the transaction has not yet been mined, this field will be null.
   106          energyUsed: Long
   107          # CumulativeEnergyUsed is the total energy used in the block up to and including
   108          # this transaction. If the transaction has not yet been mined, this field
   109          # will be null.
   110          cumulativeEnergyUsed: Long
   111          # CreatedContract is the account that was created by a contract creation
   112          # transaction. If the transaction was not a contract creation transaction,
   113          # or it has not yet been mined, this field will be null.
   114          createdContract(block: Long): Account
   115          # Logs is a list of log entries emitted by this transaction. If the
   116          # transaction has not yet been mined, this field will be null.
   117          logs: [Log!]
   118      }
   119  
   120      # BlockFilterCriteria encapsulates log filter criteria for a filter applied
   121      # to a single block.
   122      input BlockFilterCriteria {
   123          # Addresses is list of addresses that are of interest. If this list is
   124          # empty, results will not be filtered by address.
   125          addresses: [Address!]
   126          # Topics list restricts matches to particular event topics. Each event has a list
   127        # of topics. Topics matches a prefix of that list. An empty element array matches any
   128        # topic. Non-empty elements represent an alternative that matches any of the
   129        # contained topics.
   130        #
   131        # Examples:
   132        #  - [] or nil          matches any topic list
   133        #  - [[A]]              matches topic A in first position
   134        #  - [[], [B]]          matches any topic in first position, B in second position
   135        #  - [[A], [B]]         matches topic A in first position, B in second position
   136        #  - [[A, B]], [C, D]]  matches topic (A OR B) in first position, (C OR D) in second position
   137          topics: [[Bytes32!]!]
   138      }
   139  
   140      # Block is an Core block.
   141      type Block {
   142          # Number is the number of this block, starting at 0 for the genesis block.
   143          number: Long!
   144          # Hash is the block hash of this block.
   145          hash: Bytes32!
   146          # Parent is the parent block of this block.
   147          parent: Block
   148          # Nonce is the block nonce, an 8 byte sequence determined by the miner.
   149          nonce: Bytes!
   150          # TransactionsRoot is the SHA3 hash of the root of the trie of transactions in this block.
   151          transactionsRoot: Bytes32!
   152          # TransactionCount is the number of transactions in this block. if
   153          # transactions are not available for this block, this field will be null.
   154          transactionCount: Int
   155          # StateRoot is the SHA3 hash of the state trie after this block was processed.
   156          stateRoot: Bytes32!
   157          # ReceiptsRoot is the SHA3 hash of the trie of transaction receipts in this block.
   158          receiptsRoot: Bytes32!
   159          # Miner is the account that mined this block.
   160          miner(block: Long): Account!
   161          # ExtraData is an arbitrary data field supplied by the miner.
   162          extraData: Bytes!
   163          # EnergyLimit is the maximum amount of energy that was available to transactions in this block.
   164          energyLimit: Long!
   165          # EnergyUsed is the amount of energy that was used executing transactions in this block.
   166          energyUsed: Long!
   167          # Timestamp is the unix timestamp at which this block was mined.
   168          timestamp: Long!
   169          # LogsBloom is a bloom filter that can be used to check if a block may
   170          # contain log entries matching a filter.
   171          logsBloom: Bytes!
   172          # Difficulty is a measure of the difficulty of mining this block.
   173          difficulty: BigInt!
   174          # TotalDifficulty is the sum of all difficulty values up to and including
   175          # this block.
   176          totalDifficulty: BigInt!
   177          # OmmerCount is the number of ommers (AKA uncles) associated with this
   178          # block. If ommers are unavailable, this field will be null.
   179          ommerCount: Int
   180          # Ommers is a list of ommer (AKA uncle) blocks associated with this block.
   181          # If ommers are unavailable, this field will be null. Depending on your
   182          # node, the transactions, transactionAt, transactionCount, ommers,
   183          # ommerCount and ommerAt fields may not be available on any ommer blocks.
   184          ommers: [Block]
   185          # OmmerAt returns the ommer (AKA uncle) at the specified index. If ommers
   186          # are unavailable, or the index is out of bounds, this field will be null.
   187          ommerAt(index: Int!): Block
   188          # OmmerHash is the SHA3 hash of all the ommers (AKA uncles)
   189          # associated with this block.
   190          ommerHash: Bytes32!
   191          # Transactions is a list of transactions associated with this block. If
   192          # transactions are unavailable for this block, this field will be null.
   193          transactions: [Transaction!]
   194          # TransactionAt returns the transaction at the specified index. If
   195          # transactions are unavailable for this block, or if the index is out of
   196          # bounds, this field will be null.
   197          transactionAt(index: Int!): Transaction
   198          # Logs returns a filtered set of logs from this block.
   199          logs(filter: BlockFilterCriteria!): [Log!]!
   200          # Account fetches an Core account at the current block's state.
   201          account(address: Address!): Account!
   202          # Call executes a local call operation at the current block's state.
   203          call(data: CallData!): CallResult
   204          # EstimateEnergy estimates the amount of energy that will be required for
   205          # successful execution of a transaction at the current block's state.
   206          estimateEnergy(data: CallData!): Long!
   207      }
   208  
   209      # CallData represents the data associated with a local contract call.
   210      # All fields are optional.
   211      input CallData {
   212          # From is the address making the call.
   213          from: Address
   214          # To is the address the call is sent to.
   215          to: Address
   216          # Energy is the amount of energy sent with the call.
   217          energy: Long
   218          # EnergyPrice is the price, in ore, offered for each unit of energy.
   219          energyPrice: BigInt
   220          # Value is the value, in ore, sent along with the call.
   221          value: BigInt
   222          # Data is the data sent to the callee.
   223          data: Bytes
   224      }
   225  
   226      # CallResult is the result of a local call operation.
   227      type CallResult {
   228          # Data is the return data of the called contract.
   229          data: Bytes!
   230          # EnergyUsed is the amount of energy used by the call, after any refunds.
   231          energyUsed: Long!
   232          # Status is the result of the call - 1 for success or 0 for failure.
   233          status: Long!
   234      }
   235  
   236      # FilterCriteria encapsulates log filter criteria for searching log entries.
   237      input FilterCriteria {
   238          # FromBlock is the block at which to start searching, inclusive. Defaults
   239          # to the latest block if not supplied.
   240          fromBlock: Long
   241          # ToBlock is the block at which to stop searching, inclusive. Defaults
   242          # to the latest block if not supplied.
   243          toBlock: Long
   244          # Addresses is a list of addresses that are of interest. If this list is
   245          # empty, results will not be filtered by address.
   246          addresses: [Address!]
   247          # Topics list restricts matches to particular event topics. Each event has a list
   248        # of topics. Topics matches a prefix of that list. An empty element array matches any
   249        # topic. Non-empty elements represent an alternative that matches any of the
   250        # contained topics.
   251        #
   252        # Examples:
   253        #  - [] or nil          matches any topic list
   254        #  - [[A]]              matches topic A in first position
   255        #  - [[], [B]]          matches any topic in first position, B in second position
   256        #  - [[A], [B]]         matches topic A in first position, B in second position
   257        #  - [[A, B]], [C, D]]  matches topic (A OR B) in first position, (C OR D) in second position
   258          topics: [[Bytes32!]!]
   259      }
   260  
   261      # SyncState contains the current synchronisation state of the client.
   262      type SyncState{
   263          # StartingBlock is the block number at which synchronisation started.
   264          startingBlock: Long!
   265          # CurrentBlock is the point at which synchronisation has presently reached.
   266          currentBlock: Long!
   267          # HighestBlock is the latest known block number.
   268          highestBlock: Long!
   269          # PulledStates is the number of state entries fetched so far, or null
   270          # if this is not known or not relevant.
   271          pulledStates: Long
   272          # KnownStates is the number of states the node knows of so far, or null
   273          # if this is not known or not relevant.
   274          knownStates: Long
   275      }
   276  
   277      # Pending represents the current pending state.
   278      type Pending {
   279        # TransactionCount is the number of transactions in the pending state.
   280        transactionCount: Int!
   281        # Transactions is a list of transactions in the current pending state.
   282        transactions: [Transaction!]
   283        # Account fetches an Core account for the pending state.
   284        account(address: Address!): Account!
   285        # Call executes a local call operation for the pending state.
   286        call(data: CallData!): CallResult
   287        # EstimateEnergy estimates the amount of energy that will be required for
   288        # successful execution of a transaction for the pending state.
   289        estimateEnergy(data: CallData!): Long!
   290      }
   291  
   292      type Query {
   293          # Block fetches an Core block by number or by hash. If neither is
   294          # supplied, the most recent known block is returned.
   295          block(number: Long, hash: Bytes32): Block
   296          # Blocks returns all the blocks between two numbers, inclusive. If
   297          # to is not supplied, it defaults to the most recent known block.
   298          blocks(from: Long!, to: Long): [Block!]!
   299          # Pending returns the current pending state.
   300          pending: Pending!
   301          # Transaction returns a transaction specified by its hash.
   302          transaction(hash: Bytes32!): Transaction
   303          # Logs returns log entries matching the provided filter.
   304          logs(filter: FilterCriteria!): [Log!]!
   305          # EnergyPrice returns the node's estimate of a energy price sufficient to
   306          # ensure a transaction is mined in a timely fashion.
   307          energyPrice: BigInt!
   308          # ProtocolVersion returns the current wire protocol version number.
   309          protocolVersion: Int!
   310          # Syncing returns information on the current synchronisation state.
   311          syncing: SyncState
   312          # NetworkID returns the current chain ID for transaction replay protection.
   313          networkID: BigInt!
   314      }
   315  
   316      type Mutation {
   317          # SendRawTransaction sends an RLP-encoded transaction to the network.
   318          sendRawTransaction(data: Bytes!): Bytes32!
   319      }
   320  `