-
Notifications
You must be signed in to change notification settings - Fork 465
@0x/contracts-extensions
: Maximum gas price contract
#2511
@0x/contracts-extensions
: Maximum gas price contract
#2511
Conversation
ebf640a
to
9c5ac26
Compare
@0x/contracts-extensions
: Maximum gas price contract
|
||
*/ | ||
|
||
pragma solidity ^0.5.16; |
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.
👀
/// @dev Checks that the current transaction's gas price is less than | ||
/// the specified maximum value. | ||
/// @param data Encodes the maximum gas price. | ||
function checkGasPrice(bytes calldata data) |
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 not just take a uint256
here?
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.
didn't realize that would work 🙈
*/ | ||
|
||
pragma solidity ^0.5.16; | ||
pragma experimental ABIEncoderV2; |
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 don't think we actually need to use ABIv2 here. I'd just run tests with/without to see if there are any gas differences.
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.
looks like without is slightly cheaper for the parametrized version
* Encodes the given stop limit data parameters into StaticCall asset data so that it can be used | ||
* in a 0x order. | ||
*/ | ||
export function encodeMaxGasPriceStaticCallData(maxGasPriceContractAddress: string, maxGasPrice?: BigNumber): string { |
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.
Thank you for writing this helper 🙌
external | ||
view |
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 did we get rid of view
here?
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.
oops that was a remnant of some tests
4af2577
to
4900949
Compare
Description
Contract includes a parameter-less version which uses a hard-coded max of 20 Gwei, and a version that allows makers to specify a custom max value.
Includes tooling for encoding/decoding the StaticCall asset data, as well as some basic unit tests
Testing instructions
Types of changes
Checklist:
[WIP]
if necessary.