Skip to content

Commit ea602ba

Browse files
Revert "[Zcash]: Add google::protobuf::Any chain_specific parameters to BitcoinV2" (#4216)
This reverts commit e801cf0.
1 parent e801cf0 commit ea602ba

File tree

31 files changed

+120
-172
lines changed

31 files changed

+120
-172
lines changed

rust/chains/tw_bitcoin/src/modules/planner/psbt_planner.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ impl<Context: UtxoContext> PsbtPlanner<Context> {
6868
let out_point = Proto::OutPoint {
6969
hash: txin.previous_output.hash.to_vec().into(),
7070
vout: txin.previous_output.index,
71-
..Proto::OutPoint::default()
7271
};
7372
let sequence = Proto::mod_Input::Sequence {
7473
sequence: txin.sequence,

rust/chains/tw_bitcoin/src/modules/protobuf_builder/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ impl ProtobufBuilder {
3232
out_point: Some(Proto::OutPoint {
3333
hash: Cow::from(input.previous_output.hash.to_vec()),
3434
vout: input.previous_output.index,
35-
..Proto::OutPoint::default()
3635
}),
3736
sequence: input.sequence,
3837
script_sig: Self::script_data(&input.script_sig),

rust/chains/tw_greenfield/src/public_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ impl JsonPublicKey for GreenfieldPublicKey {
2020
}
2121

2222
impl ProtobufPublicKey for GreenfieldPublicKey {
23-
fn to_proto(&self) -> google::protobuf::Any<'static> {
23+
fn to_proto(&self) -> google::protobuf::Any {
2424
let proto = tw_cosmos_sdk::proto::cosmos::crypto::eth::ethsecp256k1::PubKey {
25-
key: self.0.compressed().to_vec().into(),
25+
key: self.0.compressed().to_vec(),
2626
};
2727
to_any(&proto)
2828
}

rust/chains/tw_greenfield/src/transaction/message/transfer_out.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ pub struct GreenfieldTransferOut {
6565
impl CosmosMessage for GreenfieldTransferOut {
6666
fn to_proto(&self) -> SigningResult<ProtobufMessage> {
6767
let msg = GreenfieldProto::bridge::MsgTransferOut {
68-
from: self.from.to_string().into(),
69-
to: self.to.to_string().into(),
68+
from: self.from.to_string(),
69+
to: self.to.to_string(),
7070
amount: Some(build_coin(&self.amount)),
7171
};
7272
Ok(to_any(&msg))

rust/chains/tw_native_evmos/src/ethermint_public_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl JsonPublicKey for EthermintEthSecp256PublicKey {
5353
}
5454

5555
impl ProtobufPublicKey for EthermintEthSecp256PublicKey {
56-
fn to_proto(&self) -> google::protobuf::Any<'static> {
56+
fn to_proto(&self) -> google::protobuf::Any {
5757
self.0.to_proto()
5858
}
5959
}

rust/chains/tw_native_injective/src/injective_public_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl JsonPublicKey for InjectiveEthSecp256PublicKey {
5353
}
5454

5555
impl ProtobufPublicKey for InjectiveEthSecp256PublicKey {
56-
fn to_proto(&self) -> google::protobuf::Any<'static> {
56+
fn to_proto(&self) -> google::protobuf::Any {
5757
self.0.to_proto()
5858
}
5959
}

rust/tw_cosmos_sdk/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ fn main() {
5858
)
5959
.expect("Error configuring pb-rs builder")
6060
.gen_info(true)
61+
.dont_use_cow(true)
6162
.build();
6263
FileDescriptor::run(&out_protos).expect("Error generating proto files");
6364
}

rust/tw_cosmos_sdk/src/modules/serializer/protobuf_serializer.rs

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ use crate::public_key::ProtobufPublicKey;
1010
use crate::transaction::{
1111
Coin, Fee, SignMode, SignedTransaction, SignerInfo, TxBody, UnsignedTransaction,
1212
};
13-
use std::borrow::Cow;
1413
use std::marker::PhantomData;
1514
use tw_coin_entry::error::prelude::*;
1615
use tw_memory::Data;
1716
use tw_proto::serialize;
1817

19-
pub fn build_coin(coin: &Coin) -> base_proto::Coin<'static> {
18+
pub fn build_coin(coin: &Coin) -> base_proto::Coin {
2019
base_proto::Coin {
21-
amount: coin.amount.to_string().into(),
22-
denom: coin.denom.clone().into(),
20+
amount: coin.amount.to_string(),
21+
denom: coin.denom.clone(),
2322
}
2423
}
2524

@@ -38,73 +37,62 @@ pub struct SignDirectArgs {
3837
impl<Context: CosmosContext> ProtobufSerializer<Context> {
3938
/// Serializes a signed transaction into the Cosmos [`tx_proto::TxRaw`] message.
4039
/// [`tx_proto::TxRaw`] can be broadcasted to the network.
41-
pub fn build_signed_tx(
42-
signed: &SignedTransaction<Context>,
43-
) -> SigningResult<tx_proto::TxRaw<'static>> {
40+
pub fn build_signed_tx(signed: &SignedTransaction<Context>) -> SigningResult<tx_proto::TxRaw> {
4441
let tx_body = Self::build_tx_body(&signed.tx_body)?;
45-
let body_bytes = serialize(&tx_body)
46-
.expect("Unexpected error on tx_body serialization")
47-
.into();
42+
let body_bytes = serialize(&tx_body).expect("Unexpected error on tx_body serialization");
4843

4944
let auth_info = Self::build_auth_info(&signed.signer, &signed.fee);
50-
let auth_info_bytes = serialize(&auth_info)
51-
.expect("Unexpected error on auth_info serialization")
52-
.into();
45+
let auth_info_bytes =
46+
serialize(&auth_info).expect("Unexpected error on auth_info serialization");
5347

5448
Ok(tx_proto::TxRaw {
5549
body_bytes,
5650
auth_info_bytes,
57-
signatures: vec![signed.signature.clone().into()],
51+
signatures: vec![signed.signature.clone()],
5852
})
5953
}
6054

61-
pub fn build_direct_signed_tx(
62-
args: &SignDirectArgs,
63-
signature: Data,
64-
) -> tx_proto::TxRaw<'static> {
55+
pub fn build_direct_signed_tx(args: &SignDirectArgs, signature: Data) -> tx_proto::TxRaw {
6556
tx_proto::TxRaw {
66-
body_bytes: args.tx_body.clone().into(),
67-
auth_info_bytes: args.auth_info.clone().into(),
68-
signatures: vec![signature.into()],
57+
body_bytes: args.tx_body.clone(),
58+
auth_info_bytes: args.auth_info.clone(),
59+
signatures: vec![signature],
6960
}
7061
}
7162

7263
/// Serializes an unsigned transaction into the Cosmos [`tx_proto::SignDoc`] message.
7364
/// [`tx_proto::SignDoc`] is used to generate a transaction prehash and sign it.
7465
pub fn build_sign_doc(
7566
unsigned: &UnsignedTransaction<Context>,
76-
) -> SigningResult<tx_proto::SignDoc<'static>> {
67+
) -> SigningResult<tx_proto::SignDoc> {
7768
let tx_body = Self::build_tx_body(&unsigned.tx_body)?;
78-
let body_bytes = serialize(&tx_body)
79-
.expect("Unexpected error on tx_body serialization")
80-
.into();
69+
let body_bytes = serialize(&tx_body).expect("Unexpected error on tx_body serialization");
8170

8271
let auth_info = Self::build_auth_info(&unsigned.signer, &unsigned.fee);
83-
let auth_info_bytes = serialize(&auth_info)
84-
.expect("Unexpected error on auth_info serialization")
85-
.into();
72+
let auth_info_bytes =
73+
serialize(&auth_info).expect("Unexpected error on auth_info serialization");
8674

8775
Ok(tx_proto::SignDoc {
8876
body_bytes,
8977
auth_info_bytes,
90-
chain_id: unsigned.chain_id.clone().into(),
78+
chain_id: unsigned.chain_id.clone(),
9179
account_number: unsigned.account_number,
9280
})
9381
}
9482

95-
pub fn build_direct_sign_doc(args: &SignDirectArgs) -> tx_proto::SignDoc<'static> {
83+
pub fn build_direct_sign_doc(args: &SignDirectArgs) -> tx_proto::SignDoc {
9684
tx_proto::SignDoc {
97-
body_bytes: args.tx_body.clone().into(),
98-
auth_info_bytes: args.auth_info.clone().into(),
99-
chain_id: args.chain_id.clone().into(),
85+
body_bytes: args.tx_body.clone(),
86+
auth_info_bytes: args.auth_info.clone(),
87+
chain_id: args.chain_id.clone(),
10088
account_number: args.account_number,
10189
}
10290
}
10391

10492
pub fn build_auth_info(
10593
signer: &SignerInfo<Context::PublicKey>,
10694
fee: &Fee<Context::Address>,
107-
) -> tx_proto::AuthInfo<'static> {
95+
) -> tx_proto::AuthInfo {
10896
tx_proto::AuthInfo {
10997
signer_infos: vec![Self::build_signer_info(signer)],
11098
fee: Some(Self::build_fee(fee)),
@@ -113,7 +101,7 @@ impl<Context: CosmosContext> ProtobufSerializer<Context> {
113101
}
114102
}
115103

116-
pub fn build_tx_body(tx_body: &TxBody) -> SigningResult<tx_proto::TxBody<'static>> {
104+
pub fn build_tx_body(tx_body: &TxBody) -> SigningResult<tx_proto::TxBody> {
117105
let messages: Vec<_> = tx_body
118106
.messages
119107
.iter()
@@ -122,14 +110,14 @@ impl<Context: CosmosContext> ProtobufSerializer<Context> {
122110

123111
Ok(tx_proto::TxBody {
124112
messages,
125-
memo: tx_body.memo.clone().into(),
113+
memo: tx_body.memo.clone(),
126114
timeout_height: tx_body.timeout_height,
127115
extension_options: Vec::default(),
128116
non_critical_extension_options: Vec::default(),
129117
})
130118
}
131119

132-
pub fn build_signer_info(signer: &SignerInfo<Context::PublicKey>) -> tx_proto::SignerInfo<'static> {
120+
pub fn build_signer_info(signer: &SignerInfo<Context::PublicKey>) -> tx_proto::SignerInfo {
133121
use tx_proto::mod_ModeInfo::{self as mode_info, OneOfsum as SumEnum};
134122

135123
// Single is the mode info for a single signer. It is structured as a message
@@ -147,13 +135,13 @@ impl<Context: CosmosContext> ProtobufSerializer<Context> {
147135
}
148136
}
149137

150-
fn build_fee(fee: &Fee<Context::Address>) -> tx_proto::Fee<'static> {
138+
fn build_fee(fee: &Fee<Context::Address>) -> tx_proto::Fee {
151139
tx_proto::Fee {
152140
amount: fee.amounts.iter().map(build_coin).collect(),
153141
gas_limit: fee.gas_limit,
154142
// Ignore `payer` and `granter` even if they set.
155-
payer: Cow::default(),
156-
granter: Cow::default(),
143+
payer: String::default(),
144+
granter: String::default(),
157145
}
158146
}
159147

rust/tw_cosmos_sdk/src/modules/tx_builder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,10 @@ where
632632

633633
let grant_msg = match auth.grant_type {
634634
ProtoGrantType::grant_stake(ref stake) => google::protobuf::Any {
635-
type_url: STAKE_AUTHORIZATION_MSG_TYPE.to_string().into(),
635+
type_url: STAKE_AUTHORIZATION_MSG_TYPE.to_string(),
636636
value: serialize(stake)
637637
.tw_err(|_| SigningErrorType::Error_invalid_params)
638-
.context("Error serializing Grant Stake Protobuf message")?
639-
.into(),
638+
.context("Error serializing Grant Stake Protobuf message")?,
640639
},
641640
ProtoGrantType::None => {
642641
return SigningError::err(SigningErrorType::Error_invalid_params)

rust/tw_cosmos_sdk/src/public_key/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub trait CosmosPublicKey: JsonPublicKey + ProtobufPublicKey + Sized {
3939
}
4040

4141
pub trait ProtobufPublicKey {
42-
fn to_proto(&self) -> google::protobuf::Any<'static>;
42+
fn to_proto(&self) -> google::protobuf::Any;
4343
}
4444

4545
pub trait JsonPublicKey {

0 commit comments

Comments
 (0)