Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor duplicate function and renamed gas option type #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

suraneti
Copy link

@suraneti suraneti commented Mar 16, 2021

reduceOption function is declared in both getRate and getRateAmountOut function, so it would be better if changed to a class method.

const reduceOption = (option: any) => {
	return {
		gasLimit: option.gasLimit,
		gasPrice: `${this.web3.utils.toWei(option.gasPrice, "gwei")}`
	}
}

Change to a private class method.

private getGasOption(option: TradeOption): GasOption {
	return {
		gasLimit: `${option.gasLimit}`,
		gasPrice: `${this.web3.utils.toWei(option.gasPrice, "gwei")}`
	}
}

And I also changed the type name from Options to GasOption in types/Web3.ts for better understanding, no idea this is good or not.

@suraneti suraneti changed the title chore: refactor duplicate func Refactor duplicate function and renamed gas option type Mar 16, 2021
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.

1 participant