Skip to content

Commit af5558d

Browse files
jkawanJenita
andauthored
feat: added changes to implement UTxOWholeResult type (#1049)
* feat: added changes to implementutxoWholeResult Signed-off-by: Jenita <[email protected]> * feat: added changes to implementutxoWholeResult Signed-off-by: Jenita <[email protected]> * feat: added changes to implementutxoWholeResult Signed-off-by: Jenita <[email protected]> * feat: added changes to implementutxoWholeResult Signed-off-by: Jenita <[email protected]> * feat: added changes to implementutxoWholeResult Signed-off-by: Jenita <[email protected]> --------- Signed-off-by: Jenita <[email protected]> Co-authored-by: Jenita <[email protected]>
1 parent 7a53570 commit af5558d

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

cmd/gouroboros/query.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,33 @@ func testQuery(f *globalFlags) {
278278
fmt.Printf("Assets: %s\n", assetsJson)
279279
}
280280
}
281+
case "utxo-whole-result":
282+
utxos, err := o.LocalStateQuery().Client.GetUTxOWhole()
283+
if err != nil {
284+
fmt.Printf("ERROR: failure querying UTxO whole: %s\n", err)
285+
os.Exit(1)
286+
}
287+
288+
for utxoId, utxo := range utxos.Results {
289+
fmt.Println("---")
290+
fmt.Printf("UTxO ID: %s#%d\n", utxoId.Hash.String(), utxoId.Idx)
291+
fmt.Printf("Address: %x\n", utxo.Address())
292+
fmt.Printf("Amount: %d\n", utxo.Amount())
293+
294+
assets := utxo.Assets()
295+
if assets != nil {
296+
fmt.Printf("Assets: %+v\n", assets)
297+
}
298+
299+
datum := utxo.Datum()
300+
if datum != nil {
301+
if cborData := datum.Cbor(); cborData != nil {
302+
fmt.Printf("Datum CBOR: %x\n", cborData)
303+
} else {
304+
fmt.Printf("Datum present (error decoding)")
305+
}
306+
}
307+
}
281308
default:
282309
fmt.Printf("ERROR: unknown query: %s\n", queryFlags.flagset.Args()[0])
283310
os.Exit(1)

protocol/localstatequery/queries.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,10 @@ func (u *UtxoId) MarshalCBOR() ([]byte, error) {
596596
/*
597597
result [{* utxo => value }]
598598
*/
599-
type UTxOWholeResult any
599+
type UTxOWholeResult struct {
600+
cbor.StructAsArray
601+
Results map[UtxoId]ledger.BabbageTransactionOutput
602+
}
600603

601604
// TODO (#863)
602605
type DebugEpochStateResult any

0 commit comments

Comments
 (0)