-
Notifications
You must be signed in to change notification settings - Fork 1
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
add quote view fn & replace getCompactWitnessTypestring w/ getCompactWitnessDetails #3
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,13 +124,59 @@ contract HyperlaneArbiter is Router { | |
); | ||
} | ||
|
||
/** | ||
* @notice Quotes a compact intent and returns the msg.value that should be provided | ||
* cover all hyperlane fees (relay, etc). | ||
* @param claimChain The chain ID of the claim. | ||
* @param compact The compact intent to fill. | ||
* @dev signatures must be compliant with https://eips.ethereum.org/EIPS/eip-2098 | ||
* @param allocatorSignature The allocator's signature. | ||
* @param sponsorSignature The sponsor's signature. | ||
* @return The quoted fee. | ||
*/ | ||
function quote( | ||
uint32 claimChain, | ||
Compact calldata compact, | ||
Intent calldata intent, | ||
bytes calldata allocatorSignature, | ||
bytes calldata sponsorSignature | ||
) external view returns (uint256) { | ||
require(block.chainid == intent.chainId, "invalid chain"); | ||
|
||
// TODO: support Permit2 fills | ||
address filler = msg.sender; | ||
|
||
return _Router_quoteDispatch( | ||
claimChain, | ||
Message.encode(compact, allocatorSignature, sponsorSignature, hash(intent), intent.fee, filler), | ||
"", | ||
address(hook) | ||
); | ||
} | ||
|
||
function hash(Intent memory intent) public pure returns (bytes32) { | ||
return | ||
keccak256(abi.encode(TYPEHASH, intent.fee, intent.chainId, intent.token, intent.recipient, intent.amount)); | ||
} | ||
|
||
function getCompactWitnessTypestring() external pure returns (string memory) { | ||
return WITNESS_TYPESTRING; | ||
function getCompactWitnessDetails() | ||
external | ||
pure | ||
returns ( | ||
string memory typestring, | ||
string[] memory compactTokenArguments, | ||
string[3][] memory customTokenArguments | ||
) | ||
{ | ||
typestring = WITNESS_TYPESTRING; | ||
|
||
// Arguments that refer to some amount of the token in the resource lock | ||
compactTokenArguments = new string[](1); | ||
compactTokenArguments[0] = "fee"; | ||
|
||
// Arguments that refer to some amount of an arbitrary chain + token combination | ||
customTokenArguments = new string[3][](1); | ||
customTokenArguments[0] = ["intent.chainId", "intent.token", "intent.amount"]; | ||
Comment on lines
+174
to
+179
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would be very happy to just adopt whatever standard struct you propose on the compact There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do feel like some form of JSON payload that lays out the typestring as well as the various semantic context and relations between the arguments could be a better way than .. whatever this is 🤣 that said, it does get the job done for just detecting token names / decimals to use 🤷 |
||
} | ||
|
||
function _handle( | ||
|
This file was deleted.
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.
if we dont populate anything here, the
handle
function is assumed to have a gas limit of 50kwe may need to adjust this, have you successfully used these quotes in prod yet?
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.
not yet — open question on whether to just build in an approximate buffer and let filler work out the exact quoted fee or if the UI should derive it locally