forked from olehmisar/vlayer-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
pub fn get_account(chain_id: u32, block_no: u64, address: Address) -> AccountWithinBlock {
// Safety: verification done separately
let (account, state_proof) =
unsafe { get_account_unconstrained_M(chain_id, block_no, address) };
let header = get_header(chain_id, block_no);
verify_account(address, account, state_proof, header.state_root);
AccountWithinBlock { account, block_hash: header.hash }
}
pub fn get_transaction<let MAX_DATA_LEN: u32>(
chain_id: u32,
block_number: u64,
tx_idx: Field,
) -> TransactionWithinBlock<MAX_DATA_LEN> {
let (tx_type, transaction, proof_input) =
unsafe { get_transaction_unconstrained_M(chain_id, block_number, tx_idx) };
let header = get_header(chain_id, block_number);
verify_tx(
tx_idx,
tx_type,
transaction,
proof_input,
header.transactions_root,
);
TransactionWithinBlock { transaction, block_hash: header.hash }
}
These functions all share the same pattern: oracle call, deserialization, get_header, erification, return *WithinBlock. Maybe we can extract the common pattern into a macro.
Metadata
Metadata
Assignees
Labels
No labels