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

Method encode_hooks

crates/simulator/src/simulation_builder.rs:271–290  ·  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

269 /// contract since executing hooks directly from the settlement contract
270 /// context would give them elevated privileges that put funds at risk.
271 fn encode_hooks(&self, hooks: &[app_data::Hook]) -> Option<InteractionData> {
272 if hooks.is_empty() {
273 return None;
274 }
275 Some(InteractionData {
276 target: self.simulator.0.hooks_trampoline,
277 value: U256::ZERO,
278 call_data: contracts::HooksTrampoline::HooksTrampoline::executeCall {
279 hooks: hooks
280 .iter()
281 .map(|h| contracts::HooksTrampoline::HooksTrampoline::Hook {
282 target: h.target,
283 callData: Bytes::copy_from_slice(&h.call_data),
284 gasLimit: U256::from(h.gas_limit),
285 })
286 .collect(),
287 }
288 .abi_encode(),
289 })
290 }
291
292 /// Instructs the builder to override the settlement contract's buy-token
293 /// 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