Skip to content

feat(toolbox): troubleshooting utilities#995

Merged
benjlevesque merged 5 commits intomasterfrom
feat/toolbox/troubleshooting-utilities
Nov 29, 2022
Merged

feat(toolbox): troubleshooting utilities#995
benjlevesque merged 5 commits intomasterfrom
feat/toolbox/troubleshooting-utilities

Conversation

@benjlevesque
Copy link
Contributor

@benjlevesque benjlevesque commented Nov 28, 2022

This PR introduces a few utilities that we missed when troubleshooting an incident today.

To avoiding re-coding core logic parts, I refactored 2 pieces of the ethereum-storage to expose internals.

import * as yargs from 'yargs';
import { modeType } from './logger';

const argv = yargs.parseSync();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type of argv changed in recent versions

network,
signer,
) as RequestOpenHashSubmitter; // type mismatch with ethers.
this.txSubmitter = new EthereumTransactionSubmitter({ network, signer, logger });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactoring to isolate the part where we submit the transaction to the blockchain, for better reusability.

@@ -0,0 +1,75 @@
import { BigNumber, ContractTransaction, providers, utils } from 'ethers';
Copy link
Contributor Author

@benjlevesque benjlevesque Nov 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly moving code from ethereum-storage-ethers.

}

/** Encodes the submission of an IPFS hash, with fees according to `ipfsSize` */
async prepareSubmit(ipfsHash: string, ipfsSize: number): Promise<providers.TransactionRequest> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is new. Enables better testability.

return { to: this.hashSubmitter.address, data: tx, value: fee, ...gasFees };
}

private async getGasFees(): Promise<{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is new. Isolate the gas fees logic from main logic

};
}

public async getSize(ipfsHash: string): Promise<number> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

introduced a new function for reusability

@benjlevesque benjlevesque marked this pull request as ready for review November 28, 2022 15:41
@benjlevesque benjlevesque force-pushed the feat/toolbox/troubleshooting-utilities branch from b047494 to 2c4df17 Compare November 28, 2022 15:41
@coveralls
Copy link

coveralls commented Nov 28, 2022

Coverage Status

Coverage decreased (-0.01%) to 88.707% when pulling 7d7be74 on feat/toolbox/troubleshooting-utilities into f8438d0 on master.

ci-skip
Co-authored-by: Alexandre ABRIOUX <alexandre-abrioux@users.noreply.github.com>
@alexandre-abrioux alexandre-abrioux force-pushed the feat/toolbox/troubleshooting-utilities branch from 2f692ce to 7d7be74 Compare November 29, 2022 08:28
Copy link
Contributor

@leoslr leoslr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benjlevesque benjlevesque merged commit 1818e08 into master Nov 29, 2022
@benjlevesque benjlevesque deleted the feat/toolbox/troubleshooting-utilities branch November 29, 2022 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants