File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
packages/cardano-services
src/Utxo/DbSyncUtxoProvider Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -90,8 +90,11 @@ export const utxosToCore = (utxosModels: UtxoModel[]): Cardano.Utxo[] => {
9090 coins : BigInt ( current . coins )
9191 }
9292 } ;
93- if ( isNotNil ( current . data_hash ) ) txOut . datumHash = current . data_hash as unknown as Hash32ByteBase16 ;
94- if ( isNotNil ( current . inline_datum ) ) txOut . datum = PlutusData . fromCbor ( HexBlob ( current . inline_datum ) ) . toCore ( ) ;
93+ if ( isNotNil ( current . inline_datum ) ) {
94+ txOut . datum = PlutusData . fromCbor ( HexBlob ( current . inline_datum ) ) . toCore ( ) ;
95+ } else if ( isNotNil ( current . data_hash ) ) {
96+ txOut . datumHash = current . data_hash as unknown as Hash32ByteBase16 ;
97+ }
9598 if ( isNotNil ( current . reference_script_type ) ) txOut . scriptReference = parseReferenceScript ( current ) ;
9699
97100 if ( isNotNil ( current . asset_name ) && current . asset_policy && current . asset_quantity ) {
Original file line number Diff line number Diff line change @@ -11,8 +11,6 @@ import {
1111 UNLIMITED_CACHE_TTL ,
1212 UtxoHttpService
1313} from '../../src' ;
14- import { Hash32ByteBase16 } from '@cardano-sdk/crypto' ;
15- import { HexBlob } from '@cardano-sdk/util' ;
1614import { INFO , createLogger } from 'bunyan' ;
1715import { OgmiosCardanoNode } from '@cardano-sdk/ogmios' ;
1816import { Pool } from 'pg' ;
@@ -169,12 +167,10 @@ describe('UtxoHttpService', () => {
169167 it ( 'return UTxO with inline datum' , async ( ) => {
170168 const addresses = await fixtureBuilder . getAddresses ( 1 , { with : [ AddressWith . InlineDatum ] } ) ;
171169 const res : Cardano . Utxo [ ] = await provider . utxoByAddresses ( { addresses } ) ;
172- const firstTxOut = res [ 0 ] [ 1 ] ;
173170
174171 expect ( res . length ) . toBeGreaterThan ( 0 ) ;
175172 expect ( res [ 0 ] ) . toMatchShapeOf ( [ DataMocks . Tx . input , DataMocks . Tx . outputWithInlineDatum ] ) ;
176- expect ( ( ) => HexBlob ( firstTxOut . datum ! as unknown as string ) ) . not . toThrow ( ) ;
177- expect ( ( ) => Hash32ByteBase16 ( firstTxOut . datumHash ! as unknown as string ) ) . not . toThrow ( ) ;
173+ expect ( res [ 0 ] [ 1 ] . datumHash ) . toBeUndefined ( ) ;
178174 } ) ;
179175
180176 it ( 'return UTxO with time lock reference script' , async ( ) => {
You can’t perform that action at this time.
0 commit comments