@@ -127,7 +127,7 @@ export class MosaicRestrictionTransactionService {
127127 mergeMap ( ( restrictionEntry : MosaicGlobalRestrictionItem | undefined ) => {
128128 if ( ! restrictionEntry ) {
129129 throw new Error (
130- `Global restriction for mosaic: ${ mosaicId } is not valid for with RestrictionKey: ${ restrictionKey } ` ,
130+ `Global restriction for mosaic: ${ mosaicId . toHex ( ) } is not valid for with RestrictionKey: ${ restrictionKey } ` ,
131131 ) ;
132132 }
133133 return this . getAddressRestrictionEntry ( resolvedMosaicId , restrictionKey , resolvedAddress ) . pipe (
@@ -161,12 +161,10 @@ export class MosaicRestrictionTransactionService {
161161 private getAddressRestrictionEntry ( mosaicId : MosaicId , restrictionKey : UInt64 , targetAddress : Address ) : Observable < UInt64 | undefined > {
162162 return this . restrictionMosaicRepository . search ( { mosaicId, targetAddress, entryType : MosaicRestrictionEntryType . ADDRESS } ) . pipe (
163163 map ( ( mosaicRestriction ) => {
164- return mosaicRestriction . data
165- . find (
166- ( r ) =>
167- r instanceof MosaicAddressRestriction && r . mosaicId . equals ( mosaicId ) && r . targetAddress . equals ( targetAddress ) ,
168- ) !
169- . getRestriction ( restrictionKey ) ?. restrictionValue ;
164+ const addressRestriction = mosaicRestriction . data . find (
165+ ( r ) => r instanceof MosaicAddressRestriction && r . mosaicId . equals ( mosaicId ) && r . targetAddress . equals ( targetAddress ) ,
166+ ) ;
167+ return addressRestriction ? addressRestriction . getRestriction ( restrictionKey ) ?. restrictionValue : undefined ;
170168 } ) ,
171169 ) ;
172170 }
@@ -180,9 +178,11 @@ export class MosaicRestrictionTransactionService {
180178 private getGlobalRestrictionEntry ( mosaicId : MosaicId , restrictionKey : UInt64 ) : Observable < MosaicGlobalRestrictionItem | undefined > {
181179 return this . restrictionMosaicRepository . search ( { mosaicId, entryType : MosaicRestrictionEntryType . GLOBAL } ) . pipe (
182180 map ( ( mosaicRestrictionPage : Page < MosaicGlobalRestriction > ) => {
183- return mosaicRestrictionPage . data
184- . find ( ( r ) => r instanceof MosaicGlobalRestriction && r . mosaicId . equals ( mosaicId ) ) !
185- . getRestriction ( restrictionKey ) ;
181+ const globalRestriction = mosaicRestrictionPage . data . find (
182+ ( r ) => r instanceof MosaicGlobalRestriction && r . mosaicId . equals ( mosaicId ) ,
183+ ) ;
184+
185+ return globalRestriction ? globalRestriction . getRestriction ( restrictionKey ) : undefined ;
186186 } ) ,
187187 ) ;
188188 }
0 commit comments