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

Function encode_wrapper_data

crates/simulator/src/encoding.rs:330–345  ·  view source on GitHub ↗

Encodes wrapper metadata for wrapper settlement calls. As wrappers are called, each wrapper reads from wrapper calldata and consumes only their needed portion (however much data that is). Once wrapper is ready to call the settlement contract (or downstream wrapper) it calls the _internalSettle function provided in the CowWrapper abstract contract Generally wrappers are encoded with a pair of Addr

(wrappers: &[WrapperCall])

Source from the content-addressed store, hash-verified

328/// More information about wrapper encoding:
329/// https://docs.cow.fi/cow-protocol/integrate/wrappers#manual-encoding
330pub fn encode_wrapper_data(wrappers: &[WrapperCall]) -> Bytes {
331 let mut wrapper_data = Vec::new();
332
333 for (index, w) in wrappers.iter().enumerate() {
334 // Skip first wrapper's address (it's the transaction target)
335 if index != 0 {
336 wrapper_data.extend(w.address.as_slice());
337 }
338
339 // Encode data length as u16 in native endian, then the data itself
340 wrapper_data.extend((w.data.len() as u16).to_be_bytes().to_vec());
341 wrapper_data.extend(w.data.clone());
342 }
343
344 wrapper_data.into()
345}
346
347pub(crate) async fn finish_simulation_builder(
348 mut builder: SimulationBuilder,

Callers 1

Calls 8

extendMethod · 0.80
as_sliceMethod · 0.80
to_be_bytesMethod · 0.80
newFunction · 0.50
iterMethod · 0.45
lenMethod · 0.45
cloneMethod · 0.45
intoMethod · 0.45

Tested by

no test coverage detected