Use array-bytes for All Array/Bytes/Hex Operations (#12190)

* Use `array-bytes` for All Array/Bytes/Hex Operations

Signed-off-by: Xavier Lau <xavier@inv.cafe>

* Reorder

* Self Review

* Format

* Fix Tests

* Bump `array-bytes`

* Optimize large test res

Signed-off-by: Xavier Lau <xavier@inv.cafe>
Co-authored-by: parity-processbot <>
This commit is contained in:
Xavier Lau
2022-09-21 14:12:20 +08:00
committed by GitHub
parent e4b6f4a66d
commit 86198c5471
79 changed files with 520 additions and 510 deletions
+2 -2
View File
@@ -55,7 +55,7 @@ impl VerifyCmd {
/// Run the command
pub fn run(&self) -> error::Result<()> {
let message = utils::read_message(self.message.as_ref(), self.hex)?;
let sig_data = utils::decode_hex(&self.sig)?;
let sig_data = array_bytes::hex2bytes(&self.sig)?;
let uri = utils::read_uri(self.uri.as_ref())?;
let uri = if let Some(uri) = uri.strip_prefix("0x") { uri } else { &uri };
@@ -71,7 +71,7 @@ where
let signature =
Pair::Signature::try_from(&sig_data).map_err(|_| error::Error::SignatureFormatInvalid)?;
let pubkey = if let Ok(pubkey_vec) = hex::decode(uri) {
let pubkey = if let Ok(pubkey_vec) = array_bytes::hex2bytes(uri) {
Pair::Public::from_slice(pubkey_vec.as_slice())
.map_err(|_| error::Error::KeyFormatInvalid)?
} else {