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

watcher: add Movement to testnet #415

Merged
merged 1 commit into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions watcher/src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']: {},
};
Expand Down
1 change: 1 addition & 0 deletions watcher/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const supportedChains: Chain[] =
'Monad',
'Ink',
// 'HyperEVM',
'Movement',
]
: [
// This is the list of chains supported in MAINNET.
Expand Down
15 changes: 9 additions & 6 deletions watcher/src/watchers/AptosWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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`;
}

Expand Down Expand Up @@ -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
);
Expand Down
4 changes: 2 additions & 2 deletions watcher/src/watchers/__tests__/AptosWatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': [
Expand Down
4 changes: 2 additions & 2 deletions watcher/src/watchers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
Loading