Skip to content

Commit

Permalink
Rename Transaction type and json error
Browse files Browse the repository at this point in the history
  • Loading branch information
azarovh committed Dec 20, 2024
1 parent 1c8c0b4 commit 48e2384
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 25 deletions.
16 changes: 8 additions & 8 deletions node-gui/backend/src/backend_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ use super::{
messages::{
AccountInfo, AddressInfo, BackendEvent, BackendRequest, CreateDelegationRequest,
DecommissionPoolRequest, DelegateStakingRequest, EncryptionAction, EncryptionState,
SendDelegateToAddressRequest, SendRequest, StakeRequest, Transaction, TransactionInfo,
WalletId, WalletInfo,
SendDelegateToAddressRequest, SendRequest, SignedTransactionWrapper, StakeRequest,
TransactionInfo, WalletId, WalletInfo,
},
p2p_event_handler::P2pEventHandler,
parse_address, parse_coin_amount,
Expand Down Expand Up @@ -723,7 +723,7 @@ impl Backend {

Ok(TransactionInfo {
wallet_id,
tx: Transaction::new(tx),
tx: SignedTransactionWrapper::new(tx),
})
}

Expand Down Expand Up @@ -774,7 +774,7 @@ impl Backend {

Ok(TransactionInfo {
wallet_id,
tx: Transaction::new(tx),
tx: SignedTransactionWrapper::new(tx),
})
}

Expand Down Expand Up @@ -806,7 +806,7 @@ impl Backend {

Ok(TransactionInfo {
wallet_id,
tx: Transaction::new(tx),
tx: SignedTransactionWrapper::new(tx),
})
}

Expand Down Expand Up @@ -838,7 +838,7 @@ impl Backend {

Ok(TransactionInfo {
wallet_id,
tx: Transaction::new(tx),
tx: SignedTransactionWrapper::new(tx),
})
}

Expand Down Expand Up @@ -877,7 +877,7 @@ impl Backend {

Ok(TransactionInfo {
wallet_id,
tx: Transaction::new(tx),
tx: SignedTransactionWrapper::new(tx),
})
}

Expand Down Expand Up @@ -920,7 +920,7 @@ impl Backend {

Ok(TransactionInfo {
wallet_id,
tx: Transaction::new(tx),
tx: SignedTransactionWrapper::new(tx),
})
}

Expand Down
6 changes: 2 additions & 4 deletions node-gui/backend/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ use super::{account_id::AccountId, messages::WalletId};
pub enum BackendError {
#[error("Wallet error: {0}")]
WalletError(String),
#[error("RPC error: {0}")]
RpcError(String),
#[error("Json error: {0}")]
JsonError(String),
#[error("Convertion to dehexify json error: {0}")]
ConversionToDehexifyJsonError(String),
#[error("Unknown wallet index: {0:?}")]
UnknownWalletIndex(WalletId),
#[error("Unknown account index: {0:?}/{0:?}")]
Expand Down
10 changes: 5 additions & 5 deletions node-gui/backend/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ pub struct SendDelegateToAddressRequest {
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Transaction {
pub struct SignedTransactionWrapper {
#[serde(with = "hex_encoded_serialization")]
tx: SignedTransaction,
}

impl Transaction {
impl SignedTransactionWrapper {
pub fn new(tx: SignedTransaction) -> Self {
Self { tx }
}
Expand All @@ -171,14 +171,14 @@ impl Transaction {

pub fn to_json(&self, config: &ChainConfig) -> Result<serde_json::Value, BackendError> {
common::address::dehexify::to_dehexified_json(config, self.tx.transaction())
.map_err(|e| BackendError::JsonError(e.to_string()))
.map_err(|e| BackendError::ConversionToDehexifyJsonError(e.to_string()))
}
}

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct TransactionInfo {
pub wallet_id: WalletId,
pub tx: Transaction,
pub tx: SignedTransactionWrapper,
}

#[derive(Debug)]
Expand Down Expand Up @@ -236,7 +236,7 @@ pub enum BackendRequest {

SubmitTx {
wallet_id: WalletId,
tx: Transaction,
tx: SignedTransactionWrapper,
},

TransactionList {
Expand Down
6 changes: 3 additions & 3 deletions node-gui/src/main_window/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use iced_aw::widgets::Modal;
use logging::log;
use node_gui_backend::{
messages::{
BackendEvent, BackendRequest, EncryptionAction, Transaction, TransactionInfo, WalletId,
WalletInfo,
BackendEvent, BackendRequest, EncryptionAction, SignedTransactionWrapper, TransactionInfo,
WalletId, WalletInfo,
},
BackendSender, ImportOrCreate, InitializedNode,
};
Expand Down Expand Up @@ -188,7 +188,7 @@ pub enum MainWindowMessage {

SubmitTx {
wallet_id: WalletId,
tx: Transaction,
tx: SignedTransactionWrapper,
},

CopyToClipboard(String),
Expand Down
10 changes: 5 additions & 5 deletions node-gui/src/widgets/confirm_broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ use iced::{
use iced_aw::Card;

use common::chain::ChainConfig;
use node_gui_backend::messages::Transaction;
use node_gui_backend::messages::SignedTransactionWrapper;

pub struct ConfirmBroadcast<Message> {
on_submit: Box<dyn Fn(Transaction) -> Message>,
on_submit: Box<dyn Fn(SignedTransactionWrapper) -> Message>,
on_close: Box<dyn Fn() -> Message>,
on_copy_to_clipboard: Box<dyn Fn(String) -> Message>,
tx: Transaction,
tx: SignedTransactionWrapper,
chain_config: Arc<ChainConfig>,
}

pub fn new_confirm_broadcast<Message>(
on_submit: Box<dyn Fn(Transaction) -> Message>,
on_submit: Box<dyn Fn(SignedTransactionWrapper) -> Message>,
on_close: Box<dyn Fn() -> Message>,
on_copy_to_clipboard: Box<dyn Fn(String) -> Message>,
tx: Transaction,
tx: SignedTransactionWrapper,
chain_config: Arc<ChainConfig>,
) -> ConfirmBroadcast<Message> {
ConfirmBroadcast {
Expand Down

0 comments on commit 48e2384

Please sign in to comment.