Skip to content

Commit

Permalink
feat: tokenTransfer property exposed in AbstractTokenTransferTransact…
Browse files Browse the repository at this point in the history
…ion (#2616)

Signed-off-by: ivaylogarnev-limechain <[email protected]>
  • Loading branch information
ivaylogarnev-limechain authored Oct 29, 2024
1 parent 0d36abe commit a563a06
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/token/AbstractTokenTransferTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a563a06

Please sign in to comment.