use of com.hedera.mirror.importer.exception.AliasNotFoundException in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method processNonFeeTransfers.
/**
* Additionally store rows in the non_fee_transactions table if applicable. This will allow the rest-api to create
* an itemized set of transfers that reflects non-fees (explicit transfers), threshold records, node fee, and
* network+service fee (paid to treasury).
*/
private void processNonFeeTransfers(long consensusTimestamp, RecordItem recordItem) {
if (!entityProperties.getPersist().isNonFeeTransfers()) {
return;
}
var body = recordItem.getTransactionBody();
var partialDataAction = parserProperties.getPartialDataAction();
var transactionRecord = recordItem.getRecord();
for (var aa : nonFeeTransfersExtractor.extractNonFeeTransfers(body, transactionRecord)) {
var entityId = EntityId.EMPTY;
if (aa.getAmount() != 0) {
try {
entityId = entityIdService.lookup(aa.getAccountID());
} catch (AliasNotFoundException ex) {
switch(partialDataAction) {
case DEFAULT:
log.warn("Setting non-fee transfer account to default value due to partial data issue");
break;
case ERROR:
throw ex;
case SKIP:
log.warn("Skipping non-fee transfer due to partial data issue");
continue;
}
}
NonFeeTransfer nonFeeTransfer = new NonFeeTransfer();
nonFeeTransfer.setAmount(aa.getAmount());
nonFeeTransfer.setConsensusTimestamp(consensusTimestamp);
nonFeeTransfer.setEntityId(entityId);
nonFeeTransfer.setIsApproval(aa.getIsApproval());
nonFeeTransfer.setPayerAccountId(recordItem.getPayerAccountId());
entityListener.onNonFeeTransfer(nonFeeTransfer);
}
}
}
use of com.hedera.mirror.importer.exception.AliasNotFoundException in project hedera-mirror-node by hashgraph.
the class ConsensusUpdateTopicTransactionHandlerTest method updateTransactionWithAliasNotFoundAndPartialDataActionSkip.
@Test
void updateTransactionWithAliasNotFoundAndPartialDataActionSkip() {
recordParserProperties.setPartialDataAction(PartialDataAction.SKIP);
var alias = DomainUtils.fromBytes(domainBuilder.key());
var recordItem = recordItemBuilder.consensusUpdateTopic().transactionBody(b -> b.getAutoRenewAccountBuilder().setAlias(alias)).build();
var topicId = EntityId.of(recordItem.getTransactionBody().getConsensusUpdateTopic().getTopicID());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(topicId)).get();
when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", ACCOUNT));
transactionHandler.updateTransaction(transaction, recordItem);
assertConsensusTopicUpdate(timestamp, topicId, Assertions::assertNull);
}
use of com.hedera.mirror.importer.exception.AliasNotFoundException in project hedera-mirror-node by hashgraph.
the class ContractCreateTransactionHandlerTest method updateTransactionWithAliasNotFoundAndPartialDataActionSkip.
@Test
void updateTransactionWithAliasNotFoundAndPartialDataActionSkip() {
recordParserProperties.setPartialDataAction(PartialDataAction.SKIP);
var alias = DomainUtils.fromBytes(domainBuilder.key());
var recordItem = recordItemBuilder.contractCreate().transactionBody(b -> b.getAutoRenewAccountIdBuilder().setAlias(alias)).build();
var contractId = EntityId.of(recordItem.getRecord().getReceipt().getContractID());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(contractId)).get();
when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", ACCOUNT));
transactionHandler.updateTransaction(transaction, recordItem);
assertContract(contractId, timestamp, t -> assertThat(t).returns(null, Contract::getAutoRenewAccountId).returns(null, Contract::getEvmAddress).satisfies(c -> assertThat(c.getFileId().getId()).isPositive()).returns(null, Contract::getInitcode));
}
use of com.hedera.mirror.importer.exception.AliasNotFoundException in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method updateTransactionThrowsWithAliasNotFound.
@ParameterizedTest(name = "{0}")
@EnumSource(value = PartialDataAction.class, names = { "DEFAULT", "ERROR" })
void updateTransactionThrowsWithAliasNotFound(PartialDataAction partialDataAction) {
// given
recordParserProperties.setPartialDataAction(partialDataAction);
var alias = DomainUtils.fromBytes(domainBuilder.key());
var recordItem = recordItemBuilder.contractUpdate().transactionBody(b -> b.getAutoRenewAccountIdBuilder().setAlias(alias)).build();
var contractId = EntityId.of(recordItem.getRecord().getReceipt().getContractID());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(contractId)).get();
when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", ACCOUNT));
// when, then
assertThrows(AliasNotFoundException.class, () -> transactionHandler.updateTransaction(transaction, recordItem));
}
use of com.hedera.mirror.importer.exception.AliasNotFoundException in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandlerTest method updateTransactionWithAliasNotFoundAndPartialDataActionSkip.
@Test
void updateTransactionWithAliasNotFoundAndPartialDataActionSkip() {
recordParserProperties.setPartialDataAction(PartialDataAction.SKIP);
var alias = DomainUtils.fromBytes(domainBuilder.key());
var recordItem = recordItemBuilder.contractUpdate().transactionBody(b -> b.getAutoRenewAccountIdBuilder().setAlias(alias)).build();
var contractId = EntityId.of(recordItem.getRecord().getReceipt().getContractID());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(contractId)).get();
when(entityIdService.lookup(AccountID.newBuilder().setAlias(alias).build())).thenThrow(new AliasNotFoundException("alias", ACCOUNT));
transactionHandler.updateTransaction(transaction, recordItem);
assertContractUpdate(timestamp, contractId, t -> assertThat(t).returns(null, Contract::getAutoRenewAccountId).satisfies(c -> assertThat(c.getAutoRenewPeriod()).isPositive()).satisfies(c -> assertThat(c.getExpirationTimestamp()).isPositive()).satisfies(c -> assertThat(c.getKey()).isNotEmpty()).satisfies(c -> assertThat(c.getMaxAutomaticTokenAssociations()).isPositive()).satisfies(c -> assertThat(c.getMemo()).isNotEmpty()).satisfies(c -> assertThat(c.getPublicKey()).isNotEmpty()).satisfies(c -> assertThat(c.getProxyAccountId().getId()).isPositive()));
}
Aggregations