export type Buffer32 = Buffer; export type RawAnchor = [string, Buffer32]; export type RawTxId = [Buffer32, number]; export type Buffer28 = Buffer; export type RawCredential = [0 | 1, Buffer28]; export class UtxoId { txHash: Buffer32; index: number; constructor(txHash: Buffer, index: number) { this.txHash = txHash; this.index = index; } public static fromCborObject(obj: RawTxId) { return new UtxoId(obj[0], obj[1]); } } export class Anchor { constructor( public url: string, public hash: Buffer ) {} public static fromCborObject(obj: RawAnchor) { return obj && new Anchor(obj[0], obj[1]); } public validate(): boolean { //@ts-ignore return typeof this.url === "string" && !!this.hash && this.url.length <= 128 && this.hash.length === 32; } } export function parseUtxoIds(rawTxIds: RawTxId[]): UtxoId[] { const utxoIds: UtxoId[] = []; rawTxIds.forEach((txid) => { utxoIds.push(UtxoId.fromCborObject(txid)); }); return utxoIds; } export type CardanoCliJsonKey = { type: string; description: string; cborHex: string; };