Skip to content

Commit

Permalink
fix sendBlockDelayLog
Browse files Browse the repository at this point in the history
  • Loading branch information
defi-dev committed Sep 27, 2023
1 parent d1f9065 commit b005f2f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions app/executors/AbstractExecutor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ethers } from 'ethers';
import { ContractWrapper, ExecutorConfig, IAgent, TxEnvelope } from '../Types.js';
import { getTxString, weiValueToGwei } from '../Utils.js';
import { getTxString } from '../Utils.js';
import { Network } from '../Network';
import axios from 'axios';

Expand All @@ -23,7 +23,7 @@ export abstract class AbstractExecutor {
protected queueHandlerLock: boolean;
protected lastTxKey: string;
protected lastTxEnvelope: TxEnvelope;
protected lastDelaySentAt;
protected lastDelaySentAtMs;

protected constructor(agentContract: ContractWrapper) {
this.agentContract = agentContract;
Expand Down Expand Up @@ -137,10 +137,10 @@ export abstract class AbstractExecutor {
}

async sendBlockDelayLog(agent: IAgent, delay, blockNumber) {
if (this.lastDelaySentAt && new Date().getTime() - this.lastDelaySentAt.getTime() < 60 * 1000) {
if (this.lastDelaySentAtMs && this.network.nowMs() - this.lastDelaySentAtMs < 60 * 1000) {
return;
}
this.lastDelaySentAt = new Date();
this.lastDelaySentAtMs = this.network.nowMs();

const types = {
Mail: [{ name: 'metadataJson', type: 'string' }],
Expand All @@ -150,14 +150,12 @@ export abstract class AbstractExecutor {
const blockData = {
metadataJson: JSON.stringify({
delay,
blockNumber,
keeperId: agent.keeperId,
rpc: networkStatusObj['rpc'],
blockNumber: Number(blockNumber),
agent: agent.address.toLowerCase(),
chainId: networkStatusObj['chainId'],
appVersion: this.network.getAppVersion(),
baseFeeGwei: weiValueToGwei(networkStatusObj['baseFee']),
maxPriorityFeeGwei: weiValueToGwei(BigInt(await this.network.getMaxPriorityFeePerGas().catch(() => 0))),
}),
};
const signature = await this.workerSigner._signTypedData({}, types, blockData);
Expand Down

0 comments on commit b005f2f

Please sign in to comment.