diff --git a/contrib/sdk-bindings/rust/src/keys.rs b/contrib/sdk-bindings/rust/src/keys.rs index c4019c130af63b2079166db3afb049bc3ba17d20..7b451f1205f522cfc1d5615d9a797f032fad9a0b 100644 --- a/contrib/sdk-bindings/rust/src/keys.rs +++ b/contrib/sdk-bindings/rust/src/keys.rs @@ -60,40 +60,12 @@ bind_hash!(Ed25519Signature, hash::Ed25519Signature); bind_hash!(Secp256k1Signature, hash::Secp256k1Signature); bind_hash!(P256Signature, hash::P256Signature); bind_hash!(BlsSignature, hash::BlsSignature); +bind_hash!(Signature, signature::Signature); bind_hash!(ContractKt1Hash, hash::ContractKt1Hash); bind_hash!(Contract, contract::Contract); -// TODO: https://linear.app/tezos/issue/SDK-73. -// Unable use the `bind_hash!` macro because the `signature::Signature` struct does not implement `from_b58check` and `to_b58check` but `from_base58_check` and `to_base58_check` -/// Generic signature structure gathering the four types of signature hash and the unknown signature hash. -#[derive(uniffi::Object, Debug, Clone, PartialEq, Eq)] -#[uniffi::export(Debug, Display, Eq)] -pub struct Signature(pub(crate) signature::Signature); - -#[uniffi::export] -impl Signature { - /// Decodes any Base58Check-encoded signature string into a `Signature`. - #[uniffi::constructor] - pub fn from_b58check(data: &str) -> Result { - signature::Signature::from_base58_check(data) - .map(Self) - .map_err(Error::Base58) - } - - /// Encodes the `Signature` into a Base58Check-encoded string. - pub fn to_b58check(&self) -> String { - signature::Signature::to_base58_check(&self.0) - } -} - -impl ::std::fmt::Display for Signature { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.0) - } -} - macro_rules! bind_pk_to_pkh { ($pk:ident, $pkh:ident) => { #[uniffi::export] diff --git a/sdk/rust/crypto/src/signature.rs b/sdk/rust/crypto/src/signature.rs index 01d3cb8f24587777b903285a0cb0513ecffcebc2..66a571c3afa4ae0f2fd16f015a74439a4873a7f7 100644 --- a/sdk/rust/crypto/src/signature.rs +++ b/sdk/rust/crypto/src/signature.rs @@ -60,6 +60,14 @@ impl Signature { } } + pub fn from_b58check(data: &str) -> Result { + Self::from_base58_check(data) + } + + pub fn to_b58check(&self) -> String { + self.to_base58_check() + } + pub fn hash_type(&self) -> HashType { match self { Self::Ed25519(_) => HashType::Ed25519Signature,