diff --git a/src/api/search_transactions.rs b/src/api/search_transactions.rs index cabcb52..389d59d 100644 --- a/src/api/search_transactions.rs +++ b/src/api/search_transactions.rs @@ -513,9 +513,10 @@ impl From 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), @@ -531,9 +532,10 @@ impl From 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), @@ -547,7 +549,7 @@ impl From 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), diff --git a/tests/snapshots/search_transactions__search_transactions_failed.snap b/tests/snapshots/search_transactions__search_transactions_failed.snap index d4b3418..7861889 100644 --- a/tests/snapshots/search_transactions__search_transactions_failed.snap +++ b/tests/snapshots/search_transactions__search_transactions_failed.snap @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 {