Skip to content

Commit

Permalink
Change postgraphile queries to work with v3 schema
Browse files Browse the repository at this point in the history
  • Loading branch information
nikugogoi committed Apr 28, 2022
1 parent 654edf4 commit ff7c6d0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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`.
Expand Down
6 changes: 3 additions & 3 deletions packages/graph-node/src/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 1 addition & 2 deletions packages/ipld-eth-client/src/eth-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
);
Expand Down
5 changes: 2 additions & 3 deletions packages/ipld-eth-client/src/eth-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/util/src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ff7c6d0

Please sign in to comment.