1414 * limitations under the License.
1515 */
1616
17- import { SignSchema } from '../../core/crypto/SignSchema' ;
18- import { Convert } from '../../core/format' ;
19- import { AccountOperationRestrictionModificationBuilder } from '../../infrastructure/catbuffer/AccountOperationRestrictionModificationBuilder' ;
20- import { AccountOperationRestrictionTransactionBuilder } from '../../infrastructure/catbuffer/AccountOperationRestrictionTransactionBuilder' ;
21- import { AmountDto } from '../../infrastructure/catbuffer/AmountDto' ;
22- import { EmbeddedAccountOperationRestrictionTransactionBuilder } from '../../infrastructure/catbuffer/EmbeddedAccountOperationRestrictionTransactionBuilder' ;
23- import { KeyDto } from '../../infrastructure/catbuffer/KeyDto' ;
24- import { SignatureDto } from '../../infrastructure/catbuffer/SignatureDto' ;
25- import { TimestampDto } from '../../infrastructure/catbuffer/TimestampDto' ;
26- import { AccountRestrictionType } from '../account/AccountRestrictionType' ;
17+ import { Builder } from '../../infrastructure/builders/AccountRestrictionsEntityTypeTransaction' ;
18+ import { VerifiableTransaction } from '../../infrastructure/builders/VerifiableTransaction' ;
2719import { PublicAccount } from '../account/PublicAccount' ;
20+ import { RestrictionType } from '../account/RestrictionType' ;
2821import { NetworkType } from '../blockchain/NetworkType' ;
2922import { UInt64 } from '../UInt64' ;
3023import { AccountRestrictionModification } from './AccountRestrictionModification' ;
3124import { Deadline } from './Deadline' ;
32- import { InnerTransaction } from './InnerTransaction' ;
3325import { Transaction } from './Transaction' ;
3426import { TransactionInfo } from './TransactionInfo' ;
3527import { TransactionType } from './TransactionType' ;
3628import { TransactionVersion } from './TransactionVersion' ;
29+ import { AccountOperationRestrictionModificationBuilder } from '../../infrastructure/catbuffer/AccountOperationRestrictionModificationBuilder' ;
30+ import { AccountOperationRestrictionTransactionBuilder } from '../../infrastructure/catbuffer/AccountOperationRestrictionTransactionBuilder' ;
31+ import { SignatureDto } from '../../infrastructure/catbuffer/SignatureDto' ;
32+ import { KeyDto } from '../../infrastructure/catbuffer/KeyDto' ;
33+ import { EntityTypeDto } from '../../infrastructure/catbuffer/EntityTypeDto' ;
34+ import { AmountDto } from '../../infrastructure/catbuffer/AmountDto' ;
35+ import { TimestampDto } from '../../infrastructure/catbuffer/TimestampDto' ;
3736
3837export class AccountOperationRestrictionTransaction extends Transaction {
3938
@@ -47,7 +46,7 @@ export class AccountOperationRestrictionTransaction extends Transaction {
4746 * @returns {AccountOperationRestrictionTransaction }
4847 */
4948 public static create ( deadline : Deadline ,
50- restrictionType : AccountRestrictionType ,
49+ restrictionType : RestrictionType ,
5150 modifications : Array < AccountRestrictionModification < TransactionType > > ,
5251 networkType : NetworkType ,
5352 maxFee : UInt64 = new UInt64 ( [ 0 , 0 ] ) ) : AccountOperationRestrictionTransaction {
@@ -74,7 +73,7 @@ export class AccountOperationRestrictionTransaction extends Transaction {
7473 version : number ,
7574 deadline : Deadline ,
7675 maxFee : UInt64 ,
77- public readonly restrictionType : AccountRestrictionType ,
76+ public readonly restrictionType : RestrictionType ,
7877 public readonly modifications : Array < AccountRestrictionModification < TransactionType > > ,
7978 signature ?: string ,
8079 signer ?: PublicAccount ,
@@ -83,36 +82,6 @@ export class AccountOperationRestrictionTransaction extends Transaction {
8382 networkType , version , deadline , maxFee , signature , signer , transactionInfo ) ;
8483 }
8584
86- /**
87- * Create a transaction object from payload
88- * @param {string } payload Binary payload
89- * @param {Boolean } isEmbedded Is embedded transaction (Default: false)
90- * @param {SignSchema } signSchema The Sign Schema. (KECCAK_REVERSED_KEY / SHA3)
91- * @returns {Transaction | InnerTransaction }
92- */
93- public static createFromPayload ( payload : string ,
94- isEmbedded : boolean = false ,
95- signSchema : SignSchema = SignSchema . SHA3 ) : Transaction | InnerTransaction {
96- const builder = isEmbedded ? EmbeddedAccountOperationRestrictionTransactionBuilder . loadFromBinary ( Convert . hexToUint8 ( payload ) ) :
97- AccountOperationRestrictionTransactionBuilder . loadFromBinary ( Convert . hexToUint8 ( payload ) ) ;
98- const signer = Convert . uint8ToHex ( builder . getSigner ( ) . key ) ;
99- const networkType = Convert . hexToUint8 ( builder . getVersion ( ) . toString ( 16 ) ) [ 0 ] ;
100- const transaction = AccountOperationRestrictionTransaction . create (
101- isEmbedded ? Deadline . create ( ) : Deadline . createFromDTO (
102- ( builder as AccountOperationRestrictionTransactionBuilder ) . getDeadline ( ) . timestamp ) ,
103- builder . getRestrictionType ( ) . valueOf ( ) ,
104- builder . getModifications ( ) . map ( ( modification ) => {
105- return AccountRestrictionModification . createForOperation (
106- modification . modificationAction . valueOf ( ) ,
107- modification . value . valueOf ( ) ,
108- ) ;
109- } ) ,
110- networkType ,
111- isEmbedded ? new UInt64 ( [ 0 , 0 ] ) : new UInt64 ( ( builder as AccountOperationRestrictionTransactionBuilder ) . fee . amount ) ,
112- ) ;
113- return isEmbedded ? transaction . toAggregate ( PublicAccount . createFromPublicKey ( signer , networkType , signSchema ) ) : transaction ;
114- }
115-
11685 /**
11786 * @override Transaction.size()
11887 * @description get the byte size of a AccountOperationRestrictionTransaction
@@ -134,6 +103,20 @@ export class AccountOperationRestrictionTransaction extends Transaction {
134103 return byteSize + byteRestrictionType + byteModificationCount + byteModifications ;
135104 }
136105
106+ /**
107+ * @internal
108+ * @returns {VerifiableTransaction }
109+ */
110+ protected buildTransaction ( ) : VerifiableTransaction {
111+ return new Builder ( )
112+ . addDeadline ( this . deadline . toDTO ( ) )
113+ . addFee ( this . maxFee . toDTO ( ) )
114+ . addVersion ( this . versionToDTO ( ) )
115+ . addRestrictionType ( this . restrictionType )
116+ . addModifications ( this . modifications . map ( ( modification ) => modification . toDTO ( ) ) )
117+ . build ( ) ;
118+ }
119+
137120 /**
138121 * @internal
139122 * @returns {Uint8Array }
@@ -159,24 +142,4 @@ export class AccountOperationRestrictionTransaction extends Transaction {
159142 ) ;
160143 return transactionBuilder . serialize ( ) ;
161144 }
162-
163- /**
164- * @internal
165- * @returns {Uint8Array }
166- */
167- protected generateEmbeddedBytes ( ) : Uint8Array {
168- const transactionBuilder = new EmbeddedAccountOperationRestrictionTransactionBuilder (
169- new KeyDto ( Convert . hexToUint8 ( this . signer ! . publicKey ) ) ,
170- this . versionToDTO ( ) ,
171- TransactionType . ACCOUNT_RESTRICTION_OPERATION . valueOf ( ) ,
172- this . restrictionType . valueOf ( ) ,
173- this . modifications . map ( ( modification ) => {
174- return new AccountOperationRestrictionModificationBuilder (
175- modification . modificationType . valueOf ( ) ,
176- modification . value . valueOf ( ) ,
177- ) ;
178- } ) ,
179- ) ;
180- return transactionBuilder . serialize ( ) ;
181- }
182145}
0 commit comments