diff --git a/watcher/src/watchers/TerraExplorerWatcher.ts b/watcher/src/watchers/TerraExplorerWatcher.ts index 0debf68c..67aea2b9 100644 --- a/watcher/src/watchers/TerraExplorerWatcher.ts +++ b/watcher/src/watchers/TerraExplorerWatcher.ts @@ -21,16 +21,16 @@ export class TerraExplorerWatcher extends Watcher { if (!this.rpc) { throw new Error(`${this.chain} RPC is not defined!`); } - this.latestBlockTag = 'blocks/latest'; - this.getBlockTag = 'blocks/'; + this.latestBlockTag = 'v1/blocks/latest'; + this.getBlockTag = 'v1/blocks/'; this.allTxsTag = 'v1/txs?'; this.latestBlockHeight = 0; } async getFinalizedBlockNumber(): Promise { const result = (await axios.get(`${this.rpc}/${this.latestBlockTag}`, AXIOS_CONFIG_JSON)).data; - if (result && result.block.header.height) { - let blockHeight: number = parseInt(result.block.header.height); + if (result && result.height) { + let blockHeight: number = parseInt(result.height); if (blockHeight !== this.latestBlockHeight) { this.latestBlockHeight = blockHeight; this.logger.debug('blockHeight = ' + blockHeight); @@ -149,13 +149,13 @@ export class TerraExplorerWatcher extends Watcher { // become the new starting point for subsequent calls. this.logger.debug(`Adding filler for block ${toBlock}`); const blkUrl = `${this.rpc}/${this.getBlockTag}${toBlock}`; - const result: CosmwasmBlockResult = (await axios.get(blkUrl, AXIOS_CONFIG_JSON)).data; + const result: NewCosmwasmBlockResult = (await axios.get(blkUrl, AXIOS_CONFIG_JSON)).data; if (!result) { throw new Error(`Unable to get block information for block ${toBlock}`); } const blockKey = makeBlockKey( - result.block.header.height.toString(), - new Date(result.block.header.time).toISOString() + result.height.toString(), + new Date(result.timestamp).toISOString() ); vaasByBlock[blockKey] = []; } @@ -232,3 +232,27 @@ type CosmwasmBlockResult = { }; }; }; + +type NewCosmwasmBlockResult = { + chainId: string; //'columbus-5'; + height: number; //14520709; + timestamp: string; //'2023-09-13T13:38:23.081Z'; + proposer: { + moniker: string; //'ISS'; + identity: string; //''; + operatorAddress: string; //'terravaloper15khv8dsaxqmf7nwu4jdlp9slxl7aczte3x068c'; + }; + txs: [ + { + id: number; + tx: Object; + logs: Object[]; + height: string; + txhash: string; + raw_log: string; + gas_used: string; + timestamp: string; + gas_wanted: string; + } + ]; +}; diff --git a/watcher/src/watchers/__tests__/CosmwasmWatcher.test.ts b/watcher/src/watchers/__tests__/CosmwasmWatcher.test.ts index 392e54ef..7cfcfd64 100644 --- a/watcher/src/watchers/__tests__/CosmwasmWatcher.test.ts +++ b/watcher/src/watchers/__tests__/CosmwasmWatcher.test.ts @@ -72,18 +72,18 @@ test('getFinalizedBlockNumber(terra explorer)', async () => { }); // flaky rpc, skip -test.skip('getMessagesForBlocks(terra explorer)', async () => { +test('getMessagesForBlocks(terra explorer)', async () => { const watcher = new TerraExplorerWatcher('terra'); - const vaasByBlock = await watcher.getMessagesForBlocks(10974196, 10974197); + const vaasByBlock = await watcher.getMessagesForBlocks(14506733, 14506740); const entries = Object.entries(vaasByBlock); expect(entries.length).toEqual(2); expect(entries.filter(([block, vaas]) => vaas.length === 0).length).toEqual(1); expect(entries.filter(([block, vaas]) => vaas.length === 1).length).toEqual(1); expect(entries.filter(([block, vaas]) => vaas.length === 2).length).toEqual(0); - expect(vaasByBlock['10974196/2023-01-06T04:23:21.000Z']).toBeDefined(); - expect(vaasByBlock['10974196/2023-01-06T04:23:21.000Z'].length).toEqual(1); - expect(vaasByBlock['10974196/2023-01-06T04:23:21.000Z'][0]).toEqual( - '8A31CDE56ED3ACB7239D705949BD6C164747210A6C4C69D98756E0CF6D22C9EB:3/0000000000000000000000007cf7b764e38a0a5e967972c1df77d432510564e2/256813' + expect(vaasByBlock['14506733/2023-09-11T21:59:36.000Z']).toBeDefined(); + expect(vaasByBlock['14506733/2023-09-11T21:59:36.000Z'].length).toEqual(1); + expect(vaasByBlock['14506733/2023-09-11T21:59:36.000Z'][0]).toEqual( + 'A0A0161B162DCD23845C32022320C21862B08F8B16A23CD04C68EF3BCBCFCFE5:3/0000000000000000000000007cf7b764e38a0a5e967972c1df77d432510564e2/259253' ); }); diff --git a/watcher/src/watchers/__tests__/EVMWatcher.test.ts b/watcher/src/watchers/__tests__/EVMWatcher.test.ts index 6501d089..2cadd781 100644 --- a/watcher/src/watchers/__tests__/EVMWatcher.test.ts +++ b/watcher/src/watchers/__tests__/EVMWatcher.test.ts @@ -8,6 +8,8 @@ const initialCeloBlock = Number(INITIAL_DEPLOYMENT_BLOCK_BY_CHAIN.celo); const initialOasisBlock = Number(INITIAL_DEPLOYMENT_BLOCK_BY_CHAIN.oasis); const initialKaruraBlock = Number(INITIAL_DEPLOYMENT_BLOCK_BY_CHAIN.karura); +jest.setTimeout(30000); + test('getBlock by tag', async () => { const watcher = new EVMWatcher('avalanche'); const block = await watcher.getBlock('latest');