Search in sources :

Example 1 with TokenMintTransactionBody

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);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) Function(java.util.function.Function) TokenInfo(com.hederahashgraph.api.proto.java.TokenInfo) BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HapiTokenFeeScheduleUpdate.lookupInfo(com.hedera.services.bdd.spec.transactions.token.HapiTokenFeeScheduleUpdate.lookupInfo) SubType(com.hederahashgraph.api.proto.java.SubType) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) SigValueObj(com.hederahashgraph.fee.SigValueObj) TokenOpsUsage(com.hedera.services.usage.token.TokenOpsUsage) TOKEN_OPS_USAGE_UTILS(com.hedera.services.usage.token.TokenOpsUsageUtils.TOKEN_OPS_USAGE_UTILS) FeeData(com.hederahashgraph.api.proto.java.FeeData) MoreObjects(com.google.common.base.MoreObjects) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) ByteString(com.google.protobuf.ByteString) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) AdapterUtils(com.hedera.services.bdd.spec.fees.AdapterUtils) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) Collections(java.util.Collections) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody)

Example 2 with TokenMintTransactionBody

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);
        }
    }
}
Also used : EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody) Nft(com.hedera.mirror.common.domain.token.Nft)

Example 3 with TokenMintTransactionBody

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());
}
Also used : FileAppendTransactionBody(com.hederahashgraph.api.proto.java.FileAppendTransactionBody) TokenFeeScheduleUpdateTransactionBody(com.hederahashgraph.api.proto.java.TokenFeeScheduleUpdateTransactionBody) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) TokenWipeAccountTransactionBody(com.hederahashgraph.api.proto.java.TokenWipeAccountTransactionBody) TokenBurnTransactionBody(com.hederahashgraph.api.proto.java.TokenBurnTransactionBody) TokenType(com.hederahashgraph.api.proto.java.TokenType) TokenMintTransactionBody(com.hederahashgraph.api.proto.java.TokenMintTransactionBody) Test(org.junit.jupiter.api.Test)

Aggregations

TokenMintTransactionBody (com.hederahashgraph.api.proto.java.TokenMintTransactionBody)3 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)2 MoreObjects (com.google.common.base.MoreObjects)1 ByteString (com.google.protobuf.ByteString)1 EntityId (com.hedera.mirror.common.domain.entity.EntityId)1 Nft (com.hedera.mirror.common.domain.token.Nft)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 AdapterUtils (com.hedera.services.bdd.spec.fees.AdapterUtils)1 HapiTxnOp (com.hedera.services.bdd.spec.transactions.HapiTxnOp)1 TxnUtils (com.hedera.services.bdd.spec.transactions.TxnUtils)1 TxnUtils.suFrom (com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom)1 HapiTokenFeeScheduleUpdate.lookupInfo (com.hedera.services.bdd.spec.transactions.token.HapiTokenFeeScheduleUpdate.lookupInfo)1 BaseTransactionMeta (com.hedera.services.usage.BaseTransactionMeta)1 UsageAccumulator (com.hedera.services.usage.state.UsageAccumulator)1 TokenOpsUsage (com.hedera.services.usage.token.TokenOpsUsage)1 TOKEN_OPS_USAGE_UTILS (com.hedera.services.usage.token.TokenOpsUsageUtils.TOKEN_OPS_USAGE_UTILS)1 FeeData (com.hederahashgraph.api.proto.java.FeeData)1 FileAppendTransactionBody (com.hederahashgraph.api.proto.java.FileAppendTransactionBody)1 HederaFunctionality (com.hederahashgraph.api.proto.java.HederaFunctionality)1 Key (com.hederahashgraph.api.proto.java.Key)1