| 177 | } |
| 178 | |
| 179 | fn order_flags(order: &OrderData, signature: &Signature) -> U256 { |
| 180 | let mut result = 0u8; |
| 181 | // The kind is encoded as 1 bit in position 0. |
| 182 | result |= match order.kind { |
| 183 | OrderKind::Sell => 0b0, |
| 184 | OrderKind::Buy => 0b1, |
| 185 | }; |
| 186 | // The order fill kind is encoded as 1 bit in position 1. |
| 187 | result |= (order.partially_fillable as u8) << 1; |
| 188 | // The order sell token balance is encoded as 2 bits in position 2. |
| 189 | result |= match order.sell_token_balance { |
| 190 | SellTokenSource::Erc20 => 0b00, |
| 191 | SellTokenSource::External => 0b10, |
| 192 | SellTokenSource::Internal => 0b11, |
| 193 | } << 2; |
| 194 | // The order buy token balance is encoded as 1 bit in position 4. |
| 195 | result |= match order.buy_token_balance { |
| 196 | BuyTokenDestination::Erc20 => 0b0, |
| 197 | BuyTokenDestination::Internal => 0b1, |
| 198 | } << 4; |
| 199 | // The signing scheme is encoded as a 2 bits in position 5. |
| 200 | result |= match signature.scheme() { |
| 201 | SigningScheme::Eip712 => 0b00, |
| 202 | SigningScheme::EthSign => 0b01, |
| 203 | SigningScheme::Eip1271 => 0b10, |
| 204 | SigningScheme::PreSign => 0b11, |
| 205 | } << 5; |
| 206 | U256::from(result) |
| 207 | } |
| 208 | |
| 209 | /// Data for a raw GPv2 interaction. |
| 210 | #[derive(Clone, PartialEq, Eq, Hash, Default, Serialize, Debug)] |