Skip to content

Commit

Permalink
Replaced code field of message Tx with code_hash.
Browse files Browse the repository at this point in the history
  • Loading branch information
murisi committed Jan 31, 2023
1 parent e7f1e42 commit c281592
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
12 changes: 3 additions & 9 deletions core/src/proto/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,7 @@ impl TryFrom<&[u8]> for Tx {
),
None => None,
};
let code = if tx.is_literal {
TxCode::Literal(tx.code)
} else {
TxCode::Hash(tx.code.try_into().expect("Unable to deserialize code hash"))
};
let code = TxCode::Hash(tx.code_hash.try_into().expect("Unable to deserialize code hash"));
Ok(Tx {
code,
data: tx.data,
Expand All @@ -261,8 +257,7 @@ impl From<Tx> for types::Tx {
};

types::Tx {
code: tx.code.code().unwrap_or(tx.code.code_hash().to_vec()),
is_literal: tx.code.is_literal(),
code_hash: tx.code.code_hash().to_vec(),
data: tx.data,
timestamp,
inner_tx,
Expand Down Expand Up @@ -402,8 +397,7 @@ impl Tx {
let timestamp = Some(self.timestamp.into());
let mut bytes = vec![];
types::Tx {
code: self.code.code_hash().to_vec(),
is_literal: false,
code_hash: self.code.code_hash().to_vec(),
data: self.data.clone(),
timestamp,
inner_tx: None,
Expand Down
2 changes: 1 addition & 1 deletion core/src/types/transaction/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod wrapper_tx {
use crate::types::token::Amount;
use crate::types::transaction::encrypted::EncryptedTx;
use crate::types::transaction::{
hash_tx, Hash, TxError, TxType,
Hash, TxError, TxType,
};

/// Minimum fee amount in micro NAMs
Expand Down
3 changes: 1 addition & 2 deletions proto/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import "google/protobuf/timestamp.proto";
package types;

message Tx {
bytes code = 1;
bytes code_hash = 1;
// TODO this optional is useless because it's default on proto3
optional bytes data = 2;
google.protobuf.Timestamp timestamp = 3;
optional bytes inner_tx = 4;
optional bytes inner_tx_code = 5;
bool is_literal = 6;
}

message Dkg { string data = 1; }
Expand Down

0 comments on commit c281592

Please sign in to comment.