Skip to content

Commit ebfb796

Browse files
committed
watcher: add Movement to testnet
1 parent 0041d46 commit ebfb796

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

watcher/src/consts.ts

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export const RPCS_BY_CHAIN: { [key in Network]: { [key in Chain]?: string } } =
112112
Monad: process.env.MONAD_RPC, // TODO: There is no Monad public endpoint.
113113
Ink: process.env.INK_RPC || 'https://rpc-qnd-sepolia.inkonchain.com',
114114
HyperEVM: process.env.HYPER_EVM_RPC || 'https://api.hyperliquid-testnet.xyz/evm',
115+
Movement: process.env.MOVEMENT_RPC || 'https://aptos.testnet.bardock.movementlabs.xyz/v1',
115116
},
116117
['Devnet']: {},
117118
};

watcher/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ const supportedChains: Chain[] =
6060
'Monad',
6161
'Ink',
6262
// 'HyperEVM',
63+
'Movement',
6364
]
6465
: [
6566
// This is the list of chains supported in MAINNET.

watcher/src/watchers/AptosWatcher.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { VaasByBlock } from '../databases/types';
66
import { makeVaaKey } from '../databases/utils';
77
import { AptosEvent } from '../types/aptos';
88
import { Watcher } from './Watcher';
9-
import { Network, contracts } from '@wormhole-foundation/sdk-base';
9+
import { Chain, Network, contracts } from '@wormhole-foundation/sdk-base';
1010

1111
const APTOS_FIELD_NAME = 'event';
1212

@@ -20,10 +20,14 @@ export class AptosWatcher extends Watcher {
2020
coreBridgeAddress: string;
2121
eventHandle: string;
2222

23-
constructor(network: Network) {
24-
super(network, 'Aptos', 'vaa');
23+
constructor(network: Network, chain: Chain) {
24+
super(network, chain, 'vaa');
2525
this.client = new AptosClient(RPCS_BY_CHAIN[this.network][this.chain]!);
26-
this.coreBridgeAddress = contracts.coreBridge(network, 'Aptos');
26+
const address = contracts.coreBridge.get(this.network, this.chain);
27+
if (!address) {
28+
throw new Error(`Core contract not defined for ${this.chain} on ${this.network}!`);
29+
}
30+
this.coreBridgeAddress = address;
2731
this.eventHandle = `${this.coreBridgeAddress}::state::WormholeMessageHandle`;
2832
}
2933

@@ -75,9 +79,8 @@ export class AptosWatcher extends Watcher {
7579
const initialSequence = z
7680
.number()
7781
.int()
78-
.parse(Number(INITIAL_DEPLOYMENT_BLOCK_BY_NETWORK_AND_CHAIN[this.network].Aptos));
82+
.parse(Number(INITIAL_DEPLOYMENT_BLOCK_BY_NETWORK_AND_CHAIN[this.network][this.chain]));
7983
return (
80-
z.number().int().parse(Number(block)) > 1094390 && // initial deployment block
8184
Date.parse(z.string().datetime().parse(timestamp)) < Date.now() &&
8285
z.number().int().parse(Number(sequence)) >= initialSequence // initial deployment sequence
8386
);

watcher/src/watchers/__tests__/AptosWatcher.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ const INITAL_SEQUENCE_NUMBER = Number(
99
);
1010

1111
test('getFinalizedSequenceNumber', async () => {
12-
const watcher = new AptosWatcher('Mainnet');
12+
const watcher = new AptosWatcher('Mainnet', 'Aptos');
1313
const blockNumber = await watcher.getFinalizedBlockNumber();
1414
expect(blockNumber).toBeGreaterThan(INITAL_SEQUENCE_NUMBER);
1515
});
1616

1717
test('getMessagesForSequenceNumbers', async () => {
18-
const watcher = new AptosWatcher('Mainnet');
18+
const watcher = new AptosWatcher('Mainnet', 'Aptos');
1919
const { vaasByBlock: messages } = await watcher.getMessagesForBlocks(0, 1);
2020
expect(messages).toMatchObject({
2121
'1095891/2022-10-19T00:55:54.676Z/0': [

watcher/src/watchers/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ export function makeFinalizedVaaWatcher(network: Network, chainName: Chain): Wat
5050
return new VAAWatcher(network, chainName, 'latest');
5151
} else if (chainName === 'Algorand') {
5252
return new AlgorandWatcher(network);
53-
} else if (chainName === 'Aptos') {
54-
return new AptosWatcher(network);
53+
} else if (chainName === 'Aptos' || chainName === 'Movement') {
54+
return new AptosWatcher(network, chainName);
5555
} else if (chainName === 'Injective') {
5656
return new InjectiveExplorerWatcher(network);
5757
} else if (chainName === 'Near') {

0 commit comments

Comments
 (0)