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