Search in sources :

Example 81 with EntityId

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();
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) AddressBookServiceEndpoint(com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint) AddressBookEntry(com.hedera.mirror.common.domain.addressbook.AddressBookEntry) AddressBookServiceEndpoint(com.hedera.mirror.common.domain.addressbook.AddressBookServiceEndpoint) HashSet(java.util.HashSet)

Example 82 with EntityId

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);
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenUnfreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenUnfreezeAccountTransactionBody) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount)

Example 83 with EntityId

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());
    });
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenUnpauseTransactionBody(com.hederahashgraph.api.proto.java.TokenUnpauseTransactionBody) TokenRevokeKycTransactionBody(com.hederahashgraph.api.proto.java.TokenRevokeKycTransactionBody) FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TokenPauseTransactionBody(com.hederahashgraph.api.proto.java.TokenPauseTransactionBody) TokenFeeScheduleUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenFeeScheduleUpdateTransactionBody) ConsensusSubmitMessageTransactionBody(com.hederahashgraph.api.proto.java.ConsensusSubmitMessageTransactionBody) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody) TokenAssociateTransactionBody(com.hederahashgraph.api.proto.java.TokenAssociateTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) FileUpdateTransactionBody(com.hederahashgraph.api.proto.java.FileUpdateTransactionBody) TokenGrantKycTransactionBody(com.hederahashgraph.api.proto.java.TokenGrantKycTransactionBody) TokenUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenUpdateTransactionBody) TokenCreateTransactionBody(com.hederahashgraph.api.proto.java.TokenCreateTransactionBody) TokenUnfreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenUnfreezeAccountTransactionBody) TokenWipeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenWipeAccountTransactionBody) TokenDissociateTransactionBody(com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody) TokenBurnTransactionBody(com.hederahashgraph.api.proto.java.TokenBurnTransactionBody) TokenFreezeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenFreezeAccountTransactionBody) CryptoAddLiveHashTransactionBody(com.hederahashgraph.api.proto.java.CryptoAddLiveHashTransactionBody) TokenID(com.hederahashgraph.api.proto.java.TokenID)

Example 84 with EntityId

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;
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId)

Example 85 with EntityId

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);
        });
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenDissociateTransactionBody(com.hederahashgraph.api.proto.java.TokenDissociateTransactionBody) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount)

Aggregations

EntityId (com.hedera.mirror.common.domain.entity.EntityId)134 Test (org.junit.jupiter.api.Test)64 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)43 IntegrationTest (com.hedera.mirror.importer.IntegrationTest)33 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)22 EntityType (com.hedera.mirror.common.domain.entity.EntityType)21 TokenAccount (com.hedera.mirror.common.domain.token.TokenAccount)21 Token (com.hedera.mirror.common.domain.token.Token)20 Entity (com.hedera.mirror.common.domain.entity.Entity)17 Transaction (com.hedera.mirror.common.domain.transaction.Transaction)17 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)16 Assertions (org.junit.jupiter.api.Assertions)16 Contract (com.hedera.mirror.common.domain.contract.Contract)15 ACCOUNT (com.hedera.mirror.common.domain.entity.EntityType.ACCOUNT)15 DomainUtils (com.hedera.mirror.common.util.DomainUtils)15 ByteString (com.google.protobuf.ByteString)14 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)14 AccountID (com.hederahashgraph.api.proto.java.AccountID)14 ContractID (com.hederahashgraph.api.proto.java.ContractID)14 Consumer (java.util.function.Consumer)13