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

Method encode_hooks

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

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