update env config, send alerts for SEND_ERROR code

This commit is contained in:
smart_ex 2022-07-05 20:35:20 +10:00
parent 0e1a9043be
commit 29fa454428
2 changed files with 6 additions and 6 deletions

View File

@ -6,12 +6,12 @@ import { version } from '../package.json';
config(); config();
const isProduction = process.env.NODE_ENV === 'production'; const isProduction = process.env.NODE_ENV === 'production';
export const relayerVersion = version; export const relayerVersion = version;
export const netId = <availableIds>Number(process.env.NET_ID || 1); export const netId = <availableIds>Number(process.env.NET_ID ?? 1);
export const redisUrl = process.env.REDIS_URL || 'redis://127.0.0.1:6379'; export const redisUrl = process.env.REDIS_URL || 'redis://127.0.0.1:6379';
export const rpcUrl = process.env.HTTP_RPC_URL; export const rpcUrl = process.env.HTTP_RPC_URL;
export const CONFIRMATIONS = Number(process.env.CONFIRMATIONS) || 4; export const CONFIRMATIONS = Number(process.env.CONFIRMATIONS ?? 4);
export const MAX_GAS_PRICE = Number(process.env.MAX_GAS_PRICE) || 1000; export const MAX_GAS_PRICE = Number(process.env.MAX_GAS_PRICE ?? 1000);
export const BASE_FEE_RESERVE_PERCENTAGE = Number(process.env.BASE_FEE_RESERVE_PERCENTAGE) || 25; export const BASE_FEE_RESERVE_PERCENTAGE = Number(process.env.BASE_FEE_RESERVE_PERCENTAGE ?? 25);
export const mainnetRpcUrl = process.env.MAINNET_RPC_URL || process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/'; export const mainnetRpcUrl = process.env.MAINNET_RPC_URL || process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/';
export const oracleRpcUrl = process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/'; export const oracleRpcUrl = process.env.ORACLE_RPC_URL || 'https://mainnet.infura.io/';
export const offchainOracleAddress = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb'; export const offchainOracleAddress = '0x07D91f5fb9Bf7798734C3f606dB065549F6893bb';

View File

@ -83,7 +83,7 @@ export class HealthService {
await this.store.client.zadd('errors:code', 'INCR', 1, e?.code || 'RUNTIME_ERROR'); await this.store.client.zadd('errors:code', 'INCR', 1, e?.code || 'RUNTIME_ERROR');
await this.store.client.zadd('errors:log', 'INCR', 1, e.message); await this.store.client.zadd('errors:log', 'INCR', 1, e.message);
if (e?.code === 'REVERTED') { if (e?.code === 'REVERTED' || e?.code === 'SEND_ERROR') {
const jobUrl = `${this.config.host}/v1/jobs/${jobId}`; const jobUrl = `${this.config.host}/v1/jobs/${jobId}`;
await this.pushAlert({ await this.pushAlert({
message: `${e.message} \n ${jobUrl}`, message: `${e.message} \n ${jobUrl}`,
@ -108,7 +108,7 @@ export class HealthService {
} else if (value.lt(this.config.balances[currency].warn)) { } else if (value.lt(this.config.balances[currency].warn)) {
level = 'WARN'; level = 'WARN';
} }
const msg = { WARN: 'Please refill your balance', CRITICAL: 'Insufficient balance' }; const msg = { WARN: 'Please refill your balance', CRITICAL: 'Insufficient balance', OK: 'ok' };
const alert = { const alert = {
type: `${type}_${currency}_${level}`, type: `${type}_${currency}_${level}`,
message: `${msg[level]} ${formatEther(value)} ${currency === 'MAIN' ? this.config.nativeCurrency : 'torn'}`, message: `${msg[level]} ${formatEther(value)} ${currency === 'MAIN' ? this.config.nativeCurrency : 'torn'}`,