diff --git a/watcher/src/consts.ts b/watcher/src/consts.ts index 327b476d..2f633386 100644 --- a/watcher/src/consts.ts +++ b/watcher/src/consts.ts @@ -112,6 +112,7 @@ export const RPCS_BY_CHAIN: { [key in Network]: { [key in Chain]?: string } } = Monad: process.env.MONAD_RPC, // TODO: There is no Monad public endpoint. Ink: process.env.INK_RPC || 'https://rpc-qnd-sepolia.inkonchain.com', HyperEVM: process.env.HYPER_EVM_RPC || 'https://api.hyperliquid-testnet.xyz/evm', + Movement: process.env.MOVEMENT_RPC || 'https://aptos.testnet.bardock.movementlabs.xyz/v1', }, ['Devnet']: {}, }; diff --git a/watcher/src/index.ts b/watcher/src/index.ts index b1a74d1e..0d4126a5 100644 --- a/watcher/src/index.ts +++ b/watcher/src/index.ts @@ -60,6 +60,7 @@ const supportedChains: Chain[] = 'Monad', 'Ink', // 'HyperEVM', + 'Movement', ] : [ // This is the list of chains supported in MAINNET. diff --git a/watcher/src/watchers/AptosWatcher.ts b/watcher/src/watchers/AptosWatcher.ts index 5d71d775..947a361e 100644 --- a/watcher/src/watchers/AptosWatcher.ts +++ b/watcher/src/watchers/AptosWatcher.ts @@ -6,7 +6,7 @@ import { VaasByBlock } from '../databases/types'; import { makeVaaKey } from '../databases/utils'; import { AptosEvent } from '../types/aptos'; import { Watcher } from './Watcher'; -import { Network, contracts } from '@wormhole-foundation/sdk-base'; +import { Chain, Network, contracts } from '@wormhole-foundation/sdk-base'; const APTOS_FIELD_NAME = 'event'; @@ -20,10 +20,14 @@ export class AptosWatcher extends Watcher { coreBridgeAddress: string; eventHandle: string; - constructor(network: Network) { - super(network, 'Aptos', 'vaa'); + constructor(network: Network, chain: Chain) { + super(network, chain, 'vaa'); this.client = new AptosClient(RPCS_BY_CHAIN[this.network][this.chain]!); - this.coreBridgeAddress = contracts.coreBridge(network, 'Aptos'); + const address = contracts.coreBridge.get(this.network, this.chain); + if (!address) { + throw new Error(`Core contract not defined for ${this.chain} on ${this.network}!`); + } + this.coreBridgeAddress = address; this.eventHandle = `${this.coreBridgeAddress}::state::WormholeMessageHandle`; } @@ -75,9 +79,8 @@ export class AptosWatcher extends Watcher { const initialSequence = z .number() .int() - .parse(Number(INITIAL_DEPLOYMENT_BLOCK_BY_NETWORK_AND_CHAIN[this.network].Aptos)); + .parse(Number(INITIAL_DEPLOYMENT_BLOCK_BY_NETWORK_AND_CHAIN[this.network][this.chain])); return ( - z.number().int().parse(Number(block)) > 1094390 && // initial deployment block Date.parse(z.string().datetime().parse(timestamp)) < Date.now() && z.number().int().parse(Number(sequence)) >= initialSequence // initial deployment sequence ); diff --git a/watcher/src/watchers/__tests__/AptosWatcher.test.ts b/watcher/src/watchers/__tests__/AptosWatcher.test.ts index e553f01f..d468dd39 100644 --- a/watcher/src/watchers/__tests__/AptosWatcher.test.ts +++ b/watcher/src/watchers/__tests__/AptosWatcher.test.ts @@ -9,13 +9,13 @@ const INITAL_SEQUENCE_NUMBER = Number( ); test('getFinalizedSequenceNumber', async () => { - const watcher = new AptosWatcher('Mainnet'); + const watcher = new AptosWatcher('Mainnet', 'Aptos'); const blockNumber = await watcher.getFinalizedBlockNumber(); expect(blockNumber).toBeGreaterThan(INITAL_SEQUENCE_NUMBER); }); test('getMessagesForSequenceNumbers', async () => { - const watcher = new AptosWatcher('Mainnet'); + const watcher = new AptosWatcher('Mainnet', 'Aptos'); const { vaasByBlock: messages } = await watcher.getMessagesForBlocks(0, 1); expect(messages).toMatchObject({ '1095891/2022-10-19T00:55:54.676Z/0': [ diff --git a/watcher/src/watchers/utils.ts b/watcher/src/watchers/utils.ts index 9667f327..f10cf178 100644 --- a/watcher/src/watchers/utils.ts +++ b/watcher/src/watchers/utils.ts @@ -50,8 +50,8 @@ export function makeFinalizedVaaWatcher(network: Network, chainName: Chain): Wat return new VAAWatcher(network, chainName, 'latest'); } else if (chainName === 'Algorand') { return new AlgorandWatcher(network); - } else if (chainName === 'Aptos') { - return new AptosWatcher(network); + } else if (chainName === 'Aptos' || chainName === 'Movement') { + return new AptosWatcher(network, chainName); } else if (chainName === 'Injective') { return new InjectiveExplorerWatcher(network); } else if (chainName === 'Near') {