use of com.hederahashgraph.api.proto.java.TokenMintTransactionBody in project hedera-services by hashgraph.
the class HapiTokenMint method opBodyDef.
@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
var tId = TxnUtils.asTokenId(token, spec);
TokenMintTransactionBody opBody = spec.txns().<TokenMintTransactionBody, TokenMintTransactionBody.Builder>body(TokenMintTransactionBody.class, b -> {
b.setToken(tId);
b.setAmount(amount);
b.addAllMetadata(metadata);
});
return b -> b.setTokenMint(opBody);
}
use of com.hederahashgraph.api.proto.java.TokenMintTransactionBody in project hedera-mirror-node by hashgraph.
the class EntityRecordItemListener method insertTokenMint.
private void insertTokenMint(RecordItem recordItem) {
if (entityProperties.getPersist().isTokens()) {
TokenMintTransactionBody tokenMintTransactionBody = recordItem.getTransactionBody().getTokenMint();
long consensusTimestamp = recordItem.getConsensusTimestamp();
EntityId tokenId = EntityId.of(tokenMintTransactionBody.getToken());
updateTokenSupply(tokenId, recordItem.getRecord().getReceipt().getNewTotalSupply(), consensusTimestamp);
List<Long> serialNumbers = recordItem.getRecord().getReceipt().getSerialNumbersList();
for (int i = 0; i < serialNumbers.size(); i++) {
Nft nft = new Nft(serialNumbers.get(i), tokenId);
nft.setCreatedTimestamp(consensusTimestamp);
nft.setDeleted(false);
nft.setMetadata(DomainUtils.toBytes(tokenMintTransactionBody.getMetadata(i)));
nft.setModifiedTimestamp(consensusTimestamp);
entityListener.onNft(nft);
}
}
}
use of com.hederahashgraph.api.proto.java.TokenMintTransactionBody in project hedera-services by hashgraph.
the class OpUsageCtxHelperTest method getMetaForTokenMintWorks.
@Test
void getMetaForTokenMintWorks() {
TokenMintTransactionBody mintTxnBody = getUniqueTokenMintOp();
TransactionBody txn = getTxnBody(mintTxnBody);
given(accessor.getTxn()).willReturn(txn);
given(accessor.getSubType()).willReturn(TOKEN_NON_FUNGIBLE_UNIQUE);
Optional<TokenType> tokenType = Optional.of(TokenType.NON_FUNGIBLE_UNIQUE);
given(workingView.tokenWith(target)).willReturn(Optional.of(extant));
final var tokenMintMeta = subject.metaForTokenMint(accessor);
// then:
assertEquals(34, tokenMintMeta.getBpt());
assertEquals(TOKEN_NON_FUNGIBLE_UNIQUE, tokenMintMeta.getSubType());
assertEquals(12345670, tokenMintMeta.getRbs());
assertEquals(80, tokenMintMeta.getTransferRecordDb());
}
Aggregations