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

Method encode_hooks

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

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