Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change postgraphile queries to work with v3 schema #112

Merged
merged 1 commit into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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