Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/track build signed submitted for tx log #626

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
421 changes: 381 additions & 40 deletions full-service/src/db/transaction_log.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions full-service/src/db/txo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::{
account::{AccountID, AccountModel},
assigned_subaddress::AssignedSubaddressModel,
models::{Account, AssignedSubaddress, NewTransactionOutputTxo, NewTxo, Txo},
transaction_log::TransactionID,
transaction_log::TransactionId,
Conn, WalletDbError,
},
service::models::tx_proposal::OutputTxo,
Expand Down Expand Up @@ -142,7 +142,7 @@ pub trait TxoModel {
fn create_new_output(
output_txo: &OutputTxo,
is_change: bool,
transaction_id: &TransactionID,
transaction_id: &TransactionId,
conn: &Conn,
) -> Result<(), WalletDbError>;

Expand Down Expand Up @@ -395,7 +395,7 @@ impl TxoModel for Txo {
fn create_new_output(
output_txo: &OutputTxo,
is_change: bool,
transaction_id: &TransactionID,
transaction_id: &TransactionId,
conn: &Conn,
) -> Result<(), WalletDbError> {
use crate::db::schema::txos;
Expand Down
6 changes: 3 additions & 3 deletions full-service/src/json_rpc/v1/api/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
db::{
account::AccountID,
transaction_log::TransactionID,
transaction_log::TransactionId,
txo::{TxoID, TxoStatus},
},
json_rpc::{
Expand Down Expand Up @@ -236,7 +236,7 @@ where
.map_err(format_error)?;
JsonCommandResponse::build_split_txo_transaction {
tx_proposal: TxProposal::try_from(&tx_proposal).map_err(format_error)?,
transaction_log_id: TransactionID::from(&tx_proposal.tx).to_string(),
transaction_log_id: TransactionId::from(&tx_proposal.tx).to_string(),
}
}
JsonCommandRequest::build_transaction {
Expand Down Expand Up @@ -286,7 +286,7 @@ where

JsonCommandResponse::build_transaction {
tx_proposal: TxProposal::try_from(&tx_proposal).map_err(format_error)?,
transaction_log_id: TransactionID::from(&tx_proposal.tx).to_string(),
transaction_log_id: TransactionId::from(&tx_proposal.tx).to_string(),
}
}
JsonCommandRequest::check_b58_type { b58_code } => {
Expand Down
1 change: 1 addition & 0 deletions full-service/src/json_rpc/v1/models/transaction_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl From<&db::transaction_log::TxStatus> for TxStatus {
fn from(tx_status: &db::transaction_log::TxStatus) -> Self {
match tx_status {
db::transaction_log::TxStatus::Built => TxStatus::Built,
db::transaction_log::TxStatus::Signed => TxStatus::Built,
db::transaction_log::TxStatus::Pending => TxStatus::Pending,
db::transaction_log::TxStatus::Succeeded => TxStatus::Succeeded,
db::transaction_log::TxStatus::Failed => TxStatus::Failed,
Expand Down
6 changes: 3 additions & 3 deletions full-service/src/json_rpc/v2/api/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
db::{
account::AccountID,
transaction_log::TransactionID,
transaction_log::TransactionId,
txo::{TxoID, TxoStatus},
},
json_rpc::{
Expand Down Expand Up @@ -242,7 +242,7 @@ where

JsonCommandResponse::build_burn_transaction {
tx_proposal: TxProposalJSON::try_from(&tx_proposal).map_err(format_error)?,
transaction_log_id: TransactionID::from(&tx_proposal.tx).to_string(),
transaction_log_id: TransactionId::from(&tx_proposal.tx).to_string(),
}
}
JsonCommandRequest::build_transaction {
Expand Down Expand Up @@ -293,7 +293,7 @@ where

JsonCommandResponse::build_transaction {
tx_proposal: TxProposalJSON::try_from(&tx_proposal).map_err(format_error)?,
transaction_log_id: TransactionID::from(&tx_proposal.tx).to_string(),
transaction_log_id: TransactionId::from(&tx_proposal.tx).to_string(),
}
}
JsonCommandRequest::build_unsigned_burn_transaction {
Expand Down
2 changes: 1 addition & 1 deletion full-service/src/json_rpc/v2/models/public_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl From<&mc_account_keys::PublicAddress> for PublicAddress {
spend_public_key: hex::encode(src.spend_public_key().to_bytes()),
fog_report_url: src.fog_report_url().map(|url| url.to_string()),
fog_report_id: src.fog_report_id().map(|id| id.to_string()),
fog_authority_sig: src.fog_authority_sig().map(|sig| hex::encode(sig)),
fog_authority_sig: src.fog_authority_sig().map(hex::encode),
}
}
}
4 changes: 2 additions & 2 deletions full-service/src/service/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::{
db::{
models::{TransactionLog, Txo},
transaction_log::{TransactionID, TransactionLogModel},
transaction_log::{TransactionId, TransactionLogModel},
txo::TxoModel,
},
WalletService,
Expand Down Expand Up @@ -169,7 +169,7 @@ where
fn get_transaction_object(&self, transaction_id_hex: &str) -> Result<Tx, LedgerServiceError> {
let conn = self.get_conn()?;
let transaction_log =
TransactionLog::get(&TransactionID(transaction_id_hex.to_string()), &conn)?;
TransactionLog::get(&TransactionId(transaction_id_hex.to_string()), &conn)?;
let tx: Tx = mc_util_serial::decode(&transaction_log.tx)?;
Ok(tx)
}
Expand Down
4 changes: 2 additions & 2 deletions full-service/src/service/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ where
let mut default_fee_token_id = Mob::ID;

for (recipient_public_address, amount) in addresses_and_amounts {
if !self.verify_address(recipient_public_address).is_ok() {
if self.verify_address(recipient_public_address).is_err() {
return Err(TransactionServiceError::InvalidPublicAddress(
recipient_public_address.to_string(),
));
Expand Down Expand Up @@ -448,7 +448,7 @@ where
let account_key: AccountKey = mc_util_serial::decode(&account.account_key)?;
let tx_proposal = unsigned_tx_proposal.sign(&account_key)?;

TransactionLog::log_built(tx_proposal.clone(), "".to_string(), account_id_hex, &conn)?;
TransactionLog::log_signed(tx_proposal.clone(), "".to_string(), account_id_hex, &conn)?;

Ok(tx_proposal)
})
Expand Down
4 changes: 2 additions & 2 deletions full-service/src/service/transaction_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::{
db::{
models::TransactionLog,
transaction_log::{AssociatedTxos, TransactionID, TransactionLogModel, ValueMap},
transaction_log::{AssociatedTxos, TransactionId, TransactionLogModel, ValueMap},
WalletDbError,
},
error::WalletServiceError,
Expand Down Expand Up @@ -88,7 +88,7 @@ where
) -> Result<(TransactionLog, AssociatedTxos, ValueMap), TransactionLogServiceError> {
let conn = self.get_conn()?;
let transaction_log =
TransactionLog::get(&TransactionID(transaction_id_hex.to_string()), &conn)?;
TransactionLog::get(&TransactionId(transaction_id_hex.to_string()), &conn)?;
let associated = transaction_log.get_associated_txos(&conn)?;
let value_map = transaction_log.value_map(&conn)?;

Expand Down