mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 12:26:19 +00:00
Change postgraphile queries to work with v3 schema (#112)
This commit is contained in:
parent
654edf4008
commit
eca09ad66b
10
README.md
10
README.md
@ -35,6 +35,12 @@ Install packages (Node.JS v16.13.1):
|
||||
yarn
|
||||
```
|
||||
|
||||
Build packages:
|
||||
|
||||
```bash
|
||||
yarn build
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
* [graph-node](./packages/graph-node/README.md)
|
||||
@ -53,6 +59,10 @@ The default config files used by the watchers assume the following services are
|
||||
|
||||
`chainConfig = "./chain.json" # ETH_CHAIN_CONFIG`
|
||||
|
||||
## Watchers
|
||||
|
||||
* [eden-watcher](./packages/eden-watcher/README.md)
|
||||
|
||||
## Databases
|
||||
|
||||
Note: Requires `postgres12`.
|
||||
|
@ -167,7 +167,7 @@ export class GraphWatcher {
|
||||
|
||||
const eventFragment = contractInterface.getEvent(eventSignature);
|
||||
|
||||
const tx = await this._getTransactionData(blockData.headerId, txHash);
|
||||
const tx = await this._getTransactionData(txHash);
|
||||
|
||||
const data = {
|
||||
block: blockData,
|
||||
@ -299,14 +299,14 @@ export class GraphWatcher {
|
||||
}
|
||||
}
|
||||
|
||||
async _getTransactionData (headerId: number, txHash: string): Promise<Transaction> {
|
||||
async _getTransactionData (txHash: string): Promise<Transaction> {
|
||||
let transaction = this._transactionsMap.get(txHash);
|
||||
|
||||
if (transaction) {
|
||||
return transaction;
|
||||
}
|
||||
|
||||
transaction = await getFullTransaction(this._postgraphileClient, headerId, txHash);
|
||||
transaction = await getFullTransaction(this._postgraphileClient, txHash);
|
||||
assert(transaction);
|
||||
this._transactionsMap.set(txHash, transaction);
|
||||
|
||||
|
@ -92,11 +92,10 @@ export class EthClient {
|
||||
);
|
||||
}
|
||||
|
||||
async getFullTransaction ({ headerId, txHash }: { headerId: number, txHash: string }): Promise<any> {
|
||||
async getFullTransaction (txHash: string): Promise<any> {
|
||||
return this._graphqlClient.query(
|
||||
ethQueries.getFullTransaction,
|
||||
{
|
||||
headerId,
|
||||
txHash
|
||||
}
|
||||
);
|
||||
|
@ -86,7 +86,6 @@ export const getFullBlocks = gql`
|
||||
query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) {
|
||||
allEthHeaderCids(condition: { blockNumber: $blockNumber, blockHash: $blockHash }) {
|
||||
nodes {
|
||||
id
|
||||
cid
|
||||
blockNumber
|
||||
blockHash
|
||||
@ -108,8 +107,8 @@ query allEthHeaderCids($blockNumber: BigInt, $blockHash: String) {
|
||||
`;
|
||||
|
||||
export const getFullTransaction = gql`
|
||||
query ethTransactionCidByHeaderIdAndTxHash($headerId: Int!, $txHash: String!) {
|
||||
ethTransactionCidByHeaderIdAndTxHash(headerId: $headerId, txHash: $txHash) {
|
||||
query ethTransactionCidByTxHash($txHash: String!) {
|
||||
ethTransactionCidByTxHash(txHash: $txHash) {
|
||||
cid
|
||||
txHash
|
||||
index
|
||||
|
@ -213,10 +213,10 @@ export const getFullBlock = async (ethClient: EthClient, ethProvider: providers.
|
||||
};
|
||||
};
|
||||
|
||||
export const getFullTransaction = async (ethClient: EthClient, headerId: number, txHash: string): Promise<any> => {
|
||||
export const getFullTransaction = async (ethClient: EthClient, txHash: string): Promise<any> => {
|
||||
const {
|
||||
ethTransactionCidByHeaderIdAndTxHash: fullTx
|
||||
} = await ethClient.getFullTransaction({ headerId, txHash });
|
||||
ethTransactionCidByTxHash: fullTx
|
||||
} = await ethClient.getFullTransaction(txHash);
|
||||
|
||||
assert(fullTx.blockByMhKey);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user