Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

add common getters for all tx types #1703

Open
tdelabro opened this issue Mar 21, 2024 · 3 comments
Open

add common getters for all tx types #1703

tdelabro opened this issue Mar 21, 2024 · 3 comments

Comments

@tdelabro
Copy link
Contributor

https://github.com/keep-starknet-strange/madara/blob/main/crates/primitives/transactions/src/getters.rs#L51

In madara we added a set of common getters for all our tx types.
You should do that for the one defined in blockifier too.
It would avoid lib users having to write this type of bad boilerplate code all the time:

            let sender_address = match &transaction.tx {
                starknet_api::transaction::InvokeTransaction::V0(tx) => tx.contract_address,
                starknet_api::transaction::InvokeTransaction::V1(tx) => tx.sender_address,
                starknet_api::transaction::InvokeTransaction::V3(tx) => tx.sender_address,
            };

This should be a trait.

@raizo07
Copy link

raizo07 commented Mar 22, 2024

Hello, can this task be assigned to me?

@tdelabro
Copy link
Contributor Author

@raizo07 I would love it if you could implement it, sadly I'm not the manager of this repo. @noaov1 is more likely to give you the green light

@tdelabro
Copy link
Contributor Author

tdelabro commented Apr 3, 2024

also I had to create those methods:

pub fn get_transaction_hash(tx: &Transaction) -> &TransactionHash {
    match tx {
        Transaction::AccountTransaction(tx) => get_account_transaction_hash(tx),
        Transaction::L1HandlerTransaction(tx) => &tx.tx_hash,
    }
}

pub fn get_account_transaction_hash(tx: &AccountTransaction) -> &TransactionHash {
    match tx {
        AccountTransaction::Invoke(tx) => &tx.tx_hash,
        AccountTransaction::Declare(tx) => &tx.tx_hash,
        AccountTransaction::DeployAccount(tx) => &tx.tx_hash,
    }
}

Just add some getters please :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants