Skip to content

Commit

Permalink
update: add a new getter to the TransferTransaction class
Browse files Browse the repository at this point in the history
Signed-off-by: svetoslav-nikol0v <[email protected]>
  • Loading branch information
svetoslav-nikol0v committed Mar 19, 2024
1 parent 3b91b88 commit d537f33
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/account/TransferTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,13 @@ export default class TransferTransaction extends Transaction {
return map;
}

/**
* @returns {Transfer[]}
*/
get hbarTransfersList() {
return this._hbarTransfers;
}

/**
* @internal
* @param {AccountId | string} accountId
Expand Down
23 changes: 23 additions & 0 deletions test/unit/TransferTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,27 @@ describe("TransferTransaction", function () {
],
});
});

it("should return hbarTransfer list", function () {
const accountId1 = AccountId.fromString("0.0.0");
const accountId2 = AccountId.fromString("0.0.1");
const amount = new Hbar(1);

const tx = new TransferTransaction()
.addHbarTransfer(accountId1, amount.negated())
.addHbarTransfer(accountId2, amount);

expect(tx.hbarTransfersList).to.deep.equal([
{
accountId: accountId1,
amount: amount.negated(),
isApproved: false,
},
{
accountId: accountId2,
amount: amount,
isApproved: false,
},
]);
});
});

0 comments on commit d537f33

Please sign in to comment.