mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-07 20:08:06 +00:00
Add boolean flag to enable sending L2 txs from watcher peer (#354)
This commit is contained in:
parent
754db311f0
commit
7dada71fa3
@ -33,6 +33,7 @@
|
|||||||
relayMultiaddr = ''
|
relayMultiaddr = ''
|
||||||
pubSubTopic = 'mobymask'
|
pubSubTopic = 'mobymask'
|
||||||
peerIdFile = ''
|
peerIdFile = ''
|
||||||
|
enableL2Txs = false
|
||||||
|
|
||||||
[server.p2p.peer.l2TxConfig]
|
[server.p2p.peer.l2TxConfig]
|
||||||
privateKey = ''
|
privateKey = ''
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import assert from 'assert';
|
||||||
import 'reflect-metadata';
|
import 'reflect-metadata';
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
import { ethers } from 'ethers';
|
import { ethers } from 'ethers';
|
||||||
@ -23,11 +24,12 @@ export const main = async (): Promise<any> => {
|
|||||||
await serverCmd.initIndexer(Indexer);
|
await serverCmd.initIndexer(Indexer);
|
||||||
|
|
||||||
let p2pMessageHandler = parseLibp2pMessage;
|
let p2pMessageHandler = parseLibp2pMessage;
|
||||||
const { l2TxConfig } = serverCmd.config.server.p2p.peer;
|
const { enableL2Txs, l2TxsConfig } = serverCmd.config.server.p2p.peer;
|
||||||
|
|
||||||
if (l2TxConfig) {
|
if (enableL2Txs) {
|
||||||
const wallet = new ethers.Wallet(l2TxConfig.privateKey, serverCmd.ethProvider);
|
assert(l2TxsConfig);
|
||||||
p2pMessageHandler = createMessageToL2Handler(wallet, l2TxConfig);
|
const wallet = new ethers.Wallet(l2TxsConfig.privateKey, serverCmd.ethProvider);
|
||||||
|
p2pMessageHandler = createMessageToL2Handler(wallet, l2TxsConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
const typeDefs = fs.readFileSync(path.join(__dirname, 'schema.gql')).toString();
|
||||||
|
@ -70,7 +70,7 @@ export interface RelayConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// L2 tx config
|
// L2 tx config
|
||||||
interface L2TxConfig {
|
interface L2TxsConfig {
|
||||||
// Address of contract for which txs are sent
|
// Address of contract for which txs are sent
|
||||||
contractAddress: string;
|
contractAddress: string;
|
||||||
|
|
||||||
@ -113,8 +113,11 @@ export interface PeerConfig {
|
|||||||
// Participate in exchange of debug info over floodsub
|
// Participate in exchange of debug info over floodsub
|
||||||
enableDebugInfo?: boolean;
|
enableDebugInfo?: boolean;
|
||||||
|
|
||||||
|
// Enable sending txs to L2 chain for every message received in P2P network
|
||||||
|
enableL2Txs: boolean;
|
||||||
|
|
||||||
// Config for sending txs to L2
|
// Config for sending txs to L2
|
||||||
l2TxConfig?: L2TxConfig;
|
l2TxsConfig?: L2TxsConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
// P2P config
|
// P2P config
|
||||||
|
Loading…
Reference in New Issue
Block a user