Skip to content

Commit

Permalink
don't show amt on failed tx
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-iohk committed Nov 28, 2024
1 parent db74639 commit cd6d63c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 113 deletions.
8 changes: 5 additions & 3 deletions src/api/search_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,10 @@ impl From<UserCommand> for BlockTransaction {

// Operation 2: Account Creation Fee (if applicable)
if let Some(creation_fee) = &user_command.creation_fee {
let negated_creation_fee = format!("-{}", creation_fee);
operations.push(operation(
operation_index,
Some(&format!("-{}", creation_fee)),
if user_command.status == TransactionStatus::Applied { Some(&negated_creation_fee) } else { None },
receiver_account_id,
OperationType::AccountCreationFeeViaPayment,
Some(&user_command.status),
Expand All @@ -531,9 +532,10 @@ impl From<UserCommand> for BlockTransaction {
match user_command.command_type {
// Operation 3: Payment Source Decrement
UserCommandType::Payment => {
let negated_amt = format!("-{}", amt);
operations.push(operation(
operation_index,
Some(&format!("-{}", amt)),
if user_command.status == TransactionStatus::Applied { Some(&negated_amt) } else { None },
source_account_id,
OperationType::PaymentSourceDec,
Some(&user_command.status),
Expand All @@ -547,7 +549,7 @@ impl From<UserCommand> for BlockTransaction {
// Operation 4: Payment Receiver Increment
operations.push(operation(
operation_index,
Some(&amt),
if user_command.status == TransactionStatus::Applied { Some(&amt) } else { None },
receiver_account_id,
OperationType::PaymentReceiverInc,
Some(&user_command.status),
Expand Down
120 changes: 10 additions & 110 deletions tests/snapshots/search_transactions__search_transactions_failed.snap
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "-1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down Expand Up @@ -121,17 +111,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down Expand Up @@ -219,17 +199,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "-1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down Expand Up @@ -265,17 +235,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down Expand Up @@ -363,17 +323,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "-1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down Expand Up @@ -409,17 +359,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down Expand Up @@ -507,17 +447,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "-1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down Expand Up @@ -553,17 +483,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down Expand Up @@ -651,17 +571,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "-1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down Expand Up @@ -697,17 +607,7 @@ Ok(
),
},
),
amount: Some(
Amount {
value: "1500000",
currency: Currency {
symbol: "MINA",
decimals: 9,
metadata: None,
},
metadata: None,
},
),
amount: None,
coin_change: None,
metadata: Some(
Object {
Expand Down

0 comments on commit cd6d63c

Please sign in to comment.