@@ -52,12 +52,6 @@ contract Orchestrator is
5252 using EfficientHashLib for bytes32 [];
5353 using LibBitmap for LibBitmap.Bitmap;
5454
55- enum Flags {
56- NORMAL_MODE,
57- SIMULATION_MODE,
58- MULTICHAIN_INTENT_MODE
59- }
60-
6155 ////////////////////////////////////////////////////////////////////////
6256 // Errors
6357 ////////////////////////////////////////////////////////////////////////
@@ -154,6 +148,12 @@ contract Orchestrator is
154148 /// Should be enough for a cold zero to non-zero SSTORE + a warm SSTORE + a few SLOADs.
155149 uint256 internal constant _REFUND_GAS = 50000 ;
156150
151+ /// @dev Flag for normal execution mode.
152+ uint256 internal constant _NORMAL_MODE_FLAG = 0 ;
153+
154+ /// @dev Flag for simulation mode.
155+ uint256 internal constant _SIMULATION_MODE_FLAG = 1 ;
156+
157157 ////////////////////////////////////////////////////////////////////////
158158 // Constructor
159159 ////////////////////////////////////////////////////////////////////////
@@ -176,24 +176,20 @@ contract Orchestrator is
176176 /// `encodedIntent` is given by `abi.encode(intent)`, where `intent` is a struct of type `Intent`.
177177 /// If sufficient gas is provided, returns an error selector that is non-zero
178178 /// if there is an error during the payment, verification, and call execution.
179- function execute (bool isMultichain , bytes calldata encodedIntent )
179+ function execute (bytes calldata encodedIntent )
180180 public
181181 payable
182182 virtual
183183 nonReentrant
184184 returns (bytes4 err )
185185 {
186- (, err) = _execute (
187- encodedIntent,
188- 0 ,
189- uint256 (isMultichain ? Flags.MULTICHAIN_INTENT_MODE : Flags.NORMAL_MODE)
190- );
186+ (, err) = _execute (encodedIntent, 0 , _NORMAL_MODE_FLAG);
191187 }
192188
193189 /// @dev Executes the array of encoded intents.
194190 /// Each element in `encodedIntents` is given by `abi.encode(intent)`,
195191 /// where `intent` is a struct of type `Intent`.
196- function execute (bool isMultichain , bytes [] calldata encodedIntents )
192+ function execute (bytes [] calldata encodedIntents )
197193 public
198194 payable
199195 virtual
@@ -206,11 +202,7 @@ contract Orchestrator is
206202 // We reluctantly use regular Solidity to access `encodedIntents[i]`.
207203 // This generates an unnecessary check for `i < encodedIntents.length`, but helps
208204 // generate all the implicit calldata bound checks on `encodedIntents[i]`.
209- (, errs[i]) = _execute (
210- encodedIntents[i],
211- 0 ,
212- uint256 (isMultichain ? Flags.MULTICHAIN_INTENT_MODE : Flags.NORMAL_MODE)
213- );
205+ (, errs[i]) = _execute (encodedIntents[i], 0 , _NORMAL_MODE_FLAG);
214206 }
215207 }
216208
@@ -229,7 +221,7 @@ contract Orchestrator is
229221 ) external payable returns (uint256 ) {
230222 // If Simulation Fails, then it will revert here.
231223 (uint256 gUsed , bytes4 err ) =
232- _execute (encodedIntent, combinedGasOverride, uint256 (Flags.SIMULATION_MODE) );
224+ _execute (encodedIntent, combinedGasOverride, _SIMULATION_MODE_FLAG );
233225
234226 if (err != 0 ) {
235227 assembly ("memory-safe" ) {
@@ -308,7 +300,7 @@ contract Orchestrator is
308300 ) {
309301 err = PaymentError.selector ;
310302
311- if (flags == uint256 (Flags.SIMULATION_MODE) ) {
303+ if (flags == _SIMULATION_MODE_FLAG ) {
312304 revert PaymentError ();
313305 }
314306 }
@@ -318,7 +310,7 @@ contract Orchestrator is
318310 // via the 63/64 rule. This is for gas estimation. If the total amount of gas
319311 // for the whole transaction is insufficient, revert.
320312 if (((gasleft () * 63 ) >> 6 ) < Math.saturatingAdd (g, _INNER_GAS_OVERHEAD)) {
321- if (flags != uint256 (Flags.SIMULATION_MODE) ) {
313+ if (flags != _SIMULATION_MODE_FLAG ) {
322314 revert InsufficientGas ();
323315 }
324316 }
@@ -327,7 +319,7 @@ contract Orchestrator is
327319 if (i.supportedAccountImplementation != address (0 )) {
328320 if (accountImplementationOf (i.eoa) != i.supportedAccountImplementation) {
329321 err = UnsupportedAccountImplementation.selector ;
330- if (flags == uint256 (Flags.SIMULATION_MODE) ) {
322+ if (flags == _SIMULATION_MODE_FLAG ) {
331323 revert UnsupportedAccountImplementation ();
332324 }
333325 }
@@ -338,14 +330,11 @@ contract Orchestrator is
338330 // Early skip the entire pay-verify-call workflow if the payer lacks tokens,
339331 // so that less gas is wasted when the Intent fails.
340332 // For multi chain mode, we skip this check, as the funding happens inside the self call.
341- if (
342- flags != uint256 (Flags.MULTICHAIN_INTENT_MODE)
343- && LibBit.and (i.prePaymentAmount != 0 , err == 0 )
344- ) {
333+ if (! i.isMultichain && LibBit.and (i.prePaymentAmount != 0 , err == 0 )) {
345334 if (TokenTransferLib.balanceOf (i.paymentToken, payer) < i.prePaymentAmount) {
346335 err = PaymentError.selector ;
347336
348- if (flags == uint256 (Flags.SIMULATION_MODE) ) {
337+ if (flags == _SIMULATION_MODE_FLAG ) {
349338 revert PaymentError ();
350339 }
351340 }
@@ -373,7 +362,7 @@ contract Orchestrator is
373362
374363 if iszero (selfCallSuccess) {
375364 // If it is a simulation, we simply revert with the full error.
376- if eq (flags, 1 ) {
365+ if eq (flags, _SIMULATION_MODE_FLAG ) {
377366 returndatacopy (mload (0x40 ), 0x00 , returndatasize ())
378367 revert (mload (0x40 ), returndatasize ())
379368 }
@@ -454,7 +443,7 @@ contract Orchestrator is
454443
455444 bool isValid;
456445 bytes32 keyHash;
457- if (flags == uint256 (Flags.MULTICHAIN_INTENT_MODE) ) {
446+ if (i.isMultichain ) {
458447 // For multi chain intents, we have to verify using merkle sigs.
459448 (isValid, keyHash) = _verifyMerkleSig (digest, eoa, i.signature);
460449
@@ -468,7 +457,7 @@ contract Orchestrator is
468457 (isValid, keyHash) = _verify (digest, eoa, i.signature);
469458 }
470459
471- if (flags == uint256 (Flags.SIMULATION_MODE) ) {
460+ if (flags == _SIMULATION_MODE_FLAG ) {
472461 isValid = true ;
473462 }
474463
@@ -515,7 +504,7 @@ contract Orchestrator is
515504 if iszero (
516505 call (gas (), address (), 0 , add (m, 0x1c ), add (0x64 , encodedIntentLength), m, 0x20 )
517506 ) {
518- if eq (flags, 1 ) {
507+ if eq (flags, _SIMULATION_MODE_FLAG ) {
519508 returndatacopy (mload (0x40 ), 0x00 , returndatasize ())
520509 revert (mload (0x40 ), returndatasize ())
521510 }
@@ -556,7 +545,7 @@ contract Orchestrator is
556545 assembly ("memory-safe" ) {
557546 mstore (0x00 , 0 ) // Zeroize the return slot.
558547 if iszero (call (gas (), eoa, 0 , add (0x20 , data), mload (data), 0x00 , 0x20 )) {
559- if eq (flags, 1 ) {
548+ if eq (flags, _SIMULATION_MODE_FLAG ) {
560549 returndatacopy (mload (0x40 ), 0x00 , returndatasize ())
561550 revert (mload (0x40 ), returndatasize ())
562551 }
@@ -597,7 +586,7 @@ contract Orchestrator is
597586
598587 (bool isValid , bytes32 keyHash ) = _verify (_computeDigest (p), eoa, p.signature);
599588
600- if (flags == uint256 (Flags.SIMULATION_MODE) ) {
589+ if (flags == _SIMULATION_MODE_FLAG ) {
601590 isValid = true ;
602591 }
603592 if (! isValid) revert PreCallVerificationError ();
@@ -616,7 +605,7 @@ contract Orchestrator is
616605 mstore (0x00 , 0 ) // Zeroize the return slot.
617606 if iszero (call (gas (), eoa, 0 , add (0x20 , data), mload (data), 0x00 , 0x20 )) {
618607 // If this is a simulation via `simulateFailed`, bubble up the whole revert.
619- if eq (flags, 1 ) {
608+ if eq (flags, _SIMULATION_MODE_FLAG ) {
620609 returndatacopy (mload (0x40 ), 0x00 , returndatasize ())
621610 revert (mload (0x40 ), returndatasize ())
622611 }
@@ -898,7 +887,7 @@ contract Orchestrator is
898887 returns (string memory name , string memory version )
899888 {
900889 name = "Orchestrator " ;
901- version = "0.4.2 " ;
890+ version = "0.4.3 " ;
902891 }
903892
904893 ////////////////////////////////////////////////////////////////////////
0 commit comments