Skip to content

Commit b1905fd

Browse files
author
Greg S
committed
issue #53: make maxFee field optional with default value 0
1 parent 882971d commit b1905fd

34 files changed

+575
-198
lines changed

e2e/infrastructure/TransactionHttp.spec.ts

Lines changed: 0 additions & 57 deletions
Large diffs are not rendered by default.

e2e/infrastructure/TransactionUtils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export class TransactionUtils {
3838
const account = TestingAccount;
3939
const transferTransaction = TransferTransaction.create(
4040
Deadline.create(),
41-
new UInt64([0, 0]),
4241
recipient,
4342
[],
4443
PlainMessage.create('test-message'),
@@ -52,7 +51,6 @@ export class TransactionUtils {
5251
const account = TestingAccount;
5352
const transferTransaction = TransferTransaction.create(
5453
Deadline.create(),
55-
new UInt64([0, 0]),
5654
Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC'),
5755
[NetworkCurrencyMosaic.createRelative(100000000000)],
5856
PlainMessage.create('test-message'),
@@ -65,7 +63,6 @@ export class TransactionUtils {
6563
public static createAggregateBoundedTransactionAndAnnounce(transactionHttp: TransactionHttp = new TransactionHttp(NIS2_URL)) {
6664
const transferTransaction = TransferTransaction.create(
6765
Deadline.create(),
68-
new UInt64([0, 0]),
6966
Address.createFromRawAddress('SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC'),
7067
[NetworkCurrencyMosaic.createRelative(100000000000)],
7168
PlainMessage.create('test-message'),
@@ -74,7 +71,6 @@ export class TransactionUtils {
7471

7572
const aggregateTransaction = AggregateTransaction.createBonded(
7673
Deadline.create(2, ChronoUnit.MINUTES),
77-
new UInt64([0, 0]),
7874
[transferTransaction.toAggregate(MultisigAccount.publicAccount)],
7975
NetworkType.MIJIN_TEST,
8076
[],

src/model/transaction/AccountLinkTransaction.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,18 @@ export class AccountLinkTransaction extends Transaction {
3535
* @param deadline - The deadline to include the transaction.
3636
* @param remoteAccountKey - The public key of the remote account.
3737
* @param linkAction - The account link action.
38+
* @param maxFee - (Optional) Max fee defined by the sender
3839
* @returns {AccountLinkTransaction}
3940
*/
4041
public static create(deadline: Deadline,
4142
remoteAccountKey: string,
4243
linkAction: LinkAction,
43-
networkType: NetworkType): AccountLinkTransaction {
44+
networkType: NetworkType,
45+
maxFee: UInt64 = new UInt64([0, 0])): AccountLinkTransaction {
4446
return new AccountLinkTransaction(networkType,
4547
TransactionVersion.LINK_ACCOUNT,
4648
deadline,
47-
new UInt64([0, 0]),
49+
maxFee,
4850
remoteAccountKey,
4951
linkAction);
5052
}
@@ -53,7 +55,7 @@ export class AccountLinkTransaction extends Transaction {
5355
* @param networkType
5456
* @param version
5557
* @param deadline
56-
* @param fee
58+
* @param maxFee
5759
* @param remoteAccountKey
5860
* @param linkAction
5961
* @param signature
@@ -63,7 +65,7 @@ export class AccountLinkTransaction extends Transaction {
6365
constructor(networkType: NetworkType,
6466
version: number,
6567
deadline: Deadline,
66-
fee: UInt64,
68+
maxFee: UInt64,
6769
/**
6870
* The public key of the remote account.
6971
*/
@@ -75,7 +77,7 @@ export class AccountLinkTransaction extends Transaction {
7577
signature?: string,
7678
signer?: PublicAccount,
7779
transactionInfo?: TransactionInfo) {
78-
super(TransactionType.LINK_ACCOUNT, networkType, version, deadline, fee, signature, signer, transactionInfo);
80+
super(TransactionType.LINK_ACCOUNT, networkType, version, deadline, maxFee, signature, signer, transactionInfo);
7981
}
8082

8183
/**
@@ -85,7 +87,7 @@ export class AccountLinkTransaction extends Transaction {
8587
protected buildTransaction(): VerifiableTransaction {
8688
return new AccountLinkTransactionLibrary.Builder()
8789
.addDeadline(this.deadline.toDTO())
88-
.addFee(this.fee.toDTO())
90+
.addFee(this.maxFee.toDTO())
8991
.addVersion(this.versionToDTO())
9092
.addRemoteAccountKey(this.remoteAccountKey)
9193
.addLinkAction(this.linkAction)

src/model/transaction/AccountPropertyTransaction.ts

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { PropertyModificationType } from '../account/PropertyModificationType';
1919
import { PropertyType } from '../account/PropertyType';
2020
import { NetworkType } from '../blockchain/NetworkType';
2121
import { MosaicId } from '../mosaic/MosaicId';
22+
import { UInt64 } from '../Uint64';
2223
import { AccountPropertyModification } from './AccountPropertyModification';
2324
import { Deadline } from './Deadline';
2425
import { ModifyAccountPropertyAddressTransaction } from './ModifyAccountPropertyAddressTransaction';
@@ -32,16 +33,26 @@ export class AccountPropertyTransaction {
3233
* @param propertyType - Type of account property transaction
3334
* @param modification - array of address modifications
3435
* @param networkType - The network type.
36+
* @param maxFee - (Optional) Max fee defined by the sender
3537
* @returns {ModifyAccountPropertyAddressTransaction}
3638
*/
37-
public static createAddressPropertyModificationTransaction(deadline: Deadline,
38-
propertyType: PropertyType,
39-
modifications: Array<AccountPropertyModification<string>>,
40-
networkType: NetworkType): ModifyAccountPropertyAddressTransaction {
39+
public static createAddressPropertyModificationTransaction(
40+
deadline: Deadline,
41+
propertyType: PropertyType,
42+
modifications: Array<AccountPropertyModification<string>>,
43+
networkType: NetworkType,
44+
maxFee: UInt64 = new UInt64([0, 0])
45+
): ModifyAccountPropertyAddressTransaction {
4146
if (![PropertyType.AllowAddress, PropertyType.BlockAddress].includes(propertyType)) {
4247
throw new Error ('Property type is not allowed.');
4348
}
44-
return ModifyAccountPropertyAddressTransaction.create(deadline, propertyType, modifications, networkType);
49+
return ModifyAccountPropertyAddressTransaction.create(
50+
deadline,
51+
propertyType,
52+
modifications,
53+
networkType,
54+
maxFee
55+
);
4556
}
4657

4758
/**
@@ -50,16 +61,26 @@ export class AccountPropertyTransaction {
5061
* @param propertyType - Type of account property transaction
5162
* @param modification - array of mosaic modifications
5263
* @param networkType - The network type.
64+
* @param maxFee - (Optional) Max fee defined by the sender
5365
* @returns {ModifyAccountPropertyMosaicTransaction}
5466
*/
55-
public static createMosaicPropertyModificationTransaction(deadline: Deadline,
56-
propertyType: PropertyType,
57-
modifications: Array<AccountPropertyModification<number[]>>,
58-
networkType: NetworkType): ModifyAccountPropertyMosaicTransaction {
67+
public static createMosaicPropertyModificationTransaction(
68+
deadline: Deadline,
69+
propertyType: PropertyType,
70+
modifications: Array<AccountPropertyModification<number[]>>,
71+
networkType: NetworkType,
72+
maxFee: UInt64 = new UInt64([0, 0])
73+
): ModifyAccountPropertyMosaicTransaction {
5974
if (![PropertyType.AllowMosaic, PropertyType.BlockMosaic].includes(propertyType)) {
6075
throw new Error ('Property type is not allowed.');
6176
}
62-
return ModifyAccountPropertyMosaicTransaction.create(deadline, propertyType, modifications, networkType);
77+
return ModifyAccountPropertyMosaicTransaction.create(
78+
deadline,
79+
propertyType,
80+
modifications,
81+
networkType,
82+
maxFee
83+
);
6384
}
6485

6586
/**
@@ -68,16 +89,26 @@ export class AccountPropertyTransaction {
6889
* @param propertyType - Type of account property transaction
6990
* @param modification - array of entity type modifications
7091
* @param networkType - The network type.
92+
* @param maxFee - (Optional) Max fee defined by the sender
7193
* @returns {ModifyAccountPropertyEntityTypeTransaction}
7294
*/
73-
public static createEntityTypePropertyModificationTransaction(deadline: Deadline,
74-
propertyType: PropertyType,
75-
modifications: Array<AccountPropertyModification<number>>,
76-
networkType: NetworkType): ModifyAccountPropertyEntityTypeTransaction {
95+
public static createEntityTypePropertyModificationTransaction(
96+
deadline: Deadline,
97+
propertyType: PropertyType,
98+
modifications: Array<AccountPropertyModification<number>>,
99+
networkType: NetworkType,
100+
maxFee: UInt64 = new UInt64([0, 0])
101+
): ModifyAccountPropertyEntityTypeTransaction {
77102
if (![PropertyType.AllowTransaction, PropertyType.BlockTransaction].includes(propertyType)) {
78103
throw new Error ('Property type is not allowed.');
79104
}
80-
return ModifyAccountPropertyEntityTypeTransaction.create(deadline, propertyType, modifications, networkType);
105+
return ModifyAccountPropertyEntityTypeTransaction.create(
106+
deadline,
107+
propertyType,
108+
modifications,
109+
networkType,
110+
maxFee
111+
);
81112
}
82113

83114
/**

src/model/transaction/AddressAliasTransaction.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ export class AddressAliasTransaction extends Transaction {
3636
/**
3737
* Create a mosaic supply change transaction object
3838
* @param deadline - The deadline to include the transaction.
39-
* @param maxFee - Max fee defined by the sender
4039
* @param actionType - The namespace id.
4140
* @param namespaceId - The namespace id.
4241
* @param mosaicId - The mosaic id.
4342
* @param networkType - The network type.
43+
* @param maxFee - (Optional) Max fee defined by the sender
4444
* @returns {AddressAliasTransaction}
4545
*/
4646
public static create(deadline: Deadline,
47-
maxFee: UInt64,
4847
actionType: AliasActionType,
4948
namespaceId: NamespaceId,
5049
address: Address,
51-
networkType: NetworkType): AddressAliasTransaction {
50+
networkType: NetworkType,
51+
maxFee: UInt64 = new UInt64([0, 0])): AddressAliasTransaction {
5252
return new AddressAliasTransaction(networkType,
5353
TransactionVersion.ADDRESS_ALIAS,
5454
deadline,
@@ -90,7 +90,7 @@ export class AddressAliasTransaction extends Transaction {
9090
signature?: string,
9191
signer?: PublicAccount,
9292
transactionInfo?: TransactionInfo) {
93-
super(TransactionType.ADDRESS_ALIAS, networkType, version, deadline, fee, signature, signer, transactionInfo);
93+
super(TransactionType.ADDRESS_ALIAS, networkType, version, deadline, maxFee, signature, signer, transactionInfo);
9494
}
9595

9696
/**

src/model/transaction/AggregateTransaction.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,17 @@ export class AggregateTransaction extends Transaction {
6767
/**
6868
* Create an aggregate complete transaction object
6969
* @param deadline - The deadline to include the transaction.
70-
* @param {maxFee} maxFee
7170
* @param innerTransactions - The array of inner innerTransactions.
7271
* @param networkType - The network type.
7372
* @param cosignatures
73+
* @param maxFee - (Optional) Max fee defined by the sender
7474
* @returns {AggregateTransaction}
7575
*/
7676
public static createComplete(deadline: Deadline,
77-
maxFee: UInt64,
7877
innerTransactions: InnerTransaction[],
7978
networkType: NetworkType,
80-
cosignatures: AggregateTransactionCosignature[]): AggregateTransaction {
79+
cosignatures: AggregateTransactionCosignature[],
80+
maxFee: UInt64 = new UInt64([0, 0])): AggregateTransaction {
8181
return new AggregateTransaction(networkType,
8282
TransactionType.AGGREGATE_COMPLETE,
8383
TransactionVersion.AGGREGATE_COMPLETE,
@@ -91,17 +91,17 @@ export class AggregateTransaction extends Transaction {
9191
/**
9292
* Create an aggregate bonded transaction object
9393
* @param {Deadline} deadline
94-
* @param {maxFee} maxFee
9594
* @param {InnerTransaction[]} innerTransactions
9695
* @param {NetworkType} networkType
9796
* @param {AggregateTransactionCosignature[]} cosignatures
97+
* @param {UInt64} maxFee - (Optional) Max fee defined by the sender
9898
* @return {AggregateTransaction}
9999
*/
100100
public static createBonded(deadline: Deadline,
101-
maxFee: UInt64,
102101
innerTransactions: InnerTransaction[],
103102
networkType: NetworkType,
104-
cosignatures: AggregateTransactionCosignature[] = []): AggregateTransaction {
103+
cosignatures: AggregateTransactionCosignature[] = [],
104+
maxFee: UInt64 = new UInt64([0, 0])): AggregateTransaction {
105105
return new AggregateTransaction(networkType,
106106
TransactionType.AGGREGATE_BONDED,
107107
TransactionVersion.AGGREGATE_BONDED,

src/model/transaction/AliasTransaction.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,39 +35,53 @@ export abstract class AliasTransaction extends Transaction {
3535
/**
3636
* Create an address alias transaction object
3737
* @param deadline - The deadline to include the transaction.
38-
* @param maxFee - Max fee defined by the sender
3938
* @param aliasAction - The namespace id.
4039
* @param namespaceId - The namespace id.
4140
* @param address - The address.
4241
* @param networkType - The network type.
42+
* @param maxFee - (Optional) Max fee defined by the sender
4343
* @returns {AddressAliasTransaction}
4444
*/
4545
public static createForAddress(deadline: Deadline,
46-
maxFee: UInt64,
4746
aliasAction: AliasActionType,
4847
namespaceId: NamespaceId,
4948
address: Address,
50-
networkType: NetworkType): AliasTransaction {
51-
return AddressAliasTransaction.create(deadline, maxFee, aliasAction, namespaceId, address, networkType);
49+
networkType: NetworkType,
50+
maxFee: UInt64 = new UInt64([0, 0])): AliasTransaction {
51+
return AddressAliasTransaction.create(
52+
deadline,
53+
aliasAction,
54+
namespaceId,
55+
address,
56+
networkType,
57+
maxFee,
58+
);
5259
}
5360

5461
/**
5562
* Create a mosaic alias transaction object
5663
* @param deadline - The deadline to include the transaction.
57-
* @param maxFee - Max fee defined by the sender
5864
* @param aliasAction - The namespace id.
5965
* @param namespaceId - The namespace id.
6066
* @param mosaicId - The mosaic id.
6167
* @param networkType - The network type.
68+
* @param maxFee - (Optional) Max fee defined by the sender
6269
* @returns {MosaicAliasTransaction}
6370
*/
6471
public static createForMosaic(deadline: Deadline,
65-
maxFee: UInt64,
6672
aliasAction: AliasActionType,
6773
namespaceId: NamespaceId,
6874
mosaicId: MosaicId,
69-
networkType: NetworkType): AliasTransaction {
70-
return MosaicAliasTransaction.create(deadline, maxFee, aliasAction, namespaceId, mosaicId, networkType);
75+
networkType: NetworkType,
76+
maxFee: UInt64 = new UInt64([0, 0])): AliasTransaction {
77+
return MosaicAliasTransaction.create(
78+
deadline,
79+
aliasAction,
80+
namespaceId,
81+
mosaicId,
82+
networkType,
83+
maxFee,
84+
);
7185
}
7286

7387
}

src/model/transaction/LockFundsTransaction.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,19 @@ export class LockFundsTransaction extends Transaction {
4242
/**
4343
* Create a Lock funds transaction object
4444
* @param deadline - The deadline to include the transaction.
45-
* @param maxFee - Max fee defined by the sender
4645
* @param mosaic - The locked mosaic.
4746
* @param duration - The funds lock duration.
4847
* @param signedTransaction - The signed transaction for which funds are locked.
4948
* @param networkType - The network type.
49+
* @param maxFee - (Optional) Max fee defined by the sender
50+
* @returns {LockFundsTransaction}
5051
*/
5152
public static create(deadline: Deadline,
52-
maxFee: UInt64,
5353
mosaic: Mosaic,
5454
duration: UInt64,
5555
signedTransaction: SignedTransaction,
56-
networkType: NetworkType): LockFundsTransaction {
56+
networkType: NetworkType,
57+
maxFee: UInt64 = new UInt64([0, 0])): LockFundsTransaction {
5758
return new LockFundsTransaction(
5859
networkType,
5960
TransactionVersion.LOCK,

0 commit comments

Comments
 (0)