@@ -127,7 +127,7 @@ export class MosaicRestrictionTransactionService {
127
127
mergeMap ( ( restrictionEntry : MosaicGlobalRestrictionItem | undefined ) => {
128
128
if ( ! restrictionEntry ) {
129
129
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 } ` ,
131
131
) ;
132
132
}
133
133
return this . getAddressRestrictionEntry ( resolvedMosaicId , restrictionKey , resolvedAddress ) . pipe (
@@ -161,12 +161,10 @@ export class MosaicRestrictionTransactionService {
161
161
private getAddressRestrictionEntry ( mosaicId : MosaicId , restrictionKey : UInt64 , targetAddress : Address ) : Observable < UInt64 | undefined > {
162
162
return this . restrictionMosaicRepository . search ( { mosaicId, targetAddress, entryType : MosaicRestrictionEntryType . ADDRESS } ) . pipe (
163
163
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 ;
170
168
} ) ,
171
169
) ;
172
170
}
@@ -180,9 +178,11 @@ export class MosaicRestrictionTransactionService {
180
178
private getGlobalRestrictionEntry ( mosaicId : MosaicId , restrictionKey : UInt64 ) : Observable < MosaicGlobalRestrictionItem | undefined > {
181
179
return this . restrictionMosaicRepository . search ( { mosaicId, entryType : MosaicRestrictionEntryType . GLOBAL } ) . pipe (
182
180
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 ;
186
186
} ) ,
187
187
) ;
188
188
}
0 commit comments