-
Notifications
You must be signed in to change notification settings - Fork 107
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
✨ feat: Add gas estimation actions #67
✨ feat: Add gas estimation actions #67
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
/** | ||
* Estimate the l1 gas price portion for a transaction | ||
* @example | ||
* const price = await getL1GasPrice(publicClient, { | ||
* blockNumber, | ||
* blockTag, | ||
* }); | ||
*/ |
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.
/** | |
* Estimate the l1 gas price portion for a transaction | |
* @example | |
* const price = await getL1GasPrice(publicClient, { | |
* blockNumber, | |
* blockTag, | |
* }); | |
*/ |
Maybe delete for now and go through and add jsdocs in it's own pr
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.
yeah I've been underinvesting in jsdoc in favor of the markdown docs, not sure if right tradeoff.
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.
Jsdoc is more important because you see jsdoc in your editor imo
// no way to get historical gas price | ||
createPublicClient: (...args: [any]) => { | ||
const client = _viem.createPublicClient(...args) | ||
client.getGasPrice = async () => parseGwei('0.00000042') |
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.
does getGasPrice
not work with normal forking?
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.
It does not unfortunately. Viem types correctly don't give you blockTag as a param as well
src/actions/public/L2/feeActions.ts
Outdated
* const contract = getGasPriceOracleContract(publicClient) | ||
* const gasPrice = await contract.read.gasPrice({ blockNumber }) | ||
*/ | ||
const getGasPriceOracleContract = <TChain extends Chain | undefined>( |
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.
again prefer 1 function per file.
Thinking if we should actually export these viem versions of all the main contracts 🤔
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.
@eth-optimism/contracts-ts is the package that exports versions of all the main contracts. It does it both as react hooks and as vanilla hooks. It might be a good idea to reexport them from this package though
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.
Thanks for review! Will update in next couple days
// no way to get historical gas price | ||
createPublicClient: (...args: [any]) => { | ||
const client = _viem.createPublicClient(...args) | ||
client.getGasPrice = async () => parseGwei('0.00000042') |
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.
It does not unfortunately. Viem types correctly don't give you blockTag as a param as well
src/actions/public/L2/feeActions.ts
Outdated
* const contract = getGasPriceOracleContract(publicClient) | ||
* const gasPrice = await contract.read.gasPrice({ blockNumber }) | ||
*/ | ||
const getGasPriceOracleContract = <TChain extends Chain | undefined>( |
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.
@eth-optimism/contracts-ts is the package that exports versions of all the main contracts. It does it both as react hooks and as vanilla hooks. It might be a good idea to reexport them from this package though
/** | ||
* Estimate the l1 gas price portion for a transaction | ||
* @example | ||
* const price = await getL1GasPrice(publicClient, { | ||
* blockNumber, | ||
* blockTag, | ||
* }); | ||
*/ |
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.
Jsdoc is more important because you see jsdoc in your editor imo
994411a
to
8adc3e2
Compare
ab6e31f
to
abce50a
Compare
abce50a
to
206b473
Compare
* args: [address], | ||
* }); | ||
*/ | ||
export const estimateFees: EstimateFees = async (client, options) => { |
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.
in an ideal world, this would be the default estimateGas
function for an OPStack chain in viem, right? @roninjin10
Do we think we should name it like opStackEstimateGas or something closer?
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.
Estimate gas is different. On l1 estimate fees would be estimateGas multiplied by the gas price. This is something I chatted with Jake about and he lightly agreed it would be valuable to add for all chains
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.
ok thanks for clarifying @roninjin10
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.
I’m not in love with the name estimateFees btw I just couldn’t come up with a better name. Etherscan calls it a transactionFee. Maybe we should call it transactionFee? I would love a name that makes it so folks can guess the difference between it and estimateGas most of the time
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.
transactionFee is pretty good! I don't have a strong preference
7b44eea
to
9e640aa
Compare
9e640aa
to
a3d7ef5
Compare
a3d7ef5
to
6de7647
Compare
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.
@roninjin10 we should also export this in actions/index
96d4f79
to
ca4bb91
Compare
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.
Approving with fast-follows for documentation and testing updates.
version
andl1BaseFee
. The recommended way to use this is to just use the gasPriceOracle contract or get stuff like l1BaseFee from l1 they just bloat the API including them here imo