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

chore: make async fn with no await an error #423

Merged
merged 10 commits into from
Oct 4, 2023

Conversation

james-a-morris
Copy link
Contributor

@james-a-morris james-a-morris commented Oct 3, 2023

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.

async getGasCosts(): Promise<BigNumberish> {
return gasCost(this.defaultGas, 1e9); // 1 gwei
getGasCosts(): Promise<BigNumberish> {
return Promise.resolve(gasCost(this.defaultGas, 1e9)); // 1 gwei
Copy link
Member

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?

Copy link
Contributor Author

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);
};

@james-a-morris james-a-morris force-pushed the james/acx-1563-re-enable-some-validatefillts-tests branch from eb57c59 to 4263e68 Compare October 3, 2023 15:50
@james-a-morris james-a-morris changed the base branch from james/acx-1563-re-enable-some-validatefillts-tests to master October 3, 2023 22:10
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",
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@pxrl pxrl left a comment

Choose a reason for hiding this comment

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

LGTM!

@james-a-morris james-a-morris merged commit ae9873c into master Oct 4, 2023
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.

3 participants