From 74ac1620859f9ce0b533847f0d038c7bed5e8d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Tue, 26 Aug 2025 09:05:26 +0200 Subject: [PATCH 1/2] Rust SDK: aliasing to_base58_check to to_b58check for Signature And `from_base58_check` to `from_b58check` --- sdk/rust/crypto/src/signature.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/rust/crypto/src/signature.rs b/sdk/rust/crypto/src/signature.rs index 01d3cb8f2458..66a571c3afa4 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, -- GitLab From fd60cc2e34ce6c509733a2551a466bebc9fac38b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Tue, 26 Aug 2025 09:09:37 +0200 Subject: [PATCH 2/2] SDK/bindings: use `bind_hash` macro for signature Now that Signature implements `from_b58check` and `to_b58check` --- contrib/sdk-bindings/rust/src/keys.rs | 30 +-------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/contrib/sdk-bindings/rust/src/keys.rs b/contrib/sdk-bindings/rust/src/keys.rs index c4019c130af6..7b451f1205f5 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] -- GitLab