| 29 | { |
| 30 | |
| 31 | bytes jsToBytes(string const& _s, OnFailed _f) |
| 32 | { |
| 33 | try |
| 34 | { |
| 35 | return fromHex(_s, WhenError::Throw); |
| 36 | } |
| 37 | catch (...) |
| 38 | { |
| 39 | if (_f == OnFailed::InterpretRaw) |
| 40 | return asBytes(_s); |
| 41 | else if (_f == OnFailed::Throw) |
| 42 | throw invalid_argument("Cannot intepret '" + _s + "' as bytes; must be 0x-prefixed hex or decimal."); |
| 43 | } |
| 44 | return bytes(); |
| 45 | } |
| 46 | |
| 47 | bytes padded(bytes _b, unsigned _l) |
| 48 | { |