use of com.hedera.mirror.common.domain.entity.CryptoAllowance in project hedera-mirror-node by hashgraph.
the class AbstractAllowanceTransactionHandler method updateTransaction.
@Override
public void updateTransaction(Transaction transaction, RecordItem recordItem) {
long consensusTimestamp = transaction.getConsensusTimestamp();
var payerAccountId = recordItem.getPayerAccountId();
for (var cryptoApproval : getCryptoAllowances(recordItem)) {
CryptoAllowance cryptoAllowance = new CryptoAllowance();
cryptoAllowance.setAmount(cryptoApproval.getAmount());
cryptoAllowance.setOwner(EntityId.of(cryptoApproval.getOwner()).getId());
cryptoAllowance.setPayerAccountId(payerAccountId);
cryptoAllowance.setSpender(EntityId.of(cryptoApproval.getSpender()).getId());
cryptoAllowance.setTimestampLower(consensusTimestamp);
entityListener.onCryptoAllowance(cryptoAllowance);
}
for (var nftApproval : getNftAllowances(recordItem)) {
var approvedForAll = nftApproval.hasApprovedForAll() && nftApproval.getApprovedForAll().getValue();
NftAllowance nftAllowance = new NftAllowance();
nftAllowance.setApprovedForAll(approvedForAll);
nftAllowance.setOwner(EntityId.of(nftApproval.getOwner()).getId());
nftAllowance.setPayerAccountId(payerAccountId);
nftAllowance.setSerialNumbers(nftApproval.getSerialNumbersList());
nftAllowance.setSpender(EntityId.of(nftApproval.getSpender()).getId());
nftAllowance.setTokenId(EntityId.of(nftApproval.getTokenId()).getId());
nftAllowance.setTimestampLower(consensusTimestamp);
entityListener.onNftAllowance(nftAllowance);
}
for (var tokenApproval : getTokenAllowances(recordItem)) {
TokenAllowance tokenAllowance = new TokenAllowance();
tokenAllowance.setAmount(tokenApproval.getAmount());
tokenAllowance.setOwner(EntityId.of(tokenApproval.getOwner()).getId());
tokenAllowance.setPayerAccountId(payerAccountId);
tokenAllowance.setSpender(EntityId.of(tokenApproval.getSpender()).getId());
tokenAllowance.setTokenId(EntityId.of(tokenApproval.getTokenId()).getId());
tokenAllowance.setTimestampLower(consensusTimestamp);
entityListener.onTokenAllowance(tokenAllowance);
}
}
use of com.hedera.mirror.common.domain.entity.CryptoAllowance in project hedera-mirror-node by hashgraph.
the class BatchUpserterTest method cryptoAllowance.
@Test
void cryptoAllowance() {
CryptoAllowance cryptoAllowance1 = domainBuilder.cryptoAllowance().get();
CryptoAllowance cryptoAllowance2 = domainBuilder.cryptoAllowance().get();
CryptoAllowance cryptoAllowance3 = domainBuilder.cryptoAllowance().get();
var cryptoAllowances = List.of(cryptoAllowance1, cryptoAllowance2, cryptoAllowance3);
persist(batchPersister, cryptoAllowances);
assertThat(cryptoAllowanceRepository.findAll()).containsExactlyInAnyOrderElementsOf(cryptoAllowances);
}
Aggregations