Skip to content

Commit

Permalink
feat: pool created handler (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnigir1 authored Oct 18, 2024
1 parent 24ce18e commit f585a86
Show file tree
Hide file tree
Showing 46 changed files with 4,675 additions and 17 deletions.
6 changes: 6 additions & 0 deletions apps/indexer/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
name: Allo Indexer
unordered_multichain_mode: true
raw_events: true

field_selection:
transaction_fields:
- "hash"
- "transactionIndex"
- "from"
##########################
# CONTRACTS #
##########################
Expand Down
5 changes: 5 additions & 0 deletions packages/chain-providers/src/providers/evmProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
fallback,
FallbackTransport,
GetBlockReturnType,
GetTransactionReturnType,
Hex,
http,
HttpTransport,
Expand Down Expand Up @@ -65,6 +66,10 @@ export class EvmProvider {
return this.chain?.contracts?.multicall3?.address;
}

async getTransaction(hash: Hex): Promise<GetTransactionReturnType> {
return this.client.getTransaction({ hash });
}

/**
* Retrieves the balance of the specified address.
* @param {Address} address The address for which to retrieve the balance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import { arrayAbiFixture, structAbiFixture } from "../../fixtures/batchRequest.fixture.js";

const mockClient = {
getTransaction: vi.fn(),
getBalance: vi.fn(),
getBlockNumber: vi.fn(),
getGasPrice: vi.fn(),
Expand Down Expand Up @@ -70,6 +71,20 @@ describe("EvmProvider", () => {
}).toThrowError(RpcUrlsEmpty);
});

describe("getTransaction", () => {
it("returns the transaction for the given hash", async () => {
viemProvider = new EvmProvider(defaultRpcUrls, defaultMockChain, mockLogger);
const hash = "0x123456789";
const expectedTransaction = { from: "0x123456789", to: "0x987654321" };
vi.spyOn(mockClient, "getTransaction").mockResolvedValue(expectedTransaction);

const transaction = await viemProvider.getTransaction(hash);

expect(transaction).toBe(expectedTransaction);
expect(mockClient.getTransaction).toHaveBeenCalledWith({ hash });
});
});

describe("getBalance", () => {
it("returns the balance of the specified address", async () => {
viemProvider = new EvmProvider(defaultRpcUrls, defaultMockChain, mockLogger);
Expand Down
2 changes: 2 additions & 0 deletions packages/data-flow/test/unit/eventsFetcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("EventsFetcher", () => {
srcAddress: "0x1234567890123456789012345678901234567890",
logIndex: 0,
params: { contractAddress: "0x1234" },
transactionFields: { hash: "0x1234", transactionIndex: 0 },
},
{
chainId: 1,
Expand All @@ -38,6 +39,7 @@ describe("EventsFetcher", () => {
srcAddress: "0x1234567890123456789012345678901234567890",
logIndex: 0,
params: { contractAddress: "0x1234" },
transactionFields: { hash: "0x1234", transactionIndex: 1 },
},
];
const chainId = 1n;
Expand Down
4 changes: 3 additions & 1 deletion packages/processors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
"test:cov": "vitest run --config vitest.config.ts --coverage"
},
"dependencies": {
"@grants-stack-indexer/chain-providers": "workspace:*",
"@grants-stack-indexer/metadata": "workspace:*",
"@grants-stack-indexer/pricing": "workspace:*",
"@grants-stack-indexer/repository": "workspace:*",
"@grants-stack-indexer/shared": "workspace:*",
"viem": "2.21.19"
"viem": "2.21.19",
"zod": "3.23.8"
}
}
Loading

0 comments on commit f585a86

Please sign in to comment.