Skip to content

Commit af1127a

Browse files
committed
refactor: move dummy packet initialization for getModule into a block scope
1 parent 9b9ad84 commit af1127a

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

src/core/TxAtomicSimple.sol

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,35 +100,18 @@ abstract contract TxAtomicSimple is
100100

101101
// --- 3. Local Prepare (Coordinator) ---
102102

103-
// Dummy packet for getModule (local execution)
104-
Height.Data memory emptyHeight = Height.Data(0, 0);
105-
// TODO: SimpleContractRegistry is designed to have only a single ContractModule,
106-
// but it is not correct to force that assumption on the caller as well.
107-
// We should generate a proper Packet instead of dummyPacket to support multiple modules.
108-
Packet memory dummyPacket = Packet({
109-
sequence: 0,
110-
sourcePort: "",
111-
sourceChannel: "",
112-
destinationPort: "",
113-
destinationChannel: "",
114-
data: bytes(""),
115-
timeoutHeight: emptyHeight,
116-
timeoutTimestamp: 0
117-
});
118-
119-
IContractModule module = getModule(dummyPacket);
120-
if (address(module) == address(0)) {
121-
revert ModuleNotInitialized();
122-
}
123-
124103
CoordinatorState.CoordinatorPhase phase = CoordinatorState.CoordinatorPhase.COORDINATOR_PHASE_UNKNOWN;
125104
CoordinatorState.CoordinatorDecision decision =
126105
CoordinatorState.CoordinatorDecision.COORDINATOR_DECISION_UNKNOWN;
127106
bool prepareOK = false;
128107

129108
// Use a block scope to avoid "Stack Too Deep" error by limiting the lifetime of temporary variables
130109
{
110+
// Dummy packet for getModule (local execution)
131111
Height.Data memory emptyHeight = Height.Data(0, 0);
112+
// TODO: SimpleContractRegistry is designed to have only a single ContractModule,
113+
// but it is not correct to force that assumption on the caller as well.
114+
// We should generate a proper Packet instead of dummyPacket to support multiple modules.
132115
Packet memory dummyPacket = Packet({
133116
sequence: 0,
134117
sourcePort: "",

0 commit comments

Comments
 (0)