diff --git a/blockchain-watcher/config/default.json b/blockchain-watcher/config/default.json index a7a12e91..d7a21f61 100644 --- a/blockchain-watcher/config/default.json +++ b/blockchain-watcher/config/default.json @@ -201,7 +201,7 @@ "wormchain": { "name": "wormchain", "network": "testnet", - "chainId": 0, + "chainId": 3104, "rpcs": ["https://wormchain-testnet.jumpisolated.com"], "timeout": 10000 } diff --git a/blockchain-watcher/src/domain/actions/wormchain/GetWormchainLogs.ts b/blockchain-watcher/src/domain/actions/wormchain/GetWormchainLogs.ts index 6caaa2e4..4adade61 100644 --- a/blockchain-watcher/src/domain/actions/wormchain/GetWormchainLogs.ts +++ b/blockchain-watcher/src/domain/actions/wormchain/GetWormchainLogs.ts @@ -7,8 +7,8 @@ export class GetWormchainLogs { protected readonly logger: winston.Logger; constructor(blockRepo: WormchainRepository) { - this.blockRepo = blockRepo; this.logger = winston.child({ module: "GetWormchainLogs" }); + this.blockRepo = blockRepo; } async execute(range: Range, opts: GetWormchainOpts): Promise { @@ -51,9 +51,9 @@ type Range = { type TopicFilter = string | string[]; type GetWormchainOpts = { + environment: string; addresses?: string[]; topics?: TopicFilter[]; - chain: string; chainId: number; - environment: string; + chain: string; }; diff --git a/blockchain-watcher/src/domain/actions/wormchain/HandleWormchainLogs.ts b/blockchain-watcher/src/domain/actions/wormchain/HandleWormchainLogs.ts index 302224cd..a5cd0e17 100644 --- a/blockchain-watcher/src/domain/actions/wormchain/HandleWormchainLogs.ts +++ b/blockchain-watcher/src/domain/actions/wormchain/HandleWormchainLogs.ts @@ -29,9 +29,9 @@ export class HandleWormchainLogs { private report() { const labels = { - job: this.cfg.id, - chain: "wormchain", commitment: "immediate", + chain: "wormchain", + job: this.cfg.id, }; this.statsRepo.count(this.cfg.metricName, labels); } diff --git a/blockchain-watcher/src/domain/actions/wormchain/PollWormchain.ts b/blockchain-watcher/src/domain/actions/wormchain/PollWormchain.ts index 5fd0ea38..1c767806 100644 --- a/blockchain-watcher/src/domain/actions/wormchain/PollWormchain.ts +++ b/blockchain-watcher/src/domain/actions/wormchain/PollWormchain.ts @@ -8,15 +8,15 @@ const ID = "watch-wormchain-logs"; export class PollWormchain extends RunPollingJob { protected readonly logger: winston.Logger; - private readonly blockRepo: WormchainRepository; private readonly metadataRepo: MetadataRepository; - private readonly statsRepo: StatRepository; private readonly getWormchain: GetWormchainLogs; + private readonly blockRepo: WormchainRepository; + private readonly statsRepo: StatRepository; - private cfg: PollWormchainLogsConfig; private latestBlockHeight?: bigint; private blockHeightCursor?: bigint; private lastRange?: { fromBlock: bigint; toBlock: bigint }; + private cfg: PollWormchainLogsConfig; private getWormchainRecords: { [key: string]: any } = { GetWormchainLogs, }; @@ -56,7 +56,7 @@ export class PollWormchain extends RunPollingJob { } protected async get(): Promise { - const latestBlockHeight = await this.blockRepo.getBlockHeight(this.cfg.getCommitment()); + const latestBlockHeight = await this.blockRepo.getBlockHeight(); if (!latestBlockHeight) { throw new Error(`Could not obtain latest block height: ${latestBlockHeight}`); @@ -136,17 +136,17 @@ export type PollWormchainLogsMetadata = { }; export interface PollWormchainLogsConfigProps { - fromBlock?: bigint; - toBlock?: bigint; blockBatchSize?: number; - commitment?: string; - interval?: number; - addresses: string[]; - topics: (string | string[])[]; - id?: string; - chain: string; - chainId: number; environment: string; + commitment?: string; + fromBlock?: bigint; + addresses: string[]; + interval?: number; + toBlock?: bigint; + chainId: number; + topics: (string | string[])[]; + chain: string; + id?: string; } export class PollWormchainLogsConfig { @@ -223,7 +223,7 @@ export class PollWormchainLogsConfig { addresses: [], topics: [], environment: "", - chainId: 0, + chainId: 3104, }); } } diff --git a/blockchain-watcher/src/domain/entities/wormchain.ts b/blockchain-watcher/src/domain/entities/wormchain.ts index 0904b579..bd93736f 100644 --- a/blockchain-watcher/src/domain/entities/wormchain.ts +++ b/blockchain-watcher/src/domain/entities/wormchain.ts @@ -5,9 +5,9 @@ export type WormchainLog = { hash: string; type: string; attributes: { - key: string; - value: string; index: boolean; + value: string; + key: string; }[]; }[]; }; diff --git a/blockchain-watcher/src/domain/repositories.ts b/blockchain-watcher/src/domain/repositories.ts index cf342b5c..8c5ee753 100644 --- a/blockchain-watcher/src/domain/repositories.ts +++ b/blockchain-watcher/src/domain/repositories.ts @@ -84,7 +84,7 @@ export interface AptosRepository { } export interface WormchainRepository { - getBlockHeight(finality: string): Promise; + getBlockHeight(): Promise; getBlockLogs(blockNumber: bigint): Promise; } diff --git a/blockchain-watcher/src/infrastructure/mappers/wormchain/wormchainLogMessagePublishedMapper.ts b/blockchain-watcher/src/infrastructure/mappers/wormchain/wormchainLogMessagePublishedMapper.ts index fb194b55..de14d4cd 100644 --- a/blockchain-watcher/src/infrastructure/mappers/wormchain/wormchainLogMessagePublishedMapper.ts +++ b/blockchain-watcher/src/infrastructure/mappers/wormchain/wormchainLogMessagePublishedMapper.ts @@ -21,7 +21,7 @@ export const wormchainLogMessagePublishedMapper = ( return { name: "log-message-published", address: CORE_ADDRESS, - chainId: 0, + chainId: 3104, txHash: hash, blockHeight: log.blockHeight, blockTime: log.timestamp, diff --git a/blockchain-watcher/src/infrastructure/repositories/wormchain/RateLimitedWormchainJsonRPCBlockRepository.ts b/blockchain-watcher/src/infrastructure/repositories/wormchain/RateLimitedWormchainJsonRPCBlockRepository.ts index b3f6f989..bb845d3d 100644 --- a/blockchain-watcher/src/infrastructure/repositories/wormchain/RateLimitedWormchainJsonRPCBlockRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/wormchain/RateLimitedWormchainJsonRPCBlockRepository.ts @@ -12,8 +12,8 @@ export class RateLimitedWormchainJsonRPCBlockRepository this.logger = winston.child({ module: "RateLimitedWormchainJsonRPCBlockRepository" }); } - getBlockHeight(finality: string): Promise { - return this.breaker.fn(() => this.delegate.getBlockHeight(finality)).execute(); + getBlockHeight(): Promise { + return this.breaker.fn(() => this.delegate.getBlockHeight()).execute(); } getBlockLogs(blockNumber: bigint): Promise { diff --git a/blockchain-watcher/src/infrastructure/repositories/wormchain/WormchainJsonRPCBlockRepository.ts b/blockchain-watcher/src/infrastructure/repositories/wormchain/WormchainJsonRPCBlockRepository.ts index 9ce9c4ad..3db77b98 100644 --- a/blockchain-watcher/src/infrastructure/repositories/wormchain/WormchainJsonRPCBlockRepository.ts +++ b/blockchain-watcher/src/infrastructure/repositories/wormchain/WormchainJsonRPCBlockRepository.ts @@ -18,7 +18,7 @@ export class WormchainJsonRPCBlockRepository implements WormchainRepository { this.pool = pool; } - async getBlockHeight(finality: string): Promise { + async getBlockHeight(): Promise { try { const endpoint = `/abci_info`; let results: ResultBlockHeight; @@ -66,6 +66,7 @@ export class WormchainJsonRPCBlockRepository implements WormchainRepository { let resultTransaction: ResultTransaction; const hash: string = this.hexToHash(hashBatch); const txEndpoint = `/tx?hash=0x${hash}`; + resultTransaction = await this.pool .get() .get({ endpoint: txEndpoint }); diff --git a/blockchain-watcher/test/domain/actions/wormchain/GetWormchainLogs.test.ts b/blockchain-watcher/test/domain/actions/wormchain/GetWormchainLogs.test.ts index 8dbf1915..245b8a04 100644 --- a/blockchain-watcher/test/domain/actions/wormchain/GetWormchainLogs.test.ts +++ b/blockchain-watcher/test/domain/actions/wormchain/GetWormchainLogs.test.ts @@ -37,7 +37,7 @@ let props = { addresses: ["wormhole1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqqaqfk2j"], interval: 5000, topics: [], - chainId: 0, // TODO: Change to the correct chainId + chainId: 3104, filter: { address: "wormhole1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqqaqfk2j", }, diff --git a/blockchain-watcher/test/domain/actions/wormchain/HandleWormchainLogs.test.ts b/blockchain-watcher/test/domain/actions/wormchain/HandleWormchainLogs.test.ts index cbaf6360..be531f63 100644 --- a/blockchain-watcher/test/domain/actions/wormchain/HandleWormchainLogs.test.ts +++ b/blockchain-watcher/test/domain/actions/wormchain/HandleWormchainLogs.test.ts @@ -29,7 +29,7 @@ describe("HandleWormchainLogs", () => { // Then expect(result).toHaveLength(1); expect(result[0].name).toBe("log-message-published"); - expect(result[0].chainId).toBe(0); // TODO: check this attribute + expect(result[0].chainId).toBe(3104); expect(result[0].txHash).toBe( "0x7f61bf387fdb700d32d2b40ccecfb70ae46a2f82775242d04202bb7a538667c6" ); @@ -43,12 +43,12 @@ const mapper = (tx: WormchainLog) => { return { name: "log-message-published", address: "wormhole1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqqaqfk2j", - chainId: 0, // TODO: check this attribute + chainId: 3104, txHash: "0x7f61bf387fdb700d32d2b40ccecfb70ae46a2f82775242d04202bb7a538667c6", blockHeight: 153549311n, blockTime: 1709645685704036, attributes: { - sender: "wormhole1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqqaqfk2j", // TODO: check this attribute + sender: "wormhole1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqqaqfk2j", sequence: 203, payload: "", nonce: 75952, diff --git a/blockchain-watcher/test/mocks/configMock.ts b/blockchain-watcher/test/mocks/configMock.ts index 2fa94540..d8b7212d 100644 --- a/blockchain-watcher/test/mocks/configMock.ts +++ b/blockchain-watcher/test/mocks/configMock.ts @@ -153,7 +153,7 @@ export const configMock = (): Config => { wormchain: { name: "wormchain", network: "testnet", - chainId: 0, // TODO: check this attribute + chainId: 3104, rpcs: ["http://localhost"], timeout: 10000, }, diff --git a/deploy/blockchain-watcher/workers/source-events-2.yaml b/deploy/blockchain-watcher/workers/source-events-2.yaml index ab3c6174..0f49d46e 100644 --- a/deploy/blockchain-watcher/workers/source-events-2.yaml +++ b/deploy/blockchain-watcher/workers/source-events-2.yaml @@ -257,7 +257,7 @@ data: "interval": 5000, "addresses": ["wormhole16jzpxp0e8550c9aht6q9svcux30vtyyyyxv5w2l2djjra46580wsazcjwp"], "chain": "wormchain", - "chainId": 0 // TODO: Update chainId + "chainId": 3104 } }, "handlers": [ @@ -499,7 +499,7 @@ data: "interval": 5000, "addresses": ["wormhole1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqqaqfk2j"], "chain": "wormchain", - "chainId": 0 // TODO: Update chainId + "chainId": 3104 } }, "handlers": [