use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class AddressBookServiceEndpointRepositoryTest method addressBookEntry.
private AddressBookEntry addressBookEntry(long consensusTimestamp, long nodeAccountId, List<Integer> portNums) throws UnknownHostException {
long nodeId = nodeAccountId - 3;
String nodeAccountIdString = String.format("0.0.%s", nodeAccountId);
EntityId nodeAccountEntityId = EntityId.of(nodeAccountIdString, EntityType.ACCOUNT);
AddressBookEntry.AddressBookEntryBuilder builder = AddressBookEntry.builder().consensusTimestamp(consensusTimestamp).memo(nodeAccountIdString).nodeAccountId(nodeAccountEntityId).nodeCertHash("nodeCertHash".getBytes()).nodeId(nodeId).publicKey("rsa+public/key");
if (!CollectionUtils.isEmpty(portNums)) {
Set<AddressBookServiceEndpoint> serviceEndpoints = new HashSet<>();
for (int i = 0; i < portNums.size(); i++) {
serviceEndpoints.add(addressBookServiceEndpoint(consensusTimestamp, InetAddress.getByName("127.0.0." + i).getHostAddress(), portNums.get(i), nodeId));
}
builder.serviceEndpoints(serviceEndpoints);
}
return builder.build();
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertTokenAccountUnfreeze.
private void insertTokenAccountUnfreeze(RecordItem recordItem) {
if (entityProperties.getPersist().isTokens()) {
TokenUnfreezeAccountTransactionBody tokenUnfreezeAccountTransactionBody = recordItem.getTransactionBody().getTokenUnfreeze();
EntityId tokenId = EntityId.of(tokenUnfreezeAccountTransactionBody.getToken());
EntityId accountId = EntityId.of(tokenUnfreezeAccountTransactionBody.getAccount());
long consensusTimestamp = recordItem.getConsensusTimestamp();
TokenAccount tokenAccount = new TokenAccount(tokenId, accountId, consensusTimestamp);
tokenAccount.setFreezeStatus(TokenFreezeStatusEnum.UNFROZEN);
entityListener.onTokenAccount(tokenAccount);
}
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertTokenTransfers.
private void insertTokenTransfers(RecordItem recordItem) {
if (!entityProperties.getPersist().isTokens()) {
return;
}
long consensusTimestamp = recordItem.getConsensusTimestamp();
TransactionBody body = recordItem.getTransactionBody();
boolean isTokenDissociate = body.hasTokenDissociate();
recordItem.getRecord().getTokenTransferListsList().forEach(tokenTransferList -> {
TokenID tokenId = tokenTransferList.getToken();
EntityId entityTokenId = EntityId.of(tokenId);
EntityId payerAccountId = recordItem.getPayerAccountId();
insertFungibleTokenTransfers(consensusTimestamp, body, isTokenDissociate, tokenId, entityTokenId, payerAccountId, tokenTransferList.getTransfersList());
insertNonFungibleTokenTransfers(consensusTimestamp, body, tokenId, entityTokenId, payerAccountId, tokenTransferList.getNftTransfersList());
});
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method parseFixedFee.
/**
* Parse protobuf FixedFee object to domain CustomFee object.
*
* @param customFee the domain CustomFee object
* @param fixedFee the protobuf FixedFee object
* @param tokenId the attached token id
* @return whether the fee is paid in the attached token
*/
private boolean parseFixedFee(CustomFee customFee, FixedFee fixedFee, EntityId tokenId) {
customFee.setAmount(fixedFee.getAmount());
if (fixedFee.hasDenominatingTokenId()) {
EntityId denominatingTokenId = EntityId.of(fixedFee.getDenominatingTokenId());
denominatingTokenId = denominatingTokenId == EntityId.EMPTY ? tokenId : denominatingTokenId;
customFee.setDenominatingTokenId(denominatingTokenId);
return denominatingTokenId.equals(tokenId);
}
return false;
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertTokenDissociate.
private void insertTokenDissociate(RecordItem recordItem) {
if (entityProperties.getPersist().isTokens()) {
TokenDissociateTransactionBody tokenDissociateTransactionBody = recordItem.getTransactionBody().getTokenDissociate();
EntityId accountId = EntityId.of(tokenDissociateTransactionBody.getAccount());
long consensusTimestamp = recordItem.getConsensusTimestamp();
tokenDissociateTransactionBody.getTokensList().forEach(token -> {
EntityId tokenId = EntityId.of(token);
TokenAccount tokenAccount = new TokenAccount(tokenId, accountId, consensusTimestamp);
tokenAccount.setAssociated(false);
entityListener.onTokenAccount(tokenAccount);
});
}
}
Aggregations