@@ -25,8 +25,8 @@ import { NamespaceHttp } from '../../src/infrastructure/infrastructure';
2525import { Listener } from '../../src/infrastructure/Listener' ;
2626import { TransactionHttp } from '../../src/infrastructure/TransactionHttp' ;
2727import { Account } from '../../src/model/account/Account' ;
28+ import { AccountRestrictionType } from '../../src/model/account/AccountRestrictionType' ;
2829import { RestrictionModificationType } from '../../src/model/account/RestrictionModificationType' ;
29- import { RestrictionType } from '../../src/model/account/RestrictionType' ;
3030import { NetworkType } from '../../src/model/blockchain/NetworkType' ;
3131import { Mosaic } from '../../src/model/mosaic/Mosaic' ;
3232import { MosaicId } from '../../src/model/mosaic/MosaicId' ;
@@ -387,7 +387,7 @@ describe('TransactionHttp', () => {
387387 transactionHttp . announce ( signedTransaction ) ;
388388 } ) ;
389389 } ) ;
390- describe ( 'AccountRestrictionTransaction - Address' , ( ) => {
390+ describe ( 'AccountRestrictionTransaction - Outgoing Address' , ( ) => {
391391 let listener : Listener ;
392392 before ( ( ) => {
393393 listener = new Listener ( config . apiUrl ) ;
@@ -404,7 +404,7 @@ describe('TransactionHttp', () => {
404404 ) ;
405405 const addressModification = AccountRestrictionTransaction . createAddressRestrictionModificationTransaction (
406406 Deadline . create ( ) ,
407- RestrictionType . BlockAddress ,
407+ AccountRestrictionType . BlockOutgoingAddress ,
408408 [ addressRestrictionFilter ] ,
409409 NetworkType . MIJIN_TEST ,
410410 ) ;
@@ -425,7 +425,7 @@ describe('TransactionHttp', () => {
425425 transactionHttp . announce ( signedTransaction ) ;
426426 } ) ;
427427 } ) ;
428- describe ( 'AccountRestrictionTransaction - Address' , ( ) => {
428+ describe ( 'AccountRestrictionTransaction - Outgoing Address' , ( ) => {
429429 let listener : Listener ;
430430 before ( ( ) => {
431431 listener = new Listener ( config . apiUrl ) ;
@@ -441,7 +441,83 @@ describe('TransactionHttp', () => {
441441 ) ;
442442 const addressModification = AccountRestrictionTransaction . createAddressRestrictionModificationTransaction (
443443 Deadline . create ( ) ,
444- RestrictionType . BlockAddress ,
444+ AccountRestrictionType . BlockOutgoingAddress ,
445+ [ addressRestrictionFilter ] ,
446+ NetworkType . MIJIN_TEST ,
447+ ) ;
448+ const aggregateTransaction = AggregateTransaction . createComplete ( Deadline . create ( ) ,
449+ [ addressModification . toAggregate ( account . publicAccount ) ] ,
450+ NetworkType . MIJIN_TEST ,
451+ [ ] ,
452+ ) ;
453+ const signedTransaction = aggregateTransaction . signWith ( account , generationHash ) ;
454+ listener . confirmed ( account . address ) . subscribe ( ( transaction : Transaction ) => {
455+ done ( ) ;
456+ } ) ;
457+ listener . status ( account . address ) . subscribe ( ( error ) => {
458+ console . log ( 'Error:' , error ) ;
459+ assert ( false ) ;
460+ done ( ) ;
461+ } ) ;
462+ transactionHttp . announce ( signedTransaction ) ;
463+ } ) ;
464+ } ) ;
465+
466+ describe ( 'AccountRestrictionTransaction - Incoming Address' , ( ) => {
467+ let listener : Listener ;
468+ before ( ( ) => {
469+ listener = new Listener ( config . apiUrl ) ;
470+ return listener . open ( ) ;
471+ } ) ;
472+ after ( ( ) => {
473+ return listener . close ( ) ;
474+ } ) ;
475+
476+ it ( 'standalone' , ( done ) => {
477+ const addressRestrictionFilter = AccountRestrictionModification . createForAddress (
478+ RestrictionModificationType . Add ,
479+ account3 . address ,
480+ ) ;
481+ const addressModification = AccountRestrictionTransaction . createAddressRestrictionModificationTransaction (
482+ Deadline . create ( ) ,
483+ AccountRestrictionType . BlockIncomingAddress ,
484+ [ addressRestrictionFilter ] ,
485+ NetworkType . MIJIN_TEST ,
486+ ) ;
487+ const signedTransaction = addressModification . signWith ( account , generationHash ) ;
488+
489+ listener . confirmed ( account . address ) . subscribe ( ( transaction : AccountAddressRestrictionModificationTransaction ) => {
490+ expect ( transaction . modifications , 'Modifications' ) . not . to . be . undefined ;
491+ expect ( transaction . modifications [ 0 ] . modificationType , 'Modifications.ModificationType' ) . not . to . be . undefined ;
492+ expect ( transaction . modifications [ 0 ] . value , 'Modifications.Value' ) . not . to . be . undefined ;
493+ expect ( transaction . restrictionType , 'RestrictionType' ) . not . to . be . undefined ;
494+ done ( ) ;
495+ } ) ;
496+ listener . status ( account . address ) . subscribe ( ( error ) => {
497+ console . log ( 'Error:' , error ) ;
498+ assert ( false ) ;
499+ done ( ) ;
500+ } ) ;
501+ transactionHttp . announce ( signedTransaction ) ;
502+ } ) ;
503+ } ) ;
504+ describe ( 'AccountRestrictionTransaction - Incoming Address' , ( ) => {
505+ let listener : Listener ;
506+ before ( ( ) => {
507+ listener = new Listener ( config . apiUrl ) ;
508+ return listener . open ( ) ;
509+ } ) ;
510+ after ( ( ) => {
511+ return listener . close ( ) ;
512+ } ) ;
513+ it ( 'aggregate' , ( done ) => {
514+ const addressRestrictionFilter = AccountRestrictionModification . createForAddress (
515+ RestrictionModificationType . Remove ,
516+ account3 . address ,
517+ ) ;
518+ const addressModification = AccountRestrictionTransaction . createAddressRestrictionModificationTransaction (
519+ Deadline . create ( ) ,
520+ AccountRestrictionType . BlockIncomingAddress ,
445521 [ addressRestrictionFilter ] ,
446522 NetworkType . MIJIN_TEST ,
447523 ) ;
@@ -479,7 +555,7 @@ describe('TransactionHttp', () => {
479555 ) ;
480556 const addressModification = AccountRestrictionTransaction . createMosaicRestrictionModificationTransaction (
481557 Deadline . create ( ) ,
482- RestrictionType . BlockMosaic ,
558+ AccountRestrictionType . BlockMosaic ,
483559 [ mosaicRestrictionFilter ] ,
484560 NetworkType . MIJIN_TEST ,
485561 ) ;
@@ -516,7 +592,7 @@ describe('TransactionHttp', () => {
516592 ) ;
517593 const addressModification = AccountRestrictionTransaction . createMosaicRestrictionModificationTransaction (
518594 Deadline . create ( ) ,
519- RestrictionType . BlockMosaic ,
595+ AccountRestrictionType . BlockMosaic ,
520596 [ mosaicRestrictionFilter ] ,
521597 NetworkType . MIJIN_TEST ,
522598 ) ;
@@ -537,7 +613,7 @@ describe('TransactionHttp', () => {
537613 transactionHttp . announce ( signedTransaction ) ;
538614 } ) ;
539615 } ) ;
540- describe ( 'AccountRestrictionTransaction - Operation' , ( ) => {
616+ describe ( 'AccountRestrictionTransaction - Incoming Operation' , ( ) => {
541617 let listener : Listener ;
542618 before ( ( ) => {
543619 listener = new Listener ( config . apiUrl ) ;
@@ -554,7 +630,7 @@ describe('TransactionHttp', () => {
554630 ) ;
555631 const addressModification = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
556632 Deadline . create ( ) ,
557- RestrictionType . BlockTransaction ,
633+ AccountRestrictionType . BlockIncomingTransactionType ,
558634 [ operationRestrictionFilter ] ,
559635 NetworkType . MIJIN_TEST ,
560636 ) ;
@@ -575,7 +651,7 @@ describe('TransactionHttp', () => {
575651 transactionHttp . announce ( signedTransaction ) ;
576652 } ) ;
577653 } ) ;
578- describe ( 'AccountRestrictionTransaction - Operation' , ( ) => {
654+ describe ( 'AccountRestrictionTransaction - Incoming Operation' , ( ) => {
579655 let listener : Listener ;
580656 before ( ( ) => {
581657 listener = new Listener ( config . apiUrl ) ;
@@ -591,7 +667,7 @@ describe('TransactionHttp', () => {
591667 ) ;
592668 const addressModification = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
593669 Deadline . create ( ) ,
594- RestrictionType . BlockTransaction ,
670+ AccountRestrictionType . BlockIncomingTransactionType ,
595671 [ operationRestrictionFilter ] ,
596672 NetworkType . MIJIN_TEST ,
597673 ) ;
@@ -612,6 +688,83 @@ describe('TransactionHttp', () => {
612688 transactionHttp . announce ( signedTransaction ) ;
613689 } ) ;
614690 } ) ;
691+
692+ describe ( 'AccountRestrictionTransaction - Outgoing Operation' , ( ) => {
693+ let listener : Listener ;
694+ before ( ( ) => {
695+ listener = new Listener ( config . apiUrl ) ;
696+ return listener . open ( ) ;
697+ } ) ;
698+ after ( ( ) => {
699+ return listener . close ( ) ;
700+ } ) ;
701+
702+ it ( 'standalone' , ( done ) => {
703+ const operationRestrictionFilter = AccountRestrictionModification . createForOperation (
704+ RestrictionModificationType . Add ,
705+ TransactionType . LINK_ACCOUNT ,
706+ ) ;
707+ const addressModification = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
708+ Deadline . create ( ) ,
709+ AccountRestrictionType . BlockOutgoingTransactionType ,
710+ [ operationRestrictionFilter ] ,
711+ NetworkType . MIJIN_TEST ,
712+ ) ;
713+ const signedTransaction = addressModification . signWith ( account3 , generationHash ) ;
714+
715+ listener . confirmed ( account3 . address ) . subscribe ( ( transaction : AccountOperationRestrictionModificationTransaction ) => {
716+ expect ( transaction . modifications , 'Modifications' ) . not . to . be . undefined ;
717+ expect ( transaction . modifications [ 0 ] . modificationType , 'Modifications.ModificationType' ) . not . to . be . undefined ;
718+ expect ( transaction . modifications [ 0 ] . value , 'Modifications.Value' ) . not . to . be . undefined ;
719+ expect ( transaction . restrictionType , 'RestrictionType' ) . not . to . be . undefined ;
720+ done ( ) ;
721+ } ) ;
722+ listener . status ( account3 . address ) . subscribe ( ( error ) => {
723+ console . log ( 'Error:' , error ) ;
724+ assert ( false ) ;
725+ done ( ) ;
726+ } ) ;
727+ transactionHttp . announce ( signedTransaction ) ;
728+ } ) ;
729+ } ) ;
730+ describe ( 'AccountRestrictionTransaction - Outgoing Operation' , ( ) => {
731+ let listener : Listener ;
732+ before ( ( ) => {
733+ listener = new Listener ( config . apiUrl ) ;
734+ return listener . open ( ) ;
735+ } ) ;
736+ after ( ( ) => {
737+ return listener . close ( ) ;
738+ } ) ;
739+ it ( 'aggregate' , ( done ) => {
740+ const operationRestrictionFilter = AccountRestrictionModification . createForOperation (
741+ RestrictionModificationType . Remove ,
742+ TransactionType . LINK_ACCOUNT ,
743+ ) ;
744+ const addressModification = AccountRestrictionTransaction . createOperationRestrictionModificationTransaction (
745+ Deadline . create ( ) ,
746+ AccountRestrictionType . BlockOutgoingTransactionType ,
747+ [ operationRestrictionFilter ] ,
748+ NetworkType . MIJIN_TEST ,
749+ ) ;
750+ const aggregateTransaction = AggregateTransaction . createComplete ( Deadline . create ( ) ,
751+ [ addressModification . toAggregate ( account3 . publicAccount ) ] ,
752+ NetworkType . MIJIN_TEST ,
753+ [ ] ,
754+ ) ;
755+ const signedTransaction = aggregateTransaction . signWith ( account3 , generationHash ) ;
756+ listener . confirmed ( account3 . address ) . subscribe ( ( transaction : Transaction ) => {
757+ done ( ) ;
758+ } ) ;
759+ listener . status ( account3 . address ) . subscribe ( ( error ) => {
760+ console . log ( 'Error:' , error ) ;
761+ assert ( false ) ;
762+ done ( ) ;
763+ } ) ;
764+ transactionHttp . announce ( signedTransaction ) ;
765+ } ) ;
766+ } ) ;
767+
615768 describe ( 'AccountLinkTransaction' , ( ) => {
616769 let listener : Listener ;
617770 before ( ( ) => {
0 commit comments