Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tokenTransfer property exposed in AbstractTokenTransferTransaction #2616

Merged
merged 2 commits into from
Oct 29, 2024
Merged
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
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 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 @@
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;
}

Check warning on line 433 in src/token/AbstractTokenTransferTransaction.js

View check run for this annotation

Codecov / codecov/patch

src/token/AbstractTokenTransferTransaction.js#L418-L433

Added lines #L418 - L433 were not covered by tests

/**
* @override
* @protected
Expand Down