1414 * limitations under the License.
1515 */
1616
17- import { combineLatest , from , of } from 'rxjs' ;
17+ import { combineLatest , of } from 'rxjs' ;
1818import { Observable } from 'rxjs/internal/Observable' ;
19- import { mergeMap , toArray } from 'rxjs/operators' ;
19+ import { map } from 'rxjs/operators' ;
2020import { Convert } from '../../core/format' ;
2121import { UnresolvedMapping } from '../../core/utils/UnresolvedMapping' ;
2222import { AccountMosaicRestrictionTransactionBuilder } from '../../infrastructure/catbuffer/AccountMosaicRestrictionTransactionBuilder' ;
@@ -28,11 +28,13 @@ import { KeyDto } from '../../infrastructure/catbuffer/KeyDto';
2828import { SignatureDto } from '../../infrastructure/catbuffer/SignatureDto' ;
2929import { TimestampDto } from '../../infrastructure/catbuffer/TimestampDto' ;
3030import { UnresolvedMosaicIdDto } from '../../infrastructure/catbuffer/UnresolvedMosaicIdDto' ;
31- import { NamespaceHttp } from '../../infrastructure/NamespaceHttp' ;
31+ import { ReceiptHttp } from '../../infrastructure/ReceiptHttp' ;
32+ import { TransactionService } from '../../service/TransactionService' ;
3233import { PublicAccount } from '../account/PublicAccount' ;
3334import { NetworkType } from '../blockchain/NetworkType' ;
3435import { MosaicId } from '../mosaic/MosaicId' ;
3536import { NamespaceId } from '../namespace/NamespaceId' ;
37+ import { ResolutionType } from '../receipt/ResolutionType' ;
3638import { AccountRestrictionFlags } from '../restriction/AccountRestrictionType' ;
3739import { UInt64 } from '../UInt64' ;
3840import { Deadline } from './Deadline' ;
@@ -196,23 +198,40 @@ export class AccountMosaicRestrictionTransaction extends Transaction {
196198
197199 /**
198200 * @internal
199- * @param namespaceHttp NamespaceHttp
200- * @returns {AccountMosaicRestrictionTransaction }
201+ * @param receiptHttp ReceiptHttp
202+ * @returns {TransferTransaction }
201203 */
202- resolveAliases ( namespaceHttp : NamespaceHttp ) : Observable < AccountMosaicRestrictionTransaction > {
203- const restrictionAdditions = from ( this . restrictionAdditions ) . pipe (
204- mergeMap ( ( addition ) => addition instanceof NamespaceId ?
205- namespaceHttp . getLinkedMosaicId ( addition ) :
206- of ( addition ) ,
207- ) ,
208- toArray ( ) ,
204+ resolveAliases ( receiptHttp : ReceiptHttp ) : Observable < AccountMosaicRestrictionTransaction > {
205+ const hasUnresolved = this . restrictionAdditions . find ( ( mosaicId ) => mosaicId instanceof NamespaceId ) !== undefined ||
206+ this . restrictionDeletions . find ( ( mosaicId ) => mosaicId instanceof NamespaceId ) !== undefined ;
207+
208+ if ( ! hasUnresolved ) {
209+ return of ( this ) ;
210+ }
211+
212+ const transactionInfo = this . checkTransactionHeightAndIndex ( ) ;
213+
214+ const statementObservable = receiptHttp . getBlockReceipts ( transactionInfo . height . toString ( ) ) ;
215+ const restrictionAdditions = statementObservable . pipe (
216+ map ( ( statement ) => {
217+ return this . restrictionAdditions . map ( ( addition ) => {
218+ return addition instanceof NamespaceId ?
219+ TransactionService . getResolvedFromReceipt ( ResolutionType . Mosaic , addition as NamespaceId ,
220+ statement , transactionInfo . index , transactionInfo . height . toString ( ) ) as MosaicId :
221+ addition ;
222+ } ) ;
223+ } ) ,
209224 ) ;
210- const restrictionDeletions = from ( this . restrictionDeletions ) . pipe (
211- mergeMap ( ( deletion ) => deletion instanceof NamespaceId ?
212- namespaceHttp . getLinkedMosaicId ( deletion ) :
213- of ( deletion ) ,
214- ) ,
215- toArray ( ) ,
225+
226+ const restrictionDeletions = statementObservable . pipe (
227+ map ( ( statement ) => {
228+ return this . restrictionDeletions . map ( ( deletion ) => {
229+ return deletion instanceof NamespaceId ?
230+ TransactionService . getResolvedFromReceipt ( ResolutionType . Mosaic , deletion as NamespaceId ,
231+ statement , transactionInfo . index , transactionInfo . height . toString ( ) ) as MosaicId :
232+ deletion ;
233+ } ) ;
234+ } ) ,
216235 ) ;
217236
218237 return combineLatest ( restrictionAdditions , restrictionDeletions , ( additions , deletions ) => {
0 commit comments