use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class ContractDeleteTransactionHandler method getEntity.
/**
* First attempts to extract the contract ID from the receipt, which was populated in HAPI 0.23 for contract
* deletes. Otherwise, falls back to checking the transaction body which may contain an EVM address. In case of
* partial mirror nodes, it's possible the database does not have the mapping for that EVM address in the body,
* hence the need for prioritizing the receipt.
*
* @param recordItem to check
* @return The contract ID associated with this contract delete
*/
@Override
public EntityId getEntity(RecordItem recordItem) {
ContractID contractIdBody = recordItem.getTransactionBody().getContractDeleteInstance().getContractID();
ContractID contractIdReceipt = recordItem.getRecord().getReceipt().getContractID();
return entityIdService.lookup(contractIdReceipt, contractIdBody);
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class ContractUpdateTransactionHandler method getEntity.
/**
* First attempts to extract the contract ID from the receipt, which was populated in HAPI 0.23 for contract update.
* Otherwise, falls back to checking the transaction body which may contain an EVM address. In case of partial
* mirror nodes, it's possible the database does not have the mapping for that EVM address in the body, hence the
* need for prioritizing the receipt.
*
* @param recordItem to check
* @return The contract ID associated with this contract transaction
*/
@Override
public EntityId getEntity(RecordItem recordItem) {
ContractID contractIdBody = recordItem.getTransactionBody().getContractUpdateInstance().getContractID();
ContractID contractIdReceipt = recordItem.getRecord().getReceipt().getContractID();
return entityIdService.lookup(contractIdReceipt, contractIdBody);
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupContractsReturnsFirst.
@Test
void lookupContractsReturnsFirst() {
ContractID contractId1 = ContractID.newBuilder().setContractNum(100).build();
ContractID contractId2 = ContractID.newBuilder().setContractNum(101).build();
EntityId entityId = entityIdService.lookup(contractId1, contractId2);
assertThat(entityId).isEqualTo(EntityId.of(contractId1));
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupParsableEvmAddressShardRealmMismatch.
@Test
void lookupParsableEvmAddressShardRealmMismatch() {
ContractID contractId = ContractID.newBuilder().setShardNum(1).setRealmNum(2).setEvmAddress(DomainUtils.fromBytes(PARSABLE_EVM_ADDRESS)).build();
assertThrows(AliasNotFoundException.class, () -> entityIdService.lookup(contractId));
}
use of com.hederahashgraph.api.proto.java.ContractID in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupContracts.
@Test
void lookupContracts() {
ContractID nullContractId = null;
ContractID contractId = ContractID.newBuilder().setContractNum(100).build();
ContractID contractIdInvalid = ContractID.newBuilder().setRealmNum(1).build();
Contract contractDeleted = domainBuilder.contract().customize(e -> e.deleted(true)).persist();
EntityId entityId = entityIdService.lookup(nullContractId, ContractID.getDefaultInstance(), getProtoContractId(contractDeleted), contractIdInvalid, contractId);
assertThat(entityId).isEqualTo(EntityId.of(contractId));
}
Aggregations