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])
| 325 | /// More information about wrapper encoding: |
| 326 | /// https://docs.cow.fi/cow-protocol/integrate/wrappers#manual-encoding |
| 327 | pub 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 | |
| 344 | pub(crate) async fn finish_simulation_builder( |
| 345 | mut builder: SimulationBuilder, |
no test coverage detected