Skip to content

Commit

Permalink
Fix genesis records creation order (#8749)
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Hess <[email protected]>
  • Loading branch information
mhess-swl authored Sep 19, 2023
1 parent cee09b5 commit e698740
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import edu.umd.cs.findbugs.annotations.Nullable;
import java.time.Instant;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import javax.inject.Singleton;
Expand Down Expand Up @@ -132,16 +133,18 @@ private void createAccountRecordBuilders(
@NonNull final TokenContext context,
@Nullable final String recordMemo,
@Nullable final Long overrideAutoRenewPeriod) {
for (Map.Entry<Account, CryptoCreateTransactionBody.Builder> entry : map.entrySet()) {
final var orderedAccts = map.keySet().stream()
.sorted(Comparator.comparingLong(acct -> acct.accountId().accountNum()))
.toList();
for (final Account key : orderedAccts) {
final var recordBuilder = context.addPrecedingChildRecordBuilder(GenesisAccountRecordBuilder.class);

final var accountId = requireNonNull(entry.getKey().accountId());
final var accountId = requireNonNull(key.accountId());
recordBuilder.accountID(accountId);
if (recordMemo != null) {
recordBuilder.memo(recordMemo);
}

var txnBody = entry.getValue();
var txnBody = map.get(key);
if (overrideAutoRenewPeriod != null) {
txnBody.autoRenewPeriod(Duration.newBuilder().seconds(overrideAutoRenewPeriod));
}
Expand Down

0 comments on commit e698740

Please sign in to comment.