diff --git a/src/token/AbstractTokenTransferTransaction.js b/src/token/AbstractTokenTransferTransaction.js index 7a0432fdb..284d3fd72 100644 --- a/src/token/AbstractTokenTransferTransaction.js +++ b/src/token/AbstractTokenTransferTransaction.js @@ -27,6 +27,8 @@ import Transaction from "../transaction/Transaction.js"; import Long from "long"; import NullableTokenDecimalMap from "../account/NullableTokenDecimalMap.js"; import TokenNftTransferMap from "../account/TokenNftTransferMap.js"; +import TokenTransferMap from "../account/TokenTransferMap.js"; +import TokenTransferAccountMap from "../account/TokenTransferAccountMap.js"; /** * @namespace proto @@ -409,6 +411,27 @@ export default class AbstractTokenTransferTransaction extends Transaction { return map; } + /** + * @returns {TokenTransferMap} + */ + get tokenTransfers() { + const map = new TokenTransferMap(); + + for (const transfer of this._tokenTransfers) { + let transferMap = map.get(transfer.tokenId); + + if (transferMap != null) { + transferMap._set(transfer.accountId, transfer.amount); + } else { + transferMap = new TokenTransferAccountMap(); + transferMap._set(transfer.accountId, transfer.amount); + map._set(transfer.tokenId, transferMap); + } + } + + return map; + } + /** * @override * @protected