-
Notifications
You must be signed in to change notification settings - Fork 14
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
chore: make async fn with no await an error #423
Conversation
async getGasCosts(): Promise<BigNumberish> { | ||
return gasCost(this.defaultGas, 1e9); // 1 gwei | ||
getGasCosts(): Promise<BigNumberish> { | ||
return Promise.resolve(gasCost(this.defaultGas, 1e9)); // 1 gwei |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't you just return gasCost
if gasCost
returns a Promise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gasCost
unfortunately doesn't return a promise:
/**
* Convert a gas amount and gas price to wei.
*
* @param {number} gas - gas amount.
* @param {BigNumberish} gasPrice - gas price in gwei.
* @returns {BigNumber} - total fees in wei.
*/
export const gasCost = (gas: BigNumberish, gasPrice: BigNumberish): BigNumber => {
return BigNumber.from(gas).mul(gasPrice);
};
eb57c59
to
4263e68
Compare
package.json
Outdated
@@ -19,8 +19,8 @@ | |||
"build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap", | |||
"test": "hardhat test", | |||
"test:watch": "hardhat watch test", | |||
"lint": "eslint --fix src", | |||
"lint-check": "eslint src", | |||
"lint": "eslint --fix src test", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side note: do you think we need to lint e2e
also?
And do you think we should lint the hardhat.config.ts
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR makes floating promises an error in the SDK. There was a slight lift to convert non-async functions with the async tag into nonsync counterparts.
Going forward, the CI will tag these warnings as an error.