use of com.hederahashgraph.api.proto.java.TokenID in project hedera-mirror-node by hashgraph.
the class TokenUpdateTransactionHandlerTest method updateTransactionSuccessful.
@Test
void updateTransactionSuccessful() {
RecordItem recordItem = recordItemBuilder.tokenUpdate().build();
var tokenId = EntityId.of(recordItem.getTransactionBody().getTokenUpdate().getToken());
var timestamp = recordItem.getConsensusTimestamp();
var transaction = domainBuilder.transaction().customize(t -> t.consensusTimestamp(timestamp).entityId(tokenId)).get();
when(entityIdService.lookup(any(AccountID.class))).thenReturn(EntityIdEndec.decode(10, EntityType.ACCOUNT));
transactionHandler.updateTransaction(transaction, recordItem);
assertTokenUpdate(timestamp, tokenId, id -> assertEquals(10L, id));
}
use of com.hederahashgraph.api.proto.java.TokenID 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.hederahashgraph.api.proto.java.TokenID in project hedera-mirror-node by hashgraph.
the class AccountBalanceLineParserV2 method parseTokenBalanceList.
private List<TokenBalance> parseTokenBalanceList(String tokenBalancesProtoString, long consensusTimestamp, EntityId accountId) throws InvalidProtocolBufferException {
List<com.hederahashgraph.api.proto.java.TokenBalance> tokenBalanceProtoList = TokenBalances.parseFrom(Base64.decodeBase64(tokenBalancesProtoString)).getTokenBalancesList();
List<TokenBalance> tokenBalances = new ArrayList<>();
for (com.hederahashgraph.api.proto.java.TokenBalance tokenBalanceProto : tokenBalanceProtoList) {
TokenID tokenId = tokenBalanceProto.getTokenId();
TokenBalance tokenBalance = new TokenBalance(tokenBalanceProto.getBalance(), new TokenBalance.Id(consensusTimestamp, accountId, EntityId.of(tokenId)));
tokenBalances.add(tokenBalance);
}
return tokenBalances;
}
use of com.hederahashgraph.api.proto.java.TokenID in project hedera-services by hashgraph.
the class SignedStateBalancesExporter method addTokenBalances.
private void addTokenBalances(AccountID id, MerkleAccount account, SingleAccountBalances.Builder sabBuilder, MerkleMap<EntityNum, MerkleToken> tokens, MerkleMap<EntityNumPair, MerkleTokenRelStatus> tokenAssociations) {
var accountTokens = account.tokens();
for (TokenID tokenId : accountTokens.asTokenIds()) {
var token = tokens.get(fromTokenId(tokenId));
if (token != null) {
var relationship = tokenAssociations.get(fromAccountTokenRel(id, tokenId));
sabBuilder.addTokenUnitBalances(tb(tokenId, relationship.getBalance()));
}
}
}
use of com.hederahashgraph.api.proto.java.TokenID in project hedera-services by hashgraph.
the class NftIdTest method gettersWork.
@Test
void gettersWork() {
// given:
final var subject = new NftId(shard, realm, num, serialNo);
TokenID expectedTokenId = TokenID.newBuilder().setShardNum(shard).setRealmNum(realm).setTokenNum(num).build();
assertEquals(shard, subject.shard());
assertEquals(realm, subject.realm());
assertEquals(num, subject.num());
assertEquals(serialNo, subject.serialNo());
assertEquals(expectedTokenId, subject.tokenId());
}
Aggregations