From 6816fa2165b4fdd0103c512a075b22b9c1796ae5 Mon Sep 17 00:00:00 2001 From: eaxeax Date: Thu, 28 Apr 2022 19:27:19 +0300 Subject: [PATCH 1/2] fix(provider): make ethers transaction record once --- src/providers.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/providers.ts b/src/providers.ts index 63ccc54..eff7c49 100644 --- a/src/providers.ts +++ b/src/providers.ts @@ -6,10 +6,14 @@ import { EthereumProvider, EIP1193Provider, RequestArguments } from "hardhat/typ */ export class EGRDataCollectionProvider extends ProviderWrapper { private mochaConfig: any; + private txs: Set; + private txsBlock: number; constructor(provider: EIP1193Provider, mochaConfig) { super(provider); this.mochaConfig = mochaConfig + this.txs = new Set(); + this.txsBlock = 0; } public async request(args: RequestArguments): Promise { @@ -21,6 +25,16 @@ export class EGRDataCollectionProvider extends ProviderWrapper { method: "eth_getTransactionByHash", params: [receipt.transactionHash] }); + + if (this.txsBlock != receipt.blockNumber) { + this.txsBlock = receipt.blockNumber; + this.txs.clear(); + } + + if (this.txs.has(receipt.transactionHash)) { + this.txs.add(receipt.transactionHash); + await this.mochaConfig.attachments.recordTransaction(receipt, tx); + } await this.mochaConfig.attachments.recordTransaction(receipt, tx); } return receipt; From 0420349648d4d13c947356194f813a64e577e833 Mon Sep 17 00:00:00 2001 From: eaxeax Date: Thu, 28 Apr 2022 19:29:16 +0300 Subject: [PATCH 2/2] unnecessary record removed --- src/providers.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/providers.ts b/src/providers.ts index eff7c49..3434cc9 100644 --- a/src/providers.ts +++ b/src/providers.ts @@ -35,7 +35,6 @@ export class EGRDataCollectionProvider extends ProviderWrapper { this.txs.add(receipt.transactionHash); await this.mochaConfig.attachments.recordTransaction(receipt, tx); } - await this.mochaConfig.attachments.recordTransaction(receipt, tx); } return receipt;