Skip to content

Commit

Permalink
Add parachain
Browse files Browse the repository at this point in the history
Signed-off-by: KayleCoder <[email protected]>
  • Loading branch information
KayleCoder committed May 11, 2024
1 parent b016feb commit 2020085
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export enum EVMChainType {
POLYGON = 'polygon',
BASE = 'base',
BLAST = 'blast',
PARA = 'para',
};

export const EVMChain2Token = new Map<string,string>([
Expand All @@ -64,6 +65,7 @@ export const EVMChain2Token = new Map<string,string>([
[EVMChainType.POLYGON, 'matic'],
[EVMChainType.BASE, 'eth'],
[EVMChainType.BLAST, 'eth'],
[EVMChainType.PARA, 'eth'],
]);

export const CRUST_SEEDS = getParamOrExit("CRUST_SEEDS");
Expand Down Expand Up @@ -96,6 +98,11 @@ export const BLAST_ACCOUNT = getParamOrExitExcept("BLAST_ACCOUNT", BLAST_TASK_EN
export const BLAST_ENDPOINT_URL = getParamOrExitExcept("BLAST_ENDPOINT_URL", BLAST_TASK_ENABLE);
export const BLAST_STORAGE_CONTRACT_ADDRESS = getParamOrExitExcept("BLAST_STORAGE_CONTRACT_ADDRESS", BLAST_TASK_ENABLE);

export const PARA_CHAIN_TASK_ENABLE = process.env.PARA_CHAIN_TASK_ENABLE as string !== 'false';
export const PARA_CHAIN_ACCOUNT = getParamOrExitExcept("PARA_CHAIN_ACCOUNT", PARA_CHAIN_TASK_ENABLE);
export const PARA_CHAIN_ENDPOINT_URL = getParamOrExitExcept("PARA_CHAIN_ENDPOINT_URL", PARA_CHAIN_TASK_ENABLE);
export const PARA_CHAIN_STORAGE_CONTRACT_ADDRESS = getParamOrExitExcept("PARA_CHAIN_STORAGE_CONTRACT_ADDRESS", PARA_CHAIN_TASK_ENABLE);

export const ZKSYNC_TASK_ENABLE = process.env.ZKSYNC_TASK_ENABLE as string !== 'false';
export const ZKSYNC_ACCOUNT = getParamOrExitExcept("ZKSYNC_ACCOUNT", ZKSYNC_TASK_ENABLE);
export const ZKSYNC_ENDPOINT_URL = getParamOrExitExcept("ZKSYNC_ENDPOINT_URL", ZKSYNC_TASK_ENABLE);
Expand Down Expand Up @@ -147,6 +154,7 @@ export const EVMChain2RPC = new Map<string,string>([
[EVMChainType.POLYGON, POLYGON_ENDPOINT_URL],
[EVMChainType.BASE, BASE_ENDPOINT_URL],
[EVMChainType.BLAST, BLAST_ENDPOINT_URL],
[EVMChainType.PARA, PARA_CHAIN_ENDPOINT_URL],
]);

export const TRYOUT = 10;
Expand Down
44 changes: 44 additions & 0 deletions src/tasks/monitor-parachain.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { AppContext } from '../types/context';
import { Task } from '../types/tasks';
import { logger } from '../utils/logger';
import { makeIntervalTask, listenEVMOrderEvents } from './task-utils';
import {
STORAGE_ORDER_EVM_ABI,
STORAGE_ORDER_EVM_TOPICS,
EVMChainType,
BLAST_ACCOUNT,
BLAST_STORAGE_CONTRACT_ADDRESS,
BLAST_ENDPOINT_URL,
PARA_CHAIN_STORAGE_CONTRACT_ADDRESS,
PARA_CHAIN_ACCOUNT, PARA_CHAIN_ENDPOINT_URL
} from '../consts';

async function handleMonitorParaChain(
context: AppContext
): Promise<void> {
await listenEVMOrderEvents(
context,
PARA_CHAIN_ACCOUNT,
PARA_CHAIN_ENDPOINT_URL,
PARA_CHAIN_STORAGE_CONTRACT_ADDRESS,
STORAGE_ORDER_EVM_ABI,
STORAGE_ORDER_EVM_TOPICS,
EVMChainType.PARA,
);
}

export async function createMonitorParaChainTask(
context: AppContext
): Promise<Task> {
logger.info(`---> Blast contract address:${PARA_CHAIN_STORAGE_CONTRACT_ADDRESS}`);
logger.info(`---> Blast account:${PARA_CHAIN_ACCOUNT}`);
logger.info(`---> Blast endpoint:${PARA_CHAIN_ENDPOINT_URL}`);
const monitorInterval = 15 * 1000;
return makeIntervalTask(
monitorInterval,
monitorInterval,
'Monitor-parachain',
context,
handleMonitorParaChain,
);
}

0 comments on commit 2020085

Please sign in to comment.