Set chainId for wormchain
This commit is contained in:
parent
6e97d96497
commit
c03dc0fe68
|
@ -201,7 +201,7 @@
|
|||
"wormchain": {
|
||||
"name": "wormchain",
|
||||
"network": "testnet",
|
||||
"chainId": 0,
|
||||
"chainId": 3104,
|
||||
"rpcs": ["https://wormchain-testnet.jumpisolated.com"],
|
||||
"timeout": 10000
|
||||
}
|
||||
|
|
|
@ -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<WormchainLog[]> {
|
||||
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<PollWormchainLogsMetadata>;
|
||||
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<any[]> {
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,9 @@ export type WormchainLog = {
|
|||
hash: string;
|
||||
type: string;
|
||||
attributes: {
|
||||
key: string;
|
||||
value: string;
|
||||
index: boolean;
|
||||
value: string;
|
||||
key: string;
|
||||
}[];
|
||||
}[];
|
||||
};
|
||||
|
|
|
@ -84,7 +84,7 @@ export interface AptosRepository {
|
|||
}
|
||||
|
||||
export interface WormchainRepository {
|
||||
getBlockHeight(finality: string): Promise<bigint | undefined>;
|
||||
getBlockHeight(): Promise<bigint | undefined>;
|
||||
getBlockLogs(blockNumber: bigint): Promise<any>;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -12,8 +12,8 @@ export class RateLimitedWormchainJsonRPCBlockRepository
|
|||
this.logger = winston.child({ module: "RateLimitedWormchainJsonRPCBlockRepository" });
|
||||
}
|
||||
|
||||
getBlockHeight(finality: string): Promise<bigint | undefined> {
|
||||
return this.breaker.fn(() => this.delegate.getBlockHeight(finality)).execute();
|
||||
getBlockHeight(): Promise<bigint | undefined> {
|
||||
return this.breaker.fn(() => this.delegate.getBlockHeight()).execute();
|
||||
}
|
||||
|
||||
getBlockLogs(blockNumber: bigint): Promise<any> {
|
||||
|
|
|
@ -18,7 +18,7 @@ export class WormchainJsonRPCBlockRepository implements WormchainRepository {
|
|||
this.pool = pool;
|
||||
}
|
||||
|
||||
async getBlockHeight(finality: string): Promise<bigint | undefined> {
|
||||
async getBlockHeight(): Promise<bigint | undefined> {
|
||||
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<typeof resultTransaction>({ endpoint: txEndpoint });
|
||||
|
|
|
@ -37,7 +37,7 @@ let props = {
|
|||
addresses: ["wormhole1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqqaqfk2j"],
|
||||
interval: 5000,
|
||||
topics: [],
|
||||
chainId: 0, // TODO: Change to the correct chainId
|
||||
chainId: 3104,
|
||||
filter: {
|
||||
address: "wormhole1ufs3tlq4umljk0qfe8k5ya0x6hpavn897u2cnf9k0en9jr7qarqqaqfk2j",
|
||||
},
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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": [
|
||||
|
|
Loading…
Reference in New Issue