Creates the data which the smart contract's `decodeTrade` expects.
(
order: &OrderData,
signature: &Signature,
owner: Address,
sell_token_index: usize,
buy_token_index: usize,
executed_amount: U256,
)
| 152 | |
| 153 | /// Creates the data which the smart contract's `decodeTrade` expects. |
| 154 | pub fn encode_trade( |
| 155 | order: &OrderData, |
| 156 | signature: &Signature, |
| 157 | owner: Address, |
| 158 | sell_token_index: usize, |
| 159 | buy_token_index: usize, |
| 160 | executed_amount: U256, |
| 161 | ) -> EncodedTrade { |
| 162 | ( |
| 163 | U256::from(sell_token_index), |
| 164 | U256::from(buy_token_index), |
| 165 | // Use the actual raw bytes that got signed by the owner intead of the |
| 166 | // resolved address to make the signature recovery work in the contract. |
| 167 | Address::from(*order.receiver.raw_bytes()), |
| 168 | order.sell_amount, |
| 169 | order.buy_amount, |
| 170 | order.valid_to, |
| 171 | B256::new(order.app_data.0), |
| 172 | order.fee_amount, |
| 173 | order_flags(order, signature), |
| 174 | executed_amount, |
| 175 | Bytes::from(signature.encode_for_settlement(owner)), |
| 176 | ) |
| 177 | } |
| 178 | |
| 179 | fn order_flags(order: &OrderData, signature: &Signature) -> U256 { |
| 180 | let mut result = 0u8; |
no test coverage detected