@@ -33,6 +33,13 @@ contract ExecutorQuoterRouter is IExecutorQuoterRouter {
3333 error GovernanceExpired (uint64 expiryTime );
3434 error NotAnEvmAddress (bytes32 );
3535
36+ struct ExecutionParams {
37+ uint16 dstChain;
38+ bytes32 dstAddr;
39+ address refundAddr;
40+ address quoterAddr;
41+ }
42+
3643 constructor (address _executor ) {
3744 EXECUTOR = IExecutor (_executor);
3845 OUR_CHAIN = EXECUTOR.ourChain ();
@@ -112,25 +119,34 @@ contract ExecutorQuoterRouter is IExecutorQuoterRouter {
112119 bytes calldata requestBytes ,
113120 bytes calldata relayInstructions
114121 ) external payable {
115- IExecutorQuoter implementation = quoterContract[quoterAddr];
116- (uint256 requiredPayment , bytes32 payeeAddress , bytes32 quoteBody ) =
117- implementation.requestExecutionQuote (dstChain, dstAddr, refundAddr, requestBytes, relayInstructions);
122+ ExecutionParams memory params =
123+ ExecutionParams ({dstChain: dstChain, dstAddr: dstAddr, refundAddr: refundAddr, quoterAddr: quoterAddr});
124+ _requestExecutionInternal (params, requestBytes, relayInstructions);
125+ }
126+
127+ function _requestExecutionInternal (
128+ ExecutionParams memory params ,
129+ bytes calldata requestBytes ,
130+ bytes calldata relayInstructions
131+ ) private {
132+ IExecutorQuoter implementation = quoterContract[params.quoterAddr];
133+ (uint256 requiredPayment , bytes32 payeeAddress , bytes32 quoteBody ) = implementation.requestExecutionQuote (
134+ params.dstChain, params.dstAddr, params.refundAddr, requestBytes, relayInstructions
135+ );
118136 if (msg .value < requiredPayment) {
119137 revert Underpaid (msg .value , requiredPayment);
120138 }
121139 if (msg .value > requiredPayment) {
122- (bool refundSuccessful ,) = payable (refundAddr).call {value: msg .value - requiredPayment}("" );
140+ (bool refundSuccessful ,) = payable (params. refundAddr).call {value: msg .value - requiredPayment}("" );
123141 if (! refundSuccessful) {
124- revert RefundFailed (refundAddr);
142+ revert RefundFailed (params. refundAddr);
125143 }
126144 }
145+ bytes memory signedQuote = abi.encodePacked (
146+ QUOTE_PREFIX, params.quoterAddr, payeeAddress, OUR_CHAIN, params.dstChain, EXPIRY_TIME, quoteBody
147+ );
127148 EXECUTOR.requestExecution {value: requiredPayment}(
128- dstChain,
129- dstAddr,
130- refundAddr,
131- abi.encodePacked (QUOTE_PREFIX, quoterAddr, payeeAddress, OUR_CHAIN, dstChain, EXPIRY_TIME, quoteBody),
132- requestBytes,
133- relayInstructions
149+ params.dstChain, params.dstAddr, params.refundAddr, signedQuote, requestBytes, relayInstructions
134150 );
135151 // this must emit a message in this function in order to verify off-chain that this contract generated the quote
136152 // the implementation is the only data available in this context that is not available from the executor event
0 commit comments