feat(network): implement get_utxo_whole query (#564)

This commit is contained in:
Francisco Joray 2024-12-23 13:50:40 -03:00 committed by GitHub
parent f1cbf11c74
commit 21a92fc235
3 changed files with 113 additions and 1 deletions

View file

@ -136,7 +136,7 @@ impl<'b> Decode<'b, ()> for BlockQuery {
4 => Ok(Self::GetProposedPParamsUpdates),
5 => Ok(Self::GetStakeDistribution),
6 => Ok(Self::GetUTxOByAddress(d.decode()?)),
// 7 => Ok(Self::GetUTxOWhole),
7 => Ok(Self::GetUTxOWhole),
// 8 => Ok(Self::DebugEpochState),
9 => Ok(Self::GetCBOR(d.decode()?)),
10 => Ok(Self::GetFilteredDelegationsAndRewardAccounts(d.decode()?)),

View file

@ -313,6 +313,8 @@ pub struct UTxOByAddress {
pub type UTxOByTxin = UTxOByAddress;
pub type UTxOWhole = UTxOByAddress;
// Bytes CDDL -> #6.121([ * #6.121([ *datum ]) ])
pub type Datum = (Era, TagWrap<Bytes, 24>);
@ -608,3 +610,13 @@ pub async fn get_utxo_by_txin(
Ok(result)
}
/// Get the /entire/ UTxO.
pub async fn get_utxo_whole(client: &mut Client, era: u16) -> Result<UTxOWhole, ClientError> {
let query = BlockQuery::GetUTxOWhole;
let query = LedgerQuery::BlockQuery(era, query);
let query = Request::LedgerQuery(query);
let result = client.query(query).await?;
Ok(result)
}