Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/model/transaction/AggregateTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ export class AggregateTransaction extends Transaction {
);
}

/**
* @description add inner transactions to current list
* @param {InnerTransaction[]} transaction
* @returns {AggregateTransaction}
* @memberof AggregateTransaction
*/
public addTransactions(transactions: InnerTransaction[]): AggregateTransaction {
const innerTransactions = this.innerTransactions.concat(transactions);
return Object.assign({__proto__: Object.getPrototypeOf(this)}, this, {innerTransactions});
}

/**
* @internal
* @returns {AggregateTransaction}
Expand Down
27 changes: 27 additions & 0 deletions test/model/transaction/AggregateTransaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,33 @@ describe('AggregateTransaction', () => {
expect(standardCosignedTransaction.hash).to.be.equal(signedTransaction.hash);
});

it('Should be able to add innertransactions to current aggregate tx', () => {
const transferTx1 = TransferTransaction.create(Deadline.create(),
account.address,
[],
PlainMessage.create('a to b'),
NetworkType.MIJIN_TEST);
const transferTx2 = TransferTransaction.create(Deadline.create(),
account.address,
[],
PlainMessage.create('b to a'),
NetworkType.MIJIN_TEST);
let aggregateTransaction = AggregateTransaction.createComplete(
Deadline.create(),
[transferTx1.toAggregate(account.publicAccount)],
NetworkType.MIJIN_TEST,
[],
);

expect(aggregateTransaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE);
expect(aggregateTransaction.innerTransactions.length).to.be.equal(1);

aggregateTransaction = aggregateTransaction.addTransactions([transferTx2.toAggregate(account.publicAccount)]);

expect(aggregateTransaction.type).to.be.equal(TransactionType.AGGREGATE_COMPLETE);
expect(aggregateTransaction.innerTransactions.length).to.be.equal(2);
});

describe('size', () => {
it('should return 282 for AggregateTransaction byte size with TransferTransaction with 1 mosaic and message NEM', () => {
const transaction = TransferTransaction.create(
Expand Down