Skip to content

Commit 1367eb9

Browse files
committed
chore: update deps across the board (#48)
1 parent 5df16e6 commit 1367eb9

File tree

8 files changed

+764
-707
lines changed

8 files changed

+764
-707
lines changed

Cargo.lock

Lines changed: 516 additions & 484 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ keywords = ["cardano", "blockchain", "wallet"]
1414
categories = ["command-line-utilities", "blockchain", "cardano", "wallet"]
1515

1616
[dependencies]
17-
tx3-lang = "0.11.5"
18-
tx3-cardano = "0.11.5"
17+
tx3-lang = "0.13.0"
18+
tx3-cardano = "0.13.0"
1919
tx3-sdk = "^0"
2020

2121
# tx3-lang = { git = "https://github.com/tx3-lang/tx3.git" }
@@ -26,9 +26,9 @@ tx3-sdk = "^0"
2626
# tx3-cardano = { path = "../../tx3-lang/tx3/crates/tx3-cardano" }
2727
# tx3-sdk = { path = "../../tx3-lang/rust-sdk/sdk" }
2828

29-
utxorpc = { git = "https://github.com/utxorpc/rust-sdk" }
30-
# utxorpc = "0.10.0"
31-
# utxorpc = { path = "../../../utxorpc/rust-sdk" }
29+
# utxorpc = { git = "https://github.com/utxorpc/rust-sdk" }
30+
utxorpc = "0.12.0"
31+
# utxorpc = { path = "../../utxorpc/rust-sdk" }
3232

3333
bech32 = "0.9.1"
3434
bip39 = { version = "2.0.0", features = ["rand_core"] }
@@ -44,8 +44,8 @@ inquire = "0.7.4"
4444
jsonrpsee = { version = "0", features = ["client"] }
4545
pallas = { version = "1.0.0-alpha.2", features = ["hardano"] }
4646
prost = "0.13.5"
47-
rand = "0.8.5"
48-
rand_core = { version = "0.6.4" }
47+
rand = "0.9.2"
48+
rand_core = { version = "0.9.3" }
4949
ratatui = "0.29.0"
5050
serde = { version = "1.0.217", features = ["derive"] }
5151
serde_with = "3.12.0"
@@ -74,4 +74,11 @@ lto = "thin"
7474
[workspace.metadata.release]
7575
push = false
7676
publish = false
77-
pre-release-hook = ["git", "cliff", "-o", "CHANGELOG.md", "--tag", "{{version}}"]
77+
pre-release-hook = [
78+
"git",
79+
"cliff",
80+
"-o",
81+
"CHANGELOG.md",
82+
"--tag",
83+
"{{version}}",
84+
]

src/explorer/widgets/tabs/transactions.rs

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -625,35 +625,31 @@ impl TxView {
625625
.collect()
626626
}
627627

628-
pub fn from_any_chain_tx(any_chain_tx: &query::AnyChainTx) -> Option<Self> {
629-
let chain = any_chain_tx.chain.as_ref()?;
630-
let block_ref = any_chain_tx.block_ref.as_ref()?;
631-
632-
match chain {
633-
query::any_chain_tx::Chain::Cardano(tx) => {
634-
let hash = hex::encode(&tx.hash);
635-
let certs = tx.certificates.len();
636-
let assets = tx.outputs.iter().map(|o| o.assets.len()).sum();
637-
let amount_ada = tx.outputs.iter().map(|o| o.coin).sum();
638-
let datum = tx
639-
.outputs
640-
.iter()
641-
.any(|o| o.datum.as_ref().is_some_and(|d| !d.hash.is_empty()));
642-
643-
Some(TxView {
644-
hash,
645-
certs,
646-
assets,
647-
amount_ada,
648-
datum,
649-
// TODO: improve to not clone the whole tx
650-
tx: Some(tx.clone()),
651-
block_slot: block_ref.slot,
652-
block_height: block_ref.height,
653-
block_hash: hex::encode(&block_ref.hash),
654-
})
655-
}
656-
}
628+
pub fn from_any_chain_tx(tx: &utxorpc::ChainTx<utxorpc::spec::cardano::Tx>) -> Option<Self> {
629+
let block_ref = tx.block_ref.as_ref()?;
630+
let tx = tx.parsed.as_ref()?;
631+
632+
let hash = hex::encode(&tx.hash);
633+
let certs = tx.certificates.len();
634+
let assets = tx.outputs.iter().map(|o| o.assets.len()).sum();
635+
let amount_ada = tx.outputs.iter().map(|o| o.coin).sum();
636+
let datum = tx
637+
.outputs
638+
.iter()
639+
.any(|o| o.datum.as_ref().is_some_and(|d| !d.hash.is_empty()));
640+
641+
Some(TxView {
642+
hash,
643+
certs,
644+
assets,
645+
amount_ada,
646+
datum,
647+
// TODO: improve to not clone the whole tx
648+
tx: Some(tx.clone()),
649+
block_slot: block_ref.slot,
650+
block_height: block_ref.height,
651+
block_hash: hex::encode(&block_ref.hash),
652+
})
657653
}
658654
}
659655

src/provider/types.rs

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ use pallas::ledger::addresses::Address;
66
use serde::{Deserialize, Serialize};
77
use serde_json::{json, Value};
88
use utxorpc::{
9-
spec::{
10-
query::{any_utxo_pattern::UtxoPattern, AnyChainTx, ReadTxRequest},
11-
sync::{AnyChainBlock, BlockRef, FetchBlockRequest},
12-
},
13-
CardanoQueryClient, CardanoSubmitClient, CardanoSyncClient, ClientBuilder, InnerService,
9+
spec::{query::any_utxo_pattern::UtxoPattern, sync::BlockRef},
10+
CardanoQueryClient, CardanoSubmitClient, CardanoSyncClient, ChainBlock, ChainTx, ClientBuilder,
11+
InnerService,
1412
};
1513

1614
use crate::{
@@ -290,7 +288,10 @@ impl Provider {
290288
Ok(client.submit(tx, vec![]).await?)
291289
}
292290

293-
pub async fn fetch_block(&self, refs: Vec<(Vec<u8>, u64)>) -> Result<Vec<AnyChainBlock>> {
291+
pub async fn fetch_block(
292+
&self,
293+
refs: Vec<(Vec<u8>, u64)>,
294+
) -> Result<Vec<ChainBlock<utxorpc::spec::cardano::Block>>> {
294295
let mut client: utxorpc::CardanoSyncClient = self.client().await?;
295296

296297
let refs = refs
@@ -302,34 +303,20 @@ impl Provider {
302303
})
303304
.collect();
304305

305-
let request = FetchBlockRequest {
306-
r#ref: refs,
307-
..Default::default()
308-
};
309-
let response = client
310-
.fetch_block(request)
311-
.await
312-
.map_err(|err| anyhow::Error::msg(format!("Fetch block. {}", err.code())))?
313-
.into_inner();
306+
let response = client.fetch_block(refs).await?;
314307

315-
Ok(response.block)
308+
Ok(response)
316309
}
317310

318-
pub async fn fetch_tx(&self, hash: Vec<u8>) -> Result<Option<AnyChainTx>> {
311+
pub async fn fetch_tx(
312+
&self,
313+
hash: Vec<u8>,
314+
) -> Result<Option<ChainTx<utxorpc::spec::cardano::Tx>>> {
319315
let mut client: utxorpc::CardanoQueryClient = self.client().await?;
320316

321-
let request = ReadTxRequest {
322-
hash: hash.into(),
323-
..Default::default()
324-
};
325-
326-
let response = client
327-
.read_tx(request)
328-
.await
329-
.map_err(|err| anyhow::Error::msg(format!("Fetch transaction. {}", err.code())))?
330-
.into_inner();
317+
let response = client.read_tx(hash.into()).await?;
331318

332-
Ok(response.tx)
319+
Ok(response)
333320
}
334321
}
335322

src/search/mod.rs

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ use anyhow::Result;
22
use clap::{command, Parser, Subcommand};
33
use comfy_table::Table;
44
use tracing::instrument;
5-
use utxorpc::spec::{cardano::Tx, query, sync};
5+
use utxorpc::{
6+
spec::{
7+
cardano::Tx,
8+
query::{self},
9+
},
10+
ChainBlock,
11+
};
612

713
use crate::output::OutputFormatter;
814

@@ -32,7 +38,7 @@ pub async fn run(args: Args, ctx: &mut crate::Context) -> Result<()> {
3238
}
3339
}
3440

35-
fn cardano_tx_table(block_hash: Vec<u8>, tx: &[Tx]) -> Table {
41+
fn cardano_tx_table(block_hash: Option<Vec<u8>>, tx: &[Tx]) -> Table {
3642
let mut table = Table::new();
3743
table.set_header(vec![
3844
"Block",
@@ -45,12 +51,10 @@ fn cardano_tx_table(block_hash: Vec<u8>, tx: &[Tx]) -> Table {
4551
"Datum",
4652
]);
4753

48-
let block_hash = hex::encode(block_hash);
49-
let block_hash_trucated = format!(
50-
"{}...{}",
51-
&block_hash[..4],
52-
&block_hash[block_hash.len() - 4..]
53-
);
54+
let block_hash = block_hash
55+
.map(|b| hex::encode(b))
56+
.map(|x| format!("{}...{}", &x[..4], &x[x.len() - 4..]))
57+
.unwrap_or_default();
5458

5559
for (i, tx) in tx.iter().enumerate() {
5660
let hash = hex::encode(&tx.hash);
@@ -71,7 +75,7 @@ fn cardano_tx_table(block_hash: Vec<u8>, tx: &[Tx]) -> Table {
7175
};
7276

7377
table.add_row(vec![
74-
&block_hash_trucated,
78+
&block_hash,
7579
&i.to_string(),
7680
&hash,
7781
&inputs.to_string(),
@@ -85,28 +89,31 @@ fn cardano_tx_table(block_hash: Vec<u8>, tx: &[Tx]) -> Table {
8589
table
8690
}
8791

88-
impl OutputFormatter for Vec<sync::AnyChainBlock> {
92+
impl OutputFormatter for Vec<ChainBlock<utxorpc::spec::cardano::Block>> {
8993
fn to_table(&self) {
9094
for block in self {
91-
if let Some(chain) = &block.chain {
92-
match chain {
93-
sync::any_chain_block::Chain::Cardano(block) => {
94-
if block.header.is_none() {
95-
return;
96-
}
97-
let header = block.header.as_ref().unwrap();
98-
if let Some(body) = &block.body {
99-
let table = cardano_tx_table(header.hash.clone().into(), &body.tx);
100-
println!("{table}");
101-
}
102-
}
95+
if let Some(block) = &block.parsed {
96+
if block.header.is_none() {
97+
return;
98+
}
99+
100+
let header = block.header.as_ref().unwrap();
101+
102+
if let Some(body) = &block.body {
103+
let table = cardano_tx_table(Some(header.hash.clone().into()), &body.tx);
104+
println!("{table}");
103105
}
104106
}
105107
}
106108
}
107109

108110
fn to_json(&self) {
109-
let result = serde_json::to_value(self);
111+
let blocks = self
112+
.iter()
113+
.flat_map(|x| x.parsed.as_ref())
114+
.collect::<Vec<_>>();
115+
116+
let result = serde_json::to_value(blocks);
110117
if let Err(err) = result {
111118
eprintln!("{err}");
112119
return;
@@ -130,7 +137,8 @@ impl OutputFormatter for Vec<query::AnyChainBlock> {
130137
}
131138
let header = block.header.as_ref().unwrap();
132139
if let Some(body) = &block.body {
133-
let table = cardano_tx_table(header.hash.clone().into(), &body.tx);
140+
let table =
141+
cardano_tx_table(Some(header.hash.clone().into()), &body.tx);
134142
println!("{table}");
135143
}
136144
}
@@ -153,35 +161,30 @@ impl OutputFormatter for Vec<query::AnyChainBlock> {
153161
}
154162
}
155163

156-
impl OutputFormatter for query::AnyChainTx {
164+
impl OutputFormatter for utxorpc::ChainTx<utxorpc::spec::cardano::Tx> {
157165
fn to_table(&self) {
158-
if let Some(chain) = &self.chain {
159-
match chain {
160-
query::any_chain_tx::Chain::Cardano(tx) => {
161-
let block_hash = self.block_ref.as_ref().unwrap().hash.clone();
162-
let table = cardano_tx_table(block_hash.into(), std::slice::from_ref(tx));
163-
println!("{table}");
164-
}
165-
}
166+
if let Some(parsed) = &self.parsed {
167+
let table = cardano_tx_table(
168+
self.block_ref.as_ref().map(|b| b.hash.clone().into()),
169+
std::slice::from_ref(parsed),
170+
);
171+
println!("{table}");
166172
}
167173
}
168174

169175
fn to_json(&self) {
170-
if let Some(chain) = &self.chain {
171-
match chain {
172-
query::any_chain_tx::Chain::Cardano(tx) => {
173-
let result = serde_json::to_value(tx);
174-
if let Err(err) = result {
175-
eprintln!("{err}");
176-
return;
177-
}
176+
if let Some(tx) = &self.parsed {
177+
let result = serde_json::to_value(tx);
178178

179-
println!(
180-
"{}",
181-
serde_json::to_string_pretty(&result.unwrap()).unwrap()
182-
);
183-
}
179+
if let Err(err) = result {
180+
eprintln!("{err}");
181+
return;
184182
}
183+
184+
println!(
185+
"{}",
186+
serde_json::to_string_pretty(&result.unwrap()).unwrap()
187+
);
185188
}
186189
}
187190
}

src/tx/common.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ pub fn inquire_args(
175175
"tx3 arg {key} is a custom type {x}, not supported yet"
176176
));
177177
}
178+
tx3_lang::ir::Type::Map => {
179+
return Err(anyhow::anyhow!(
180+
"tx3 arg {key} is of type Map, not supported yet",
181+
));
182+
}
178183
};
179184
}
180185

@@ -190,8 +195,7 @@ pub fn define_args(
190195
) -> Result<HashMap<String, ArgValue>> {
191196
let mut remaining_params = params.clone();
192197

193-
let mut loaded_args =
194-
super::common::load_args(inline_args, file_args, &remaining_params)?;
198+
let mut loaded_args = super::common::load_args(inline_args, file_args, &remaining_params)?;
195199

196200
// remove from the remaining params the args we already managed to load from the
197201
// file or json

0 commit comments

Comments
 (0)