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

feat: pool created handler #11

Merged
merged 8 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
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