MCPcopy Create free account
hub / github.com/cowprotocol/services / encode_hooks

Method encode_hooks

crates/simulator/src/simulation_builder.rs:253–272  ·  view source on GitHub ↗

Generates 1 interaction executing the given hooks via the trampoline contract since executing hooks directly from the settlement contract context would give them elevated privileges that put funds at risk.

(&self, hooks: &[app_data::Hook])

Source from the content-addressed store, hash-verified

251 /// contract since executing hooks directly from the settlement contract
252 /// context would give them elevated privileges that put funds at risk.
253 fn encode_hooks(&self, hooks: &[app_data::Hook]) -> Option<InteractionData> {
254 if hooks.is_empty() {
255 return None;
256 }
257 Some(InteractionData {
258 target: self.simulator.0.hooks_trampoline,
259 value: U256::ZERO,
260 call_data: contracts::HooksTrampoline::HooksTrampoline::executeCall {
261 hooks: hooks
262 .iter()
263 .map(|h| contracts::HooksTrampoline::HooksTrampoline::Hook {
264 target: h.target,
265 callData: Bytes::copy_from_slice(&h.call_data),
266 gasLimit: U256::from(h.gas_limit),
267 })
268 .collect(),
269 }
270 .abi_encode(),
271 })
272 }
273
274 /// Instructs the builder to override the settlement contract's buy-token
275 /// balances so it can pay out every order. The exact amounts are derived

Callers 1

Calls 4

collectMethod · 0.80
is_emptyMethod · 0.45
abi_encodeMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected