Skip to content

Commit c79ccc0

Browse files
nuttycomstr4d
andcommitted
Apply suggestions from code review
Co-authored-by: Jack Grigg <[email protected]>
1 parent ec5d31d commit c79ccc0

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

components/zcash_address/CHANGELOG.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ and this library adheres to Rust's notion of
77

88
## [Unreleased]
99

10-
### Added
11-
- A blanket impl of `zcash_address::convert::TryFromAddress` for `(NetworkType, T)`
12-
has been added to replace the similar impl that had previously been provided
13-
bounded by `TryFromRawAddress`.
10+
### Changed
11+
- The following methods with generic parameter `T` now require `T: TryFromAddress`
12+
instead of `T: TryFromRawAddress`:
13+
- `zcash_address::ZcashAddress::convert_if_network`
14+
- The blanket `impl zcash_address::TryFromAddress for (NetworkType, T)`
1415

1516
### Removed
16-
- `zcash_address::convert::TryFromRawAddress` has been removed. All of its
17+
- `zcash_address::TryFromRawAddress` has been removed. All of its
1718
functions can be served by `TryFromAddress` impls, and its presence adds
1819
complexity and some pitfalls to the API.
1920

components/zcash_address/src/kind/unified/address.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ impl SealedItem for Receiver {
6363
///
6464
/// ```
6565
/// # use core::convert::Infallible;
66+
/// # use zcash_protocol::consensus::NetworkType;
6667
/// use zcash_address::{
6768
/// unified::{self, Container, Encoding},
68-
/// ConversionError, TryFromRawAddress, ZcashAddress,
69+
/// ConversionError, TryFromAddress, ZcashAddress,
6970
/// };
7071
///
7172
/// # #[cfg(not(feature = "std"))]
@@ -80,12 +81,15 @@ impl SealedItem for Receiver {
8081
///
8182
/// // Or we can parse via `ZcashAddress` (which you should do):
8283
/// struct MyUnifiedAddress(unified::Address);
83-
/// impl TryFromRawAddress for MyUnifiedAddress {
84+
/// impl TryFromAddress for MyUnifiedAddress {
8485
/// // In this example we aren't checking the validity of the
8586
/// // inner Unified Address, but your code should do so!
8687
/// type Error = Infallible;
8788
///
88-
/// fn try_from_raw_unified(ua: unified::Address) -> Result<Self, ConversionError<Self::Error>> {
89+
/// fn try_from_unified(
90+
/// _net: NetworkType,
91+
/// ua: unified::Address
92+
/// ) -> Result<Self, ConversionError<Self::Error>> {
8993
/// Ok(MyUnifiedAddress(ua))
9094
/// }
9195
/// }

components/zcash_address/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
//! use std::ffi::{CStr, c_char, c_void};
6363
//! use std::ptr;
6464
//!
65-
//! use zcash_address::{ConversionError, ZcashAddress};
65+
//! use zcash_address::{ConversionError, TryFromAddress, ZcashAddress};
6666
//! use zcash_protocol::consensus::NetworkType;
6767
//!
6868
//! // Functions that return a pointer to a heap-allocated address of the given kind in
@@ -78,6 +78,7 @@
7878
//! type Error = &'static str;
7979
//!
8080
//! fn try_from_sapling(
81+
//! _net: NetworkType,
8182
//! data: [u8; 43],
8283
//! ) -> Result<Self, ConversionError<Self::Error>> {
8384
//! let parsed = unsafe { addr_from_sapling(data[..].as_ptr()) };
@@ -89,6 +90,7 @@
8990
//! }
9091
//!
9192
//! fn try_from_transparent_p2pkh(
93+
//! _net: NetworkType,
9294
//! data: [u8; 20],
9395
//! ) -> Result<Self, ConversionError<Self::Error>> {
9496
//! let parsed = unsafe { addr_from_transparent_p2pkh(data[..].as_ptr()) };
@@ -145,8 +147,7 @@ mod kind;
145147
#[cfg(any(test, feature = "test-dependencies"))]
146148
pub mod test_vectors;
147149

148-
use convert::Converter;
149-
pub use convert::{ConversionError, ToAddress, TryFromAddress, UnsupportedAddress};
150+
pub use convert::{ConversionError, Converter, ToAddress, TryFromAddress, UnsupportedAddress};
150151
pub use encoding::ParseError;
151152
pub use kind::unified;
152153
use kind::unified::Receiver;
@@ -242,11 +243,10 @@ impl ZcashAddress {
242243

243244
/// Converts this address into another type, if it matches the expected network.
244245
///
245-
/// `convert_if_network` can convert into any type that implements the
246-
/// [`TryFromRawAddress`] trait. This enables `ZcashAddress` to be used as a common
247-
/// parsing and serialization interface for Zcash addresses, while delegating
248-
/// operations on those addresses (such as constructing transactions) to downstream
249-
/// crates.
246+
/// `convert_if_network` can convert into any type that implements the [`TryFromAddress`]
247+
/// trait. This enables `ZcashAddress` to be used as a common parsing and serialization
248+
/// interface for Zcash addresses, while delegating operations on those addresses (such as
249+
/// constructing transactions) to downstream crates.
250250
///
251251
/// If you want to get the encoded string for this address, use the [`encode`]
252252
/// method or the [`Display` implementation] via [`address.to_string()`] instead.

zcash_keys/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this library adheres to Rust's notion of
77
## [Unreleased]
88

99
### Changed
10-
- Updated to `zcash_address 0.8.0`
10+
- Migrated to `zcash_address 0.8`.
1111

1212
## [0.4.1, 0.5.1, 0.6.1, 0.7.1, 0.8.1] - 2025-05-09
1313

zcash_transparent/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this library adheres to Rust's notion of
88
## [Unreleased]
99

1010
### Changed
11-
- Updated to `zcash_address 0.8.0`
11+
- Migrated to `zcash_address 0.8`.
1212

1313
## [0.2.3] - 2025-04-04
1414

0 commit comments

Comments
 (0)