Skip to content

Commit

Permalink
core-api: add scheduled information to holder status
Browse files Browse the repository at this point in the history
  • Loading branch information
afalaleev committed Dec 3, 2024
1 parent f8a24eb commit 377b1cf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions evm_loader/lib/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ impl FromAddress {
#[derive(Clone, Serialize, Deserialize)]
pub struct TxParams {
pub nonce: Option<u64>,
pub index: Option<u16>,
#[serde_as(as = "DisplayFromStr")]
pub from: FromAddress,
pub payer: Option<Address>,
pub to: Option<Address>,
#[serde_as(as = "Option<Hex>")]
pub data: Option<Vec<u8>>,
Expand Down Expand Up @@ -245,8 +247,10 @@ impl TxParams {
pub fn from_transaction(origin: Address, tx: &Transaction) -> Self {
Self {
from: FromAddress::Ethereum(origin),
payer: Some(tx.payer(origin)),
to: tx.target(),
nonce: Some(tx.nonce()),
index: tx.tree_account_index(),
data: Some(tx.call_data().to_vec()),
value: Some(tx.value()),
gas_limit: Some(tx.gas_limit()),
Expand Down
10 changes: 10 additions & 0 deletions evm_loader/program/src/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,16 @@ impl Transaction {
.ok_or(Error::IntegerOverflow)
}

#[must_use]
pub fn payer(&self, origin: Address) -> Address {
match self.transaction {
TransactionPayload::Legacy(_)
| TransactionPayload::AccessList(_)
| TransactionPayload::DynamicFee(_) => origin,
TransactionPayload::Scheduled(ScheduledTx { payer, .. }) => payer,
}
}

#[must_use]
pub fn target(&self) -> Option<Address> {
match self.transaction {
Expand Down

0 comments on commit 377b1cf

Please sign in to comment.