@@ -58,12 +58,12 @@ export class MosaicRestrictionTransactionService {
5858 public createMosaicGlobalRestrictionTransaction ( deadline : Deadline ,
5959 networkType : NetworkType ,
6060 mosaicId : MosaicId ,
61- restrictionKey : string ,
61+ restrictionKey : UInt64 ,
6262 restrictionValue : string ,
6363 restrictionType : MosaicRestrictionType ,
6464 referenceMosaicId : MosaicId = new MosaicId ( UInt64 . fromUint ( 0 ) . toDTO ( ) ) ,
6565 maxFee : UInt64 = new UInt64 ( [ 0 , 0 ] ) ) : Observable < Transaction > {
66- this . validateInput ( restrictionKey , restrictionValue ) ;
66+ this . validateInput ( restrictionValue ) ;
6767 return this . getGlobalRestrictionEntry ( mosaicId , restrictionKey ) . pipe (
6868 map ( ( restrictionEntry : MosaicGlobalRestrictionItem | undefined ) => {
6969 const currentValue = restrictionEntry ? UInt64 . fromNumericString ( restrictionEntry . restrictionValue ) :
@@ -73,7 +73,7 @@ export class MosaicRestrictionTransactionService {
7373 return MosaicGlobalRestrictionTransaction . create (
7474 deadline ,
7575 mosaicId ,
76- UInt64 . fromNumericString ( restrictionKey ) ,
76+ restrictionKey ,
7777 currentValue ,
7878 currentType ,
7979 UInt64 . fromNumericString ( restrictionValue ) ,
@@ -101,25 +101,25 @@ export class MosaicRestrictionTransactionService {
101101 public createMosaicAddressRestrictionTransaction ( deadline : Deadline ,
102102 networkType : NetworkType ,
103103 mosaicId : MosaicId ,
104- restrictionKey : string ,
104+ restrictionKey : UInt64 ,
105105 targetAddress : Address ,
106106 restrictionValue : string ,
107107 maxFee : UInt64 = new UInt64 ( [ 0 , 0 ] ) ) : Observable < Transaction > {
108- this . validateInput ( restrictionKey , restrictionValue ) ;
108+ this . validateInput ( restrictionValue ) ;
109109 return this . getGlobalRestrictionEntry ( mosaicId , restrictionKey ) . pipe (
110110 switchMap ( ( restrictionEntry : MosaicGlobalRestrictionItem | undefined ) => {
111111 if ( ! restrictionEntry ) {
112112 throw Error ( 'Global restriction is not valid for RetrictionKey: ' + restrictionKey ) ;
113113 }
114114 return this . restrictionHttp . getMosaicAddressRestriction ( mosaicId , targetAddress ) . pipe (
115115 map ( ( addressRestriction : MosaicAddressRestriction ) => {
116- const addressEntry = addressRestriction . restrictions . get ( restrictionKey ) ;
116+ const addressEntry = addressRestriction . restrictions . get ( restrictionKey . toHex ( ) ) ;
117117 const currentValue = addressEntry ? UInt64 . fromNumericString ( addressEntry ) :
118118 this . defaultMosaicAddressRestrictionVaule ;
119119 return MosaicAddressRestrictionTransaction . create (
120120 deadline ,
121121 mosaicId ,
122- UInt64 . fromNumericString ( restrictionKey ) ,
122+ restrictionKey ,
123123 targetAddress ,
124124 UInt64 . fromNumericString ( restrictionValue ) ,
125125 networkType ,
@@ -133,7 +133,7 @@ export class MosaicRestrictionTransactionService {
133133 return of ( MosaicAddressRestrictionTransaction . create (
134134 deadline ,
135135 mosaicId ,
136- UInt64 . fromNumericString ( restrictionKey ) ,
136+ restrictionKey ,
137137 targetAddress ,
138138 UInt64 . fromNumericString ( restrictionValue ) ,
139139 networkType ,
@@ -153,29 +153,25 @@ export class MosaicRestrictionTransactionService {
153153 * @param restrictionKey - Mosaic global restriction key
154154 * @return {Observable<MosaicGlobalRestrictionItem | undefined> }
155155 */
156- private getGlobalRestrictionEntry ( mosaicId : MosaicId , restrictionKey : string ) : Observable < MosaicGlobalRestrictionItem | undefined > {
156+ private getGlobalRestrictionEntry ( mosaicId : MosaicId , restrictionKey : UInt64 ) : Observable < MosaicGlobalRestrictionItem | undefined > {
157157 return this . restrictionHttp . getMosaicGlobalRestriction ( mosaicId ) . pipe (
158158 map ( ( mosaicRestriction : MosaicGlobalRestriction ) => {
159- return mosaicRestriction . restrictions . get ( restrictionKey ) ;
159+ return mosaicRestriction . restrictions . get ( restrictionKey . toHex ( ) ) ;
160160 } ) ,
161- catchError ( ( err ) => {
162- if ( err . response . statusCode && err . response . statusCode === 404 ) {
161+ catchError ( ( err : Error ) => {
162+ const error = JSON . parse ( err . message ) ;
163+ if ( error && error . statusCode && error . statusCode === 404 ) {
163164 return of ( undefined ) ;
164165 }
165- throw Error ( err ) ;
166+ throw Error ( err . message ) ;
166167 } ) ) ;
167168 }
168169
169170 /**
170171 * Check if input restriction key and value are invalid or not
171- * @param key - Restriction key
172172 * @param value - Restriction value
173173 */
174- private validateInput ( key : string , value : string ) {
175- if ( ! UInt64 . isLongNumericString ( key ) ) {
176- throw Error ( `RestrictionKey: ${ key } is not a valid numeric string.` ) ;
177- }
178-
174+ private validateInput ( value : string ) {
179175 if ( ! UInt64 . isLongNumericString ( value ) ) {
180176 throw Error ( `RestrictionValue: ${ value } is not a valid numeric string.` ) ;
181177 }
0 commit comments