From e13bb8acfe25a55b0ceb60aa681a06d41d3e18e1 Mon Sep 17 00:00:00 2001 From: Alexandre ABRIOUX Date: Tue, 15 Oct 2024 10:56:50 +0200 Subject: [PATCH 1/3] chore(ethereum-storage): add getter for eip-1559 support --- packages/ethereum-storage/src/ethereum-tx-submitter.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/ethereum-storage/src/ethereum-tx-submitter.ts b/packages/ethereum-storage/src/ethereum-tx-submitter.ts index 3fdacbc70..19fa6f9a1 100644 --- a/packages/ethereum-storage/src/ethereum-tx-submitter.ts +++ b/packages/ethereum-storage/src/ethereum-tx-submitter.ts @@ -75,6 +75,10 @@ export class EthereumTransactionSubmitter implements StorageTypes.ITransactionSu this.enableEip1559 = await isEip1559Supported(this.provider, this.logger); } + supportsEip1559() { + return this.enableEip1559; + } + /** Submits an IPFS hash, with fees according to `ipfsSize` */ async submit(ipfsHash: string, ipfsSize: number): Promise { const preparedTransaction = await this.prepareSubmit(ipfsHash, ipfsSize); From 7c5cea1b356587591aa6cf77e47df0b2b38c9fad Mon Sep 17 00:00:00 2001 From: Alexandre ABRIOUX Date: Tue, 15 Oct 2024 11:11:26 +0200 Subject: [PATCH 2/3] comment --- packages/ethereum-storage/src/ethereum-tx-submitter.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/ethereum-storage/src/ethereum-tx-submitter.ts b/packages/ethereum-storage/src/ethereum-tx-submitter.ts index 19fa6f9a1..e87d4d712 100644 --- a/packages/ethereum-storage/src/ethereum-tx-submitter.ts +++ b/packages/ethereum-storage/src/ethereum-tx-submitter.ts @@ -75,11 +75,12 @@ export class EthereumTransactionSubmitter implements StorageTypes.ITransactionSu this.enableEip1559 = await isEip1559Supported(this.provider, this.logger); } + /** Returns whether EIP-1559 is supported by the underlying provider. */ supportsEip1559() { return this.enableEip1559; } - /** Submits an IPFS hash, with fees according to `ipfsSize` */ + /** Submits an IPFS hash, with fees according to `ipfsSize` */ async submit(ipfsHash: string, ipfsSize: number): Promise { const preparedTransaction = await this.prepareSubmit(ipfsHash, ipfsSize); return await this.hashSubmitter.signer.sendTransaction(preparedTransaction); From a7dfda3a40348b7f036c3e625941507122f8021c Mon Sep 17 00:00:00 2001 From: Alexandre ABRIOUX Date: Tue, 15 Oct 2024 11:19:46 +0200 Subject: [PATCH 3/3] add unit test --- .../ethereum-storage/test/ethereum-tx-submitter.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/ethereum-storage/test/ethereum-tx-submitter.test.ts b/packages/ethereum-storage/test/ethereum-tx-submitter.test.ts index b7ebcdcad..7409fb7ba 100644 --- a/packages/ethereum-storage/test/ethereum-tx-submitter.test.ts +++ b/packages/ethereum-storage/test/ethereum-tx-submitter.test.ts @@ -13,6 +13,10 @@ describe(EthereumTransactionSubmitter, () => { await txSubmitter.initialize(); }); + it('can retrieve whether the provider supports eip-1559', () => { + expect(txSubmitter.supportsEip1559()).toBe(true); + }); + it('can prepareSubmit', async () => { expect(await txSubmitter.prepareSubmit('hash', 1)).toMatchObject({ to: '0xf25186b5081ff5ce73482ad761db0eb0d25abfbf', @@ -20,10 +24,12 @@ describe(EthereumTransactionSubmitter, () => { value: BigNumber.from(0), }); }); + it('can submit', async () => { const tx = await txSubmitter.submit('hash', 1); expect(tx.hash).toMatch(/^0x.+/); }); + it('can debug transactions', async () => { const debugMock = jest.fn(); const logger = {