[ZCash] Remove zcash paste dependency (#28333)

Remove zcash paste dependency
Resolves https://github.com/brave/brave-browser/issues/44971
This commit is contained in:
cypt4
2025-03-28 10:33:09 +00:00
committed by GitHub
parent bac35d1c95
commit bb3d4d4b5e
4 changed files with 42 additions and 31 deletions
@@ -134,7 +134,6 @@ rust_static_library("rust_lib") {
"//brave/third_party/rust/nonempty/v0_7:lib",
"//brave/third_party/rust/orchard/v0_8:lib",
"//brave/third_party/rust/pasta_curves/v0_5:lib",
"//brave/third_party/rust/paste/v1:lib",
"//brave/third_party/rust/rand/v0_8:lib",
"//brave/third_party/rust/shardtree/v0_3:lib",
"//brave/third_party/rust/zcash_note_encryption/v0_4:lib",
@@ -13,7 +13,6 @@ zcash_primitives = { version = "0.15.1", default-features = false }
zcash_note_encryption = "0.4"
zcash_client_backend = { version = "0.12.1", default-features = false }
shardtree = { version="0.3.2", features=["legacy-api"] }
paste = "1"
[lib]
name = "zcash"
@@ -94,30 +94,29 @@ macro_rules! impl_result {
}
macro_rules! impl_result_option_wrapper {
($t: ty, $rt: ident, $l: ident) => {
paste::item! {
fn [<wrap_ $l>](item: $t) -> Box<$rt> {
Box::new($rt(Ok(Option::Some(item))))
}
fn [<wrap_ $l _error>]() -> Box<$rt> {
Box::new($rt(Err(Error::ShardStoreError)))
}
fn [<wrap_ $l _none>]() -> Box<$rt> {
Box::new($rt(Ok(Option::None)))
}
($t:ty, $rt:ident, $wrap_l:ident, $wrap_l_error:ident, $wrap_l_none:ident) => {
fn $wrap_l(item: $t) -> Box<$rt> {
Box::new($rt(Ok(Some(item))))
}
fn $wrap_l_error() -> Box<$rt> {
Box::new($rt(Err(Error::ShardStoreError)))
}
fn $wrap_l_none() -> Box<$rt> {
Box::new($rt(Ok(None)))
}
};
}
macro_rules! impl_result_wrapper {
($t: ty, $rt: ident, $l: ident) => {
paste::item! {
fn [<wrap_ $l>](item: $t) -> Box<$rt> {
Box::new($rt(Ok(item)))
}
fn [<wrap_ $l _error>]() -> Box<$rt> {
Box::new($rt(Err(Error::ShardStoreError)))
}
($t:ty, $rt:ident, $wrap_l:ident, $wrap_l_error:ident) => {
fn $wrap_l(item: $t) -> Box<$rt> {
Box::new($rt(Ok(item)))
}
fn $wrap_l_error() -> Box<$rt> {
Box::new($rt(Err(Error::ShardStoreError)))
}
};
}
@@ -733,22 +732,37 @@ struct CxxCheckpointsResultWrapper(Result<Vec<CxxOrchardCheckpointBundle>, Error
struct CxxShardRootsResultWrapper(Result<Vec<CxxOrchardShardAddress>, Error>);
struct CxxCheckpointCountResultWrapper(Result<usize, Error>);
impl_result_option_wrapper!(CxxOrchardShard, CxxOrchardShardResultWrapper, shard_tree_shard);
impl_result_option_wrapper!(
CxxOrchardShard,
CxxOrchardShardResultWrapper,
wrap_shard_tree_shard,
wrap_shard_tree_shard_error,
wrap_shard_tree_shard_none);
impl_result_option_wrapper!(
CxxOrchardShardTreeCap,
CxxOrchardShardTreeCapResultWrapper,
shard_tree_cap
);
impl_result_option_wrapper!(u32, CxxCheckpointIdResultWrapper, checkpoint_id);
wrap_shard_tree_cap,
wrap_shard_tree_cap_error,
wrap_shard_tree_cap_none);
impl_result_option_wrapper!(u32, CxxCheckpointIdResultWrapper,
wrap_checkpoint_id,
wrap_checkpoint_id_error,
wrap_checkpoint_id_none);
impl_result_option_wrapper!(
CxxOrchardCheckpointBundle,
CxxCheckpointBundleResultWrapper,
checkpoint_bundle
wrap_checkpoint_bundle,
wrap_checkpoint_bundle_error,
wrap_checkpoint_bundle_none
);
impl_result_wrapper!(bool, CxxBoolResultWrapper, bool);
impl_result_wrapper!(usize, CxxCheckpointCountResultWrapper, checkpoint_count);
impl_result_wrapper!(Vec<CxxOrchardCheckpointBundle>, CxxCheckpointsResultWrapper, checkpoints);
impl_result_wrapper!(Vec<CxxOrchardShardAddress>, CxxShardRootsResultWrapper, shard_tree_roots);
impl_result_wrapper!(bool, CxxBoolResultWrapper,
wrap_bool, wrap_bool_error);
impl_result_wrapper!(usize, CxxCheckpointCountResultWrapper,
wrap_checkpoint_count, wrap_checkpoint_count_error);
impl_result_wrapper!(Vec<CxxOrchardCheckpointBundle>, CxxCheckpointsResultWrapper,
wrap_checkpoints, wrap_checkpoints_error);
impl_result_wrapper!(Vec<CxxOrchardShardAddress>, CxxShardRootsResultWrapper,
wrap_shard_tree_roots, wrap_shard_tree_roots_error);
fn generate_orchard_extended_spending_key_from_seed(
bytes: &[u8],
-1
View File
@@ -2373,7 +2373,6 @@ dependencies = [
"brave_wallet",
"cxx",
"orchard",
"paste",
"rand 0.8.5",
"shardtree",
"zcash_client_backend",