balius_runtime/ledgers/
mock.rs1use crate::wit::balius::app::ledger as wit;
2
3#[derive(Clone)]
4pub struct Ledger;
5
6impl Ledger {
7 pub async fn read_utxos(
8 &mut self,
9 _refs: Vec<wit::TxoRef>,
10 ) -> Result<Vec<wit::Utxo>, wit::LedgerError> {
11 let output = pallas::ledger::primitives::babbage::MintedTransactionOutput::PostAlonzo(pallas::ledger::primitives::babbage::MintedPostAlonzoTransactionOutput {
12 address: pallas::ledger::addresses::Address::from_bech32("addr1qx2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgse35a3x").unwrap().to_vec().into(),
13 value: pallas::ledger::primitives::babbage::Value::Coin(5_000_000),
14 datum_option: None,
15 script_ref: None,
16 });
17
18 let cbor = pallas::codec::minicbor::to_vec(&output).unwrap();
19
20 Ok(vec![wit::Utxo {
21 ref_: wit::TxoRef {
22 tx_hash: hex::decode(
23 "f7d3837715680f3a170e99cd202b726842d97f82c05af8fcd18053c64e33ec4f",
24 )
25 .unwrap(),
26 tx_index: 0,
27 },
28 body: cbor,
29 }])
30 }
31
32 pub async fn search_utxos(
33 &mut self,
34 _pattern: wit::UtxoPattern,
35 _start: Option<String>,
36 _max_items: u32,
37 ) -> Result<wit::UtxoPage, wit::LedgerError> {
38 todo!()
39 }
40
41 pub async fn read_params(&mut self) -> Result<wit::Json, wit::LedgerError> {
42 let bytes = include_bytes!("./mock_pparams.json");
43 Ok(bytes.into())
44 }
45}