Skip to content

Commit

Permalink
chore(ethereum-storage): add getter for eip-1559 support (#1466)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-abrioux authored Oct 16, 2024
1 parent f2667d0 commit fdaf3ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/ethereum-storage/src/ethereum-tx-submitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ export class EthereumTransactionSubmitter implements StorageTypes.ITransactionSu
this.enableEip1559 = await isEip1559Supported(this.provider, this.logger);
}

/** Submits an IPFS hash, with fees according to `ipfsSize` */
/** Returns whether EIP-1559 is supported by the underlying provider. */
supportsEip1559() {
return this.enableEip1559;
}

/** Submits an IPFS hash, with fees according to `ipfsSize` */
async submit(ipfsHash: string, ipfsSize: number): Promise<ContractTransaction> {
const preparedTransaction = await this.prepareSubmit(ipfsHash, ipfsSize);
return await this.hashSubmitter.signer.sendTransaction(preparedTransaction);
Expand Down
6 changes: 6 additions & 0 deletions packages/ethereum-storage/test/ethereum-tx-submitter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ 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',
data: /^0x.+/,
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 = {
Expand Down

0 comments on commit fdaf3ed

Please sign in to comment.