Skip to content

Commit

Permalink
add quote view fn & replace getCompactWitnessTypestring w/ getCompact…
Browse files Browse the repository at this point in the history
…WitnessDetails
  • Loading branch information
0age committed Nov 26, 2024
1 parent e3ddf6f commit 4477482
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 59 deletions.
19 changes: 0 additions & 19 deletions script/Counter.s.sol

This file was deleted.

14 changes: 0 additions & 14 deletions src/Counter.sol

This file was deleted.

42 changes: 40 additions & 2 deletions src/HyperlaneArbiter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,51 @@ 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"];
}

function _handle(
Expand Down
24 changes: 0 additions & 24 deletions test/Counter.t.sol

This file was deleted.

0 comments on commit 4477482

Please sign in to comment.