@@ -21,8 +21,10 @@ import {
21
21
NamespaceRegistrationTypeEnum ,
22
22
NetworkTypeEnum ,
23
23
TransactionInfoDTO ,
24
+ TransactionTypeEnum ,
24
25
TransferTransactionDTO ,
25
26
} from 'symbol-openapi-typescript-fetch-client' ;
27
+ import { MosaicId , NamespaceId } from '../../..' ;
26
28
import { CreateTransactionFromDTO } from '../../../src/infrastructure/transaction' ;
27
29
import { Address } from '../../../src/model/account' ;
28
30
import { TransferTransaction } from '../../../src/model/transaction' ;
@@ -708,4 +710,171 @@ describe('CreateTransactionFromDTO', () => {
708
710
) ;
709
711
} ) ;
710
712
} ) ;
713
+
714
+ describe ( 'Metadata Transactions' , ( ) => {
715
+ // standalone tx constants
716
+ const testTxSignature =
717
+ '7442156D839A3AC900BC0299E8701ECDABA674DCF91283223450953B005DE72C538EA54236F5E089530074CE78067CD3325CF53750B9118154C08B20A5CDC00D' ;
718
+ const testTxSignerPublicKey = '2FC3872A792933617D70E02AFF8FBDE152821A0DF0CA5FB04CB56FC3D21C8863' ;
719
+ const testTxDeadline = '71756535303' ;
720
+ const testTxHeight = '1' ;
721
+ const testTxHash = '533243B8575C4058F894C453160AFF055A4A905978AC331460F44104D831E4AC' ;
722
+ const testTxMerkleComponentHash = '533243B8575C4058F894C453160AFF055A4A905978AC331460F44104D831E4AC' ;
723
+ const testTxId = '5CD2B76B2B3F0F0001751380' ;
724
+ const testTxIndex = 0 ;
725
+ const testTxSize = 100 ;
726
+ const testTxMaxFee = '0' ;
727
+
728
+ // aggregate tx constants
729
+ const testAggTxId = '5A0069D83F17CF0001777E55' ;
730
+ const testAggTxHash = '671653C94E2254F2A23EFEDB15D67C38332AED1FBD24B063C0A8E675582B6A96' ;
731
+ const testAggTxHeight = '1860' ;
732
+ const testAggTxIndex = 0 ;
733
+ const testAggMerkleComponentHash = '81E5E7AE49998802DABC816EC10158D3A7879702FF29084C2C992CD1289877A7' ;
734
+ const testAggTxSize = 100 ;
735
+ const testAggTxCosigSignature =
736
+ '5780C8DF9D46BA2BCF029DCC5D3BF55FE1CB5BE7ABCF30387C4637DD' +
737
+ 'EDFC2152703CA0AD95F21BB9B942F3CC52FCFC2064C7B84CF60D1A9E69195F1943156C07' ;
738
+ const testAggCosigSignerPublicKey = 'A5F82EC8EBB341427B6785C8111906CD0DF18838FB11B51CE0E18B5E79DFF630' ;
739
+ const testAggTxDeadline = '1000' ;
740
+ const testAggTxMaxFee = '0' ;
741
+ const testAggTxSignature =
742
+ '939673209A13FF82397578D22CC96EB8516A6760C894D9B7535E3A1E0680' +
743
+ '07B9255CFA9A914C97142A7AE18533E381C846B69D2AE0D60D1DC8A55AD120E2B606' ;
744
+ const testAggTxSignerPublicKey = '7681ED5023141D9CDCF184E5A7B60B7D466739918ED5DA30F7E71EA7B86EFF2D' ;
745
+
746
+ // metadata tx constants
747
+ const testTargetAddress = 'TATNE7Q5BITMUTRRN6IB4I7FLSDRDWZA37JGO5Q' ;
748
+ const testScopedMedataKey = '00000000000003E8' ;
749
+
750
+ const prepBaseTxDto = ( txType : TransactionTypeEnum ) => ( {
751
+ signerPublicKey : testTxSignerPublicKey ,
752
+ version : 1 ,
753
+ network : NetworkTypeEnum . NUMBER_152 ,
754
+ type : txType ,
755
+ maxFee : testTxMaxFee ,
756
+ deadline : testTxDeadline ,
757
+ } ) ;
758
+
759
+ const prepAggregateTxDto = ( innerTransaction ) => ( {
760
+ id : testAggTxId ,
761
+ meta : {
762
+ hash : testAggTxHash ,
763
+ height : testAggTxHeight ,
764
+ index : testAggTxIndex ,
765
+ merkleComponentHash : testAggMerkleComponentHash ,
766
+ } ,
767
+ transaction : {
768
+ size : testAggTxSize ,
769
+ cosignatures : [
770
+ {
771
+ version : '0' ,
772
+ signature : testAggTxCosigSignature ,
773
+ signerPublicKey : testAggCosigSignerPublicKey ,
774
+ } ,
775
+ ] ,
776
+ deadline : testAggTxDeadline ,
777
+ maxFee : testAggTxMaxFee ,
778
+ signature : testAggTxSignature ,
779
+ signerPublicKey : testAggTxSignerPublicKey ,
780
+ transactions : [
781
+ {
782
+ id : testTxId ,
783
+ meta : {
784
+ aggregateHash : testAggTxHash ,
785
+ aggregateId : testAggTxId ,
786
+ height : testAggTxHeight ,
787
+ index : testAggTxIndex ,
788
+ } ,
789
+ transaction : innerTransaction ,
790
+ } ,
791
+ ] ,
792
+ type : 16705 ,
793
+ version : 1 ,
794
+ network : NetworkTypeEnum . NUMBER_152 ,
795
+ } ,
796
+ } ) ;
797
+
798
+ const prepStandaloneTxDto = ( transactionDto ) => ( {
799
+ id : testTxId ,
800
+ meta : {
801
+ height : testTxHeight ,
802
+ hash : testTxHash ,
803
+ merkleComponentHash : testTxMerkleComponentHash ,
804
+ index : testTxIndex ,
805
+ } ,
806
+ transaction : transactionDto ,
807
+ } ) ;
808
+
809
+ const prepTransactionDto = ( txDetails ) => ( {
810
+ size : testTxSize ,
811
+ signature : testTxSignature ,
812
+ ...txDetails ,
813
+ } ) ;
814
+
815
+ const testStandaloneAndAggregate = ( baseMetadataTxDto , txType ) => {
816
+ it ( 'standalone' , ( ) => {
817
+ // arrange
818
+ const metadataTransactionDto : TransactionInfoDTO = prepStandaloneTxDto ( prepTransactionDto ( baseMetadataTxDto ) ) ;
819
+
820
+ // act
821
+ const metadataTransaction = CreateTransactionFromDTO ( metadataTransactionDto ) ;
822
+
823
+ // assert
824
+ expect ( metadataTransaction . type ) . eq ( txType ) ;
825
+ expect ( metadataTransaction . size ) . eq ( testTxSize ) ;
826
+ ValidateTransaction . validateStandaloneTx ( metadataTransaction , metadataTransactionDto ) ;
827
+ } ) ;
828
+
829
+ it ( 'aggregate' , ( ) => {
830
+ // arrange
831
+ const aggregateMetadataTransactionDto = prepAggregateTxDto ( baseMetadataTxDto ) ;
832
+
833
+ // act
834
+ const aggregateMetadataTransaction = CreateTransactionFromDTO ( aggregateMetadataTransactionDto ) ;
835
+
836
+ // assert
837
+ expect ( aggregateMetadataTransaction . size ) . eq ( testAggTxSize ) ;
838
+ ValidateTransaction . validateAggregateTx ( aggregateMetadataTransaction , aggregateMetadataTransactionDto ) ;
839
+ } ) ;
840
+ } ;
841
+
842
+ describe ( 'AccountMetadataTransaction' , ( ) => {
843
+ const baseAccountMetadataTxDto = {
844
+ ...prepBaseTxDto ( TransactionTypeEnum . NUMBER_16708 ) ,
845
+ targetAddress : testTargetAddress ,
846
+ scopedMetadataKey : testScopedMedataKey ,
847
+ valueSizeDelta : 49 ,
848
+ valueSize : 49 ,
849
+ value : '5468697320697320746865206D65737361676520666F722074686973206163636F756E742120E6B189E5AD973839363634' ,
850
+ } ;
851
+ testStandaloneAndAggregate ( baseAccountMetadataTxDto , TransactionTypeDto . ACCOUNT_METADATA ) ;
852
+ } ) ;
853
+
854
+ describe ( 'MosaicMetadataTransaction' , ( ) => {
855
+ const baseMosaicMetadataTxDto = {
856
+ ...prepBaseTxDto ( TransactionTypeEnum . NUMBER_16964 ) ,
857
+ targetAddress : testTargetAddress ,
858
+ scopedMetadataKey : testScopedMedataKey ,
859
+ targetMosaicId : new MosaicId ( [ 2262289484 , 3405110546 ] ) . toHex ( ) ,
860
+ valueSizeDelta : 48 ,
861
+ valueSize : 48 ,
862
+ value : '5468697320697320746865206D65737361676520666F722074686973206D6F736169632120E6B189E5AD973839363634' ,
863
+ } ;
864
+ testStandaloneAndAggregate ( baseMosaicMetadataTxDto , TransactionTypeDto . MOSAIC_METADATA ) ;
865
+ } ) ;
866
+
867
+ describe ( 'NamespaceMetadataTransaction' , ( ) => {
868
+ const baseNamespaceMetadataTxDto = {
869
+ ...prepBaseTxDto ( TransactionTypeEnum . NUMBER_17220 ) ,
870
+ targetAddress : testTargetAddress ,
871
+ scopedMetadataKey : testScopedMedataKey ,
872
+ targetNamespaceId : new NamespaceId ( [ 929036875 , 2226345261 ] ) . toHex ( ) ,
873
+ valueSizeDelta : 51 ,
874
+ valueSize : 51 ,
875
+ value : '5468697320697320746865206D65737361676520666F722074686973206E616D6573706163652120E6B189E5AD973839363634' ,
876
+ } ;
877
+ testStandaloneAndAggregate ( baseNamespaceMetadataTxDto , TransactionTypeDto . NAMESPACE_METADATA ) ;
878
+ } ) ;
879
+ } ) ;
711
880
} ) ;
0 commit comments