Skip to content

Commit ca94488

Browse files
committed
Moves masp fee payment info to the wrapper tx
1 parent b8343f3 commit ca94488

2 files changed

Lines changed: 39 additions & 34 deletions

File tree

orm/src/transactions.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ pub struct WrapperTransactionDb {
135135
pub fee_token: String,
136136
pub gas_limit: String,
137137
pub gas_used: Option<i32>,
138+
pub masp_fee_payment: bool,
138139
pub amount_per_gas_unit: Option<String>,
139140
pub block_height: i32,
140141
pub exit_code: TransactionResultDb,
@@ -151,6 +152,7 @@ impl WrapperTransactionInsertDb {
151152
fee_token: tx.fee.gas_token.to_string(),
152153
gas_limit: tx.fee.gas,
153154
gas_used: tx.fee.gas_used.map(|gas| gas as i32),
155+
masp_fee_payment: tx.fee.masp_fee_payment,
154156
amount_per_gas_unit: Some(tx.fee.amount_per_gas_unit),
155157
block_height: tx.block_height as i32,
156158
exit_code: TransactionResultDb::from(tx.exit_code),

shared/src/transaction.rs

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,6 @@ pub struct InnerTransaction {
321321
pub data: Option<String>,
322322
pub extra_sections: HashMap<Id, Vec<u8>>,
323323
pub notes: u64,
324-
// FIXME: should this be on the wrapper?
325-
pub is_masp_fee_payment: bool,
326324
pub exit_code: TransactionExitStatus,
327325
}
328326

@@ -337,7 +335,7 @@ impl InnerTransaction {
337335
pub fn was_successful(&self, wrapper_tx: &WrapperTransaction) -> bool {
338336
self.exit_code == TransactionExitStatus::Applied
339337
&& (wrapper_tx.exit_code == TransactionExitStatus::Applied
340-
|| self.is_masp_fee_payment)
338+
|| wrapper_tx.fee.masp_fee_payment)
341339
}
342340

343341
pub fn is_ibc(&self) -> bool {
@@ -358,6 +356,7 @@ pub struct Fee {
358356
pub amount_per_gas_unit: String,
359357
pub gas_payer: Id,
360358
pub gas_token: Id,
359+
pub masp_fee_payment: bool,
361360
}
362361

363362
impl Transaction {
@@ -382,36 +381,7 @@ impl Transaction {
382381
match transaction.header().tx_type {
383382
TxType::Wrapper(wrapper) => {
384383
let wrapper_tx_id = Id::from(transaction.header_hash());
385-
let wrapper_tx_status =
386-
block_results.is_wrapper_tx_applied(&wrapper_tx_id);
387-
let gas_used = block_results
388-
.gas_used(&wrapper_tx_id)
389-
.map(|gas| gas.parse::<u64>().unwrap());
390-
391-
let fee = Fee {
392-
gas: Uint::from(wrapper.gas_limit).to_string(),
393-
gas_used,
394-
amount_per_gas_unit: wrapper
395-
.fee
396-
.amount_per_gas_unit
397-
.to_string_precise(),
398-
gas_payer: Id::from(wrapper.fee_payer()),
399-
gas_token: Id::from(wrapper.fee.token),
400-
};
401-
402-
let atomic = transaction.header().atomic;
403-
404-
let wrapper_tx = WrapperTransaction {
405-
tx_id: wrapper_tx_id.clone(),
406-
index,
407-
fee,
408-
atomic,
409-
block_height,
410-
exit_code: wrapper_tx_status.clone(),
411-
total_signatures,
412-
size: tx_size,
413-
};
414-
384+
let mut masp_fee_payment = false;
415385
let mut inner_txs = vec![];
416386

417387
for (batch_index, tx_commitment) in
@@ -543,6 +513,10 @@ impl Transaction {
543513
},
544514
);
545515

516+
if is_masp_fee_payment {
517+
masp_fee_payment = true;
518+
}
519+
546520
let inner_tx = InnerTransaction {
547521
tx_id: inner_tx_id,
548522
index: batch_index,
@@ -553,12 +527,41 @@ impl Transaction {
553527
notes,
554528
exit_code: inner_tx_status,
555529
kind: tx_kind,
556-
is_masp_fee_payment,
557530
};
558531

559532
inner_txs.push(inner_tx);
560533
}
561534

535+
let wrapper_tx_status =
536+
block_results.is_wrapper_tx_applied(&wrapper_tx_id);
537+
let gas_used = block_results
538+
.gas_used(&wrapper_tx_id)
539+
.map(|gas| gas.parse::<u64>().unwrap());
540+
let atomic = transaction.header().atomic;
541+
542+
let fee = Fee {
543+
gas: Uint::from(wrapper.gas_limit).to_string(),
544+
gas_used,
545+
amount_per_gas_unit: wrapper
546+
.fee
547+
.amount_per_gas_unit
548+
.to_string_precise(),
549+
gas_payer: Id::from(wrapper.fee_payer()),
550+
gas_token: Id::from(wrapper.fee.token),
551+
masp_fee_payment,
552+
};
553+
554+
let wrapper_tx = WrapperTransaction {
555+
tx_id: wrapper_tx_id.clone(),
556+
index,
557+
fee,
558+
atomic,
559+
block_height,
560+
exit_code: wrapper_tx_status.clone(),
561+
total_signatures,
562+
size: tx_size,
563+
};
564+
562565
Ok((wrapper_tx, inner_txs))
563566
}
564567
TxType::Raw => {

0 commit comments

Comments
 (0)