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

Function encode_wrapper_data

crates/simulator/src/encoding.rs:327–342  ·  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

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

Callers 1

Calls 8

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

Tested by

no test coverage detected