watcher-ts/packages/ipld-eth-client/src/eth-queries.ts
prathamesh0 2517f110ea
Update GQL and getBlock API usage (#210)
* Update getLogs and getBlockWithTransactions usage to add block number arg

* Update getFullTransaction usage to add block number arg
2022-11-03 14:14:58 +05:30

139 lines
2.4 KiB
TypeScript

//
// Copyright 2021 Vulcanize, Inc.
//
import { gql } from '@apollo/client/core';
export const getStorageAt = gql`
query getStorageAt($blockHash: Bytes32!, $contract: Address!, $slot: Bytes32!) {
getStorageAt(blockHash: $blockHash, contract: $contract, slot: $slot) {
value
cid
ipldBlock
}
}
`;
export const getLogs = gql`
query getLogs($blockHash: Bytes32!, $blockNumber: BigInt, $addresses: [Address!]) {
getLogs(blockHash: $blockHash, blockNumber: $blockNumber, addresses: $addresses) {
account {
address
}
transaction {
hash
}
topics
data
index
cid
ipldBlock
receiptCID
status
}
}
`;
export const getBlockWithTransactions = gql`
query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) {
allEthHeaderCids(condition: { blockNumber: $blockNumber, blockHash: $blockHash }) {
nodes {
cid
blockNumber
blockHash
parentHash
timestamp
ethTransactionCidsByHeaderId {
nodes {
cid
txHash
index
src
dst
}
}
}
}
}
`;
export const getBlocks = gql`
query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) {
allEthHeaderCids(condition: { blockNumber: $blockNumber, blockHash: $blockHash }) {
nodes {
cid
blockNumber
blockHash
parentHash
timestamp
stateRoot
td
txRoot
receiptRoot
}
}
}
`;
export const getFullBlocks = gql`
query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) {
allEthHeaderCids(condition: { blockNumber: $blockNumber, blockHash: $blockHash }) {
nodes {
cid
blockNumber
blockHash
parentHash
timestamp
stateRoot
td
txRoot
receiptRoot
uncleRoot
bloom
blockByMhKey {
key
data
}
}
}
}
`;
export const getFullTransaction = gql`
query ethTransactionCidByTxHash($txHash: String!, $blockNumber: BigInt) {
ethTransactionCidByTxHash(txHash: $txHash, blockNumber: $blockNumber) {
cid
txHash
index
src
dst
blockByMhKey {
data
}
}
}
`;
export const getBlockByHash = gql`
query block($blockHash: Bytes32) {
block(hash: $blockHash) {
number
hash
parent {
hash
}
timestamp
}
}
`;
export default {
getStorageAt,
getLogs,
getBlockWithTransactions,
getBlocks,
getFullBlocks,
getFullTransaction,
getBlockByHash
};