2021-06-09 09:41:05 +00:00
|
|
|
import { gql } from '@apollo/client/core';
|
|
|
|
|
|
|
|
export default gql`
|
2021-05-11 11:02:04 +00:00
|
|
|
#
|
|
|
|
# ERC20 GQL schema
|
|
|
|
#
|
2021-06-01 12:43:41 +00:00
|
|
|
# See: https://eips.ethereum.org/EIPS/eip-20
|
|
|
|
# ABI: https://ethereumdev.io/abi-for-erc20-contract-on-ethereum/
|
|
|
|
#
|
2021-05-11 11:02:04 +00:00
|
|
|
|
|
|
|
# Types
|
|
|
|
|
|
|
|
# Support uint256 values.
|
|
|
|
scalar BigInt
|
|
|
|
|
|
|
|
# Proof for returned data. Serialized blob for now.
|
|
|
|
# Will be converted into a well defined structure later.
|
|
|
|
type Proof {
|
|
|
|
data: String!
|
|
|
|
}
|
|
|
|
|
2021-06-01 12:43:41 +00:00
|
|
|
# Result type, with proof, for string method return values.
|
|
|
|
type ResultString {
|
|
|
|
value: String
|
|
|
|
|
|
|
|
# Proof from state/storage trie.
|
|
|
|
proof: Proof
|
|
|
|
}
|
|
|
|
|
2021-05-11 11:02:04 +00:00
|
|
|
# Result type, with proof, for uint256 method return values.
|
|
|
|
type ResultUInt256 {
|
|
|
|
value: BigInt!
|
|
|
|
|
|
|
|
# Proof from state/storage trie.
|
|
|
|
proof: Proof
|
|
|
|
}
|
|
|
|
|
|
|
|
# Transfer Event
|
|
|
|
type TransferEvent {
|
|
|
|
from: String!
|
|
|
|
to: String!
|
|
|
|
value: BigInt!
|
|
|
|
}
|
|
|
|
|
|
|
|
# Approval Event
|
|
|
|
type ApprovalEvent {
|
|
|
|
owner: String!
|
|
|
|
spender: String!
|
|
|
|
value: BigInt!
|
2021-05-10 09:49:48 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 11:02:04 +00:00
|
|
|
# All possible event types fired by an ERC20 contract.
|
|
|
|
union TokenEvent = TransferEvent | ApprovalEvent
|
|
|
|
|
|
|
|
# Result type, with proof, for event return values.
|
|
|
|
type ResultEvent {
|
|
|
|
event: TokenEvent!
|
|
|
|
|
|
|
|
# Proof from receipts trie.
|
|
|
|
proof: Proof
|
2021-05-10 09:49:48 +00:00
|
|
|
}
|
|
|
|
|
2021-06-09 09:41:05 +00:00
|
|
|
# Watched event, include additional context over and above the event data.
|
|
|
|
type WatchedEvent {
|
|
|
|
blockHash: String!
|
|
|
|
token: String!
|
|
|
|
|
|
|
|
event: ResultEvent!
|
|
|
|
}
|
2021-05-11 11:02:04 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Queries
|
|
|
|
#
|
|
|
|
|
2021-05-10 09:49:48 +00:00
|
|
|
type Query {
|
2021-05-11 11:02:04 +00:00
|
|
|
|
2021-06-01 12:43:41 +00:00
|
|
|
#
|
|
|
|
# Interface of the ERC20 standard as defined in the EIP.
|
|
|
|
# https://docs.openzeppelin.com/contracts/2.x/api/token/erc20#IERC20
|
|
|
|
#
|
|
|
|
|
|
|
|
totalSupply(
|
|
|
|
blockHash: String!
|
|
|
|
token: String!
|
|
|
|
): ResultUInt256!
|
|
|
|
|
2021-05-11 11:02:04 +00:00
|
|
|
balanceOf(
|
|
|
|
blockHash: String!
|
|
|
|
token: String!
|
|
|
|
|
|
|
|
owner: String!
|
|
|
|
): ResultUInt256!
|
|
|
|
|
|
|
|
allowance(
|
|
|
|
blockHash: String!
|
|
|
|
token: String!
|
|
|
|
|
|
|
|
owner: String!
|
|
|
|
spender: String!
|
|
|
|
): ResultUInt256!
|
|
|
|
|
2021-06-01 12:43:41 +00:00
|
|
|
#
|
|
|
|
# Optional functions from the ERC20 standard.
|
|
|
|
# https://docs.openzeppelin.com/contracts/2.x/api/token/erc20#ERC20Detailed
|
|
|
|
#
|
|
|
|
|
|
|
|
name(
|
|
|
|
blockHash: String!
|
|
|
|
token: String!
|
|
|
|
): ResultString!
|
|
|
|
|
|
|
|
symbol(
|
|
|
|
blockHash: String!
|
|
|
|
token: String!
|
|
|
|
): ResultString!
|
|
|
|
|
|
|
|
decimals(
|
|
|
|
blockHash: String!
|
|
|
|
token: String!
|
|
|
|
): ResultUInt256!
|
|
|
|
|
|
|
|
#
|
|
|
|
# Additional watcher queries.
|
|
|
|
#
|
|
|
|
|
2021-05-11 11:02:04 +00:00
|
|
|
# Get token events at a certain block, optionally filter by event name.
|
|
|
|
events(
|
|
|
|
blockHash: String!
|
|
|
|
token: String!
|
|
|
|
name: String
|
|
|
|
): [ResultEvent!]
|
2021-05-10 09:49:48 +00:00
|
|
|
}
|
|
|
|
|
2021-05-11 11:02:04 +00:00
|
|
|
#
|
|
|
|
# Subscriptions
|
|
|
|
#
|
|
|
|
type Subscription {
|
|
|
|
|
|
|
|
# Watch for token events (at head of chain).
|
2021-06-09 09:41:05 +00:00
|
|
|
onTokenEvent: WatchedEvent!
|
2021-05-10 09:49:48 +00:00
|
|
|
}
|
2021-06-09 10:08:07 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Mutations
|
|
|
|
#
|
|
|
|
type Mutation {
|
|
|
|
|
|
|
|
# Actively watch and index data for the token.
|
|
|
|
watchToken(
|
|
|
|
token: String!
|
|
|
|
startingBlock: Int
|
|
|
|
): Boolean!
|
|
|
|
}
|
2021-06-09 09:41:05 +00:00
|
|
|
`;
|