Search in sources :

Example 1 with FUNGIBLE_COMMON

use of com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON in project hedera-services by hashgraph.

the class ContractKeysHTSSuite method callForMintWithDelegateContractKey.

private HapiApiSpec callForMintWithDelegateContractKey() {
    final var theAccount = "anybody";
    final var mintContractByteCode = "mintContractByteCode";
    final var amount = 10L;
    final var fungibleToken = "fungibleToken";
    final var theContract = "mintContract";
    final var firstMintTxn = "firstMintTxn";
    final AtomicLong fungibleNum = new AtomicLong();
    return defaultHapiSpec("callForMintWithDelegateContractKey").given(newKeyNamed(MULTI_KEY), cryptoCreate(theAccount).balance(10 * ONE_HUNDRED_HBARS), cryptoCreate(TOKEN_TREASURY), fileCreate(mintContractByteCode).payingWith(theAccount), updateLargeFile(theAccount, mintContractByteCode, extractByteCode(ContractResources.ORDINARY_CALLS_CONTRACT)), tokenCreate(fungibleToken).tokenType(FUNGIBLE_COMMON).initialSupply(0).treasury(TOKEN_TREASURY).adminKey(MULTI_KEY).supplyKey(MULTI_KEY).exposingCreatedIdTo(idLit -> fungibleNum.set(asDotDelimitedLongArray(idLit)[2]))).when(sourcing(() -> contractCreate(theContract).bytecode(mintContractByteCode).payingWith(theAccount).gas(GAS_TO_OFFER))).then(withOpContext((spec, opLog) -> allRunFor(spec, newKeyNamed("delegateContractKey").shape(DELEGATE_CONTRACT_KEY_SHAPE.signedWith(sigs(ON, theContract))), tokenUpdate(fungibleToken).supplyKey("delegateContractKey"), contractCall(theContract, MINT_TOKEN_ORDINARY_CALL, asAddress(spec.registry().getTokenID(fungibleToken)), amount, new byte[] {}).via(firstMintTxn).payingWith(theAccount))), childRecordsCheck(firstMintTxn, SUCCESS, recordWith().status(SUCCESS).tokenTransfers(changingFungibleBalances().including(fungibleToken, TOKEN_TREASURY, 10)).newTotalSupply(10)), getTokenInfo(fungibleToken).hasTotalSupply(amount), getAccountBalance(TOKEN_TREASURY).hasTokenBalance(fungibleToken, amount));
}
Also used : SINGLE_TOKEN_DISSOCIATE(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SINGLE_TOKEN_DISSOCIATE) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES) ON(com.hedera.services.bdd.spec.keys.SigControl.ON) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) BURN_TOKEN_ORDINARY_CALL(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BURN_TOKEN_ORDINARY_CALL) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) ACCOUNT_IS_TREASURY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_IS_TREASURY) DELEGATE_BURN_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_BURN_CALL_ABI) ExpectedTokenRel.relationshipWith(com.hedera.services.bdd.spec.queries.crypto.ExpectedTokenRel.relationshipWith) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) STATIC_ASSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_ASSOCIATE_CALL_ABI) Frozen(com.hederahashgraph.api.proto.java.TokenFreezeStatus.Frozen) SomeFungibleTransfers.changingFungibleBalances(com.hedera.services.bdd.spec.assertions.SomeFungibleTransfers.changingFungibleBalances) DELEGATE_ASSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_ASSOCIATE_CALL_ABI) ACCOUNT_STILL_OWNS_NFTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_STILL_OWNS_NFTS) STATIC_DISSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_DISSOCIATE_CALL_ABI) STATIC_MINT_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_MINT_CALL_ABI) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) TRANSFER_NFT_ORDINARY_CALL(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TRANSFER_NFT_ORDINARY_CALL) Utils.extractByteCode(com.hedera.services.bdd.suites.contract.Utils.extractByteCode) NonFungibleTransfers(com.hedera.services.bdd.spec.assertions.NonFungibleTransfers) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TxnVerbs.tokenUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUpdate) NotNull(org.jetbrains.annotations.NotNull) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) STATIC_TRANSFER_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_TRANSFER_CALL_ABI) KeyShape.sigs(com.hedera.services.bdd.spec.keys.KeyShape.sigs) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) MiscEETUtils.metadata(com.hedera.services.bdd.suites.utils.MiscEETUtils.metadata) ByteString.copyFromUtf8(com.google.protobuf.ByteString.copyFromUtf8) DELEGATE_MINT_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_MINT_CALL_ABI) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) Revoked(com.hederahashgraph.api.proto.java.TokenKycStatus.Revoked) HapiPropertySource.asToken(com.hedera.services.bdd.spec.HapiPropertySource.asToken) SINGLE_TOKEN_ASSOCIATE(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SINGLE_TOKEN_ASSOCIATE) AtomicReference(java.util.concurrent.atomic.AtomicReference) DELEGATE_CONTRACT(com.hedera.services.bdd.spec.keys.KeyShape.DELEGATE_CONTRACT) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) ArrayList(java.util.ArrayList) UtilVerbs.emptyChildRecordsCheck(com.hedera.services.bdd.spec.utilops.UtilVerbs.emptyChildRecordsCheck) TxnVerbs.cryptoUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoUpdate) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) UtilVerbs.childRecordsCheck(com.hedera.services.bdd.spec.utilops.UtilVerbs.childRecordsCheck) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) HapiPropertySource.asDotDelimitedLongArray(com.hedera.services.bdd.spec.HapiPropertySource.asDotDelimitedLongArray) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) AccountID(com.hederahashgraph.api.proto.java.AccountID) MINT_TOKEN_ORDINARY_CALL(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MINT_TOKEN_ORDINARY_CALL) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) ACCOUNT_FROZEN_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_FROZEN_FOR_TOKEN) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) DELEGATE_DISSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_DISSOCIATE_CALL_ABI) UtilVerbs.updateLargeFile(com.hedera.services.bdd.spec.utilops.UtilVerbs.updateLargeFile) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) VANILLA_TOKEN(com.hedera.services.bdd.suites.token.TokenAssociationSpecs.VANILLA_TOKEN) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) BURN_TOKEN_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BURN_TOKEN_ABI) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) TokenType(com.hederahashgraph.api.proto.java.TokenType) AtomicLong(java.util.concurrent.atomic.AtomicLong) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) TokenID(com.hederahashgraph.api.proto.java.TokenID) STATIC_BURN_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_BURN_CALL_ABI) Utils.asAddress(com.hedera.services.bdd.suites.contract.Utils.asAddress) CONTRACT_REVERT_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED) NON_FUNGIBLE_UNIQUE(com.hederahashgraph.api.proto.java.TokenType.NON_FUNGIBLE_UNIQUE) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) FUNGIBLE_COMMON(com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON) LogManager(org.apache.logging.log4j.LogManager) DELEGATE_TRANSFER_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_TRANSFER_CALL_ABI) TokenMovement.movingUnique(com.hedera.services.bdd.spec.transactions.token.TokenMovement.movingUnique) TokenSupplyType(com.hederahashgraph.api.proto.java.TokenSupplyType) TxnVerbs.tokenUnfreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUnfreeze) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Example 2 with FUNGIBLE_COMMON

use of com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerContractTest method tokenSupplyTransaction.

private Transaction tokenSupplyTransaction(TokenType tokenType, boolean mint) {
    var serialNumbers = List.of(1L, 2L, 3L);
    Transaction transaction = null;
    if (mint) {
        transaction = buildTransaction(builder -> {
            builder.getTokenMintBuilder().setToken(TOKEN_ID);
            if (tokenType == FUNGIBLE_COMMON) {
                builder.getTokenMintBuilder().setAmount(10);
            } else {
                builder.getTokenMintBuilder().addAllMetadata(Collections.nCopies(serialNumbers.size(), ByteString.copyFromUtf8(METADATA)));
            }
        });
    } else {
        transaction = buildTransaction(builder -> {
            builder.getTokenBurnBuilder().setToken(TOKEN_ID);
            if (tokenType == FUNGIBLE_COMMON) {
                builder.getTokenBurnBuilder().setAmount(10);
            } else {
                builder.getTokenBurnBuilder().addAllSerialNumbers(serialNumbers);
            }
        });
    }
    return transaction;
}
Also used : DomainUtils.toBytes(com.hedera.mirror.common.util.DomainUtils.toBytes) BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) EntityId(com.hedera.mirror.common.domain.entity.EntityId) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) StringValue(com.google.protobuf.StringValue) ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) Duration(com.hederahashgraph.api.proto.java.Duration) EntityType(com.hedera.mirror.common.domain.entity.EntityType) ByteBuffer(java.nio.ByteBuffer) ContractID(com.hederahashgraph.api.proto.java.ContractID) Map(java.util.Map) RecordFile(com.hedera.mirror.common.domain.transaction.RecordFile) Version(org.springframework.data.util.Version) ContractCallTransactionBody(com.hederahashgraph.api.proto.java.ContractCallTransactionBody) TestUtils(com.hedera.mirror.importer.TestUtils) Utility(com.hedera.mirror.importer.util.Utility) RecordItemBuilder(com.hedera.mirror.importer.parser.domain.RecordItemBuilder) ContractResult(com.hedera.mirror.common.domain.contract.ContractResult) ContractStateChange(com.hedera.mirror.common.domain.contract.ContractStateChange) Range(com.google.common.collect.Range) Resource(javax.annotation.Resource) ContractLoginfo(com.hederahashgraph.api.proto.java.ContractLoginfo) Collectors(java.util.stream.Collectors) TransactionReceipt(com.hederahashgraph.api.proto.java.TransactionReceipt) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test) BytesValue(com.google.protobuf.BytesValue) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) List(java.util.List) ContractLogRepository(com.hedera.mirror.importer.repository.ContractLogRepository) STAKEDID_NOT_SET(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody.StakedIdCase.STAKEDID_NOT_SET) ObjectAssert(org.assertj.core.api.ObjectAssert) Optional(java.util.Optional) AccountIdConverter(com.hedera.mirror.common.converter.AccountIdConverter) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) CsvSource(org.junit.jupiter.params.provider.CsvSource) Contract(com.hedera.mirror.common.domain.contract.Contract) HashMap(java.util.HashMap) EnumSource(org.junit.jupiter.params.provider.EnumSource) Value(lombok.Value) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) ContractStateChangeRepository(com.hedera.mirror.importer.repository.ContractStateChangeRepository) AccountID(com.hederahashgraph.api.proto.java.AccountID) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) Int32Value(com.google.protobuf.Int32Value) DomainUtils(com.hedera.mirror.common.util.DomainUtils) FileID(com.hederahashgraph.api.proto.java.FileID) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) ContractLog(com.hedera.mirror.common.domain.contract.ContractLog) Consumer(java.util.function.Consumer) TokenType(com.hederahashgraph.api.proto.java.TokenType) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TokenID(com.hederahashgraph.api.proto.java.TokenID) ContractCreateTransactionBody(com.hederahashgraph.api.proto.java.ContractCreateTransactionBody) Assertions(org.junit.jupiter.api.Assertions) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) FUNGIBLE_COMMON(com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON) Collections(java.util.Collections) Transaction(com.hederahashgraph.api.proto.java.Transaction)

Example 3 with FUNGIBLE_COMMON

use of com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON in project hedera-mirror-node by hashgraph.

the class EntityRecordItemListenerTokenTest method tokenDissociateDeletedFungibleToken.

@Test
void tokenDissociateDeletedFungibleToken() {
    // given
    createAndAssociateToken(TOKEN_ID, FUNGIBLE_COMMON, SYMBOL, CREATE_TIMESTAMP, ASSOCIATE_TIMESTAMP, PAYER2, false, false, false, INITIAL_SUPPLY);
    long tokenDeleteTimestamp = 15L;
    Transaction deleteTransaction = tokenDeleteTransaction(TOKEN_ID);
    insertAndParseTransaction(tokenDeleteTimestamp, deleteTransaction);
    // when
    Transaction dissociateTransaction = tokenDissociate(List.of(TOKEN_ID), PAYER2);
    long dissociateTimeStamp = 20L;
    TokenTransferList dissociateTransfer = tokenTransfer(TOKEN_ID, PAYER2, -10);
    insertAndParseTransaction(dissociateTimeStamp, dissociateTransaction, builder -> builder.addTokenTransferLists(dissociateTransfer));
    // then
    assertTokenInRepository(TOKEN_ID, true, CREATE_TIMESTAMP, dissociateTimeStamp, SYMBOL, INITIAL_SUPPLY - 10);
    var expected = domainBuilder.tokenTransfer().customize(t -> t.amount(-10).id(new TokenTransfer.Id(dissociateTimeStamp, EntityId.of(TOKEN_ID), EntityId.of(PAYER2))).isApproval(false).payerAccountId(EntityId.of(PAYER)).tokenDissociate(false)).get();
    assertThat(tokenTransferRepository.findById(expected.getId())).get().isEqualTo(expected);
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Arrays(java.util.Arrays) EntityId(com.hedera.mirror.common.domain.entity.EntityId) FixedFee(com.hederahashgraph.api.proto.java.FixedFee) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) StringValue(com.google.protobuf.StringValue) Duration(com.hederahashgraph.api.proto.java.Duration) NftTransfer(com.hederahashgraph.api.proto.java.NftTransfer) StringUtils(org.apache.commons.lang3.StringUtils) EntityType(com.hedera.mirror.common.domain.entity.EntityType) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Token(com.hedera.mirror.common.domain.token.Token) TokenId(com.hedera.mirror.common.domain.token.TokenId) TestUtils(com.hedera.mirror.importer.TestUtils) MethodSource(org.junit.jupiter.params.provider.MethodSource) ContractResult(com.hedera.mirror.common.domain.contract.ContractResult) TokenRepository(com.hedera.mirror.importer.repository.TokenRepository) TokenFreezeStatusEnum(com.hedera.mirror.common.domain.token.TokenFreezeStatusEnum) Assertions.from(org.assertj.core.api.Assertions.from) EntityIdEndec(com.hedera.mirror.common.domain.entity.EntityIdEndec) Resource(javax.annotation.Resource) TokenPauseStatusEnum(com.hedera.mirror.common.domain.token.TokenPauseStatusEnum) Arguments(org.junit.jupiter.params.provider.Arguments) Collectors(java.util.stream.Collectors) ByteString(com.google.protobuf.ByteString) Test(org.junit.jupiter.api.Test) CustomFee(com.hedera.mirror.common.domain.transaction.CustomFee) AccountAmount(com.hederahashgraph.api.proto.java.AccountAmount) List(java.util.List) Nft(com.hedera.mirror.common.domain.token.Nft) Stream(java.util.stream.Stream) Builder(lombok.Builder) AssessedCustomFeeWrapper(com.hedera.mirror.importer.domain.AssessedCustomFeeWrapper) Lists(org.assertj.core.util.Lists) TokenAccountRepository(com.hedera.mirror.importer.repository.TokenAccountRepository) ObjectAssert(org.assertj.core.api.ObjectAssert) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId) Optional(java.util.Optional) TokenAccount(com.hedera.mirror.common.domain.token.TokenAccount) TokenAssociation(com.hederahashgraph.api.proto.java.TokenAssociation) RecordItem(com.hedera.mirror.common.domain.transaction.RecordItem) Transaction(com.hederahashgraph.api.proto.java.Transaction) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) NftId(com.hedera.mirror.common.domain.token.NftId) RoyaltyFee(com.hederahashgraph.api.proto.java.RoyaltyFee) EnumSource(org.junit.jupiter.params.provider.EnumSource) CustomFeeWrapper(com.hedera.mirror.importer.domain.CustomFeeWrapper) AtomicReference(java.util.concurrent.atomic.AtomicReference) ArrayList(java.util.ArrayList) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) NftAllowance(com.hederahashgraph.api.proto.java.NftAllowance) FractionalFee(com.hederahashgraph.api.proto.java.FractionalFee) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) NftTransferRepository(com.hedera.mirror.importer.repository.NftTransferRepository) AccountID(com.hederahashgraph.api.proto.java.AccountID) AssessedCustomFee(com.hedera.mirror.common.domain.transaction.AssessedCustomFee) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) NftRepository(com.hedera.mirror.importer.repository.NftRepository) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) TokenAccountId(com.hedera.mirror.common.domain.token.TokenAccountId) TokenTransferRepository(com.hedera.mirror.importer.repository.TokenTransferRepository) Entity(com.hedera.mirror.common.domain.entity.Entity) Consumer(java.util.function.Consumer) TokenType(com.hederahashgraph.api.proto.java.TokenType) Fraction(com.hederahashgraph.api.proto.java.Fraction) Key(com.hederahashgraph.api.proto.java.Key) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TokenID(com.hederahashgraph.api.proto.java.TokenID) TokenKycStatusEnum(com.hedera.mirror.common.domain.token.TokenKycStatusEnum) Assertions(org.junit.jupiter.api.Assertions) NON_FUNGIBLE_UNIQUE(com.hederahashgraph.api.proto.java.TokenType.NON_FUNGIBLE_UNIQUE) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) FUNGIBLE_COMMON(com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON) Comparator(java.util.Comparator) Collections(java.util.Collections) TokenSupplyType(com.hederahashgraph.api.proto.java.TokenSupplyType) TokenTransfer(com.hedera.mirror.common.domain.token.TokenTransfer) TokenTransferList(com.hederahashgraph.api.proto.java.TokenTransferList) Transaction(com.hederahashgraph.api.proto.java.Transaction) EntityId(com.hedera.mirror.common.domain.entity.EntityId) TokenId(com.hedera.mirror.common.domain.token.TokenId) NftTransferId(com.hedera.mirror.common.domain.token.NftTransferId) NftId(com.hedera.mirror.common.domain.token.NftId) TokenAccountId(com.hedera.mirror.common.domain.token.TokenAccountId) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with FUNGIBLE_COMMON

use of com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON in project hedera-services by hashgraph.

the class ContractKeysHTSSuite method callForMintWithContractKey.

private HapiApiSpec callForMintWithContractKey() {
    final var theAccount = "anybody";
    final var mintContractByteCode = "mintContractByteCode";
    final var amount = 10L;
    final var fungibleToken = "fungibleToken";
    final var theContract = "mintContract";
    final var firstMintTxn = "firstMintTxn";
    final AtomicLong fungibleNum = new AtomicLong();
    return defaultHapiSpec("callForMintWithContractKey").given(newKeyNamed(MULTI_KEY), cryptoCreate(theAccount).balance(10 * ONE_HUNDRED_HBARS), cryptoCreate(TOKEN_TREASURY), fileCreate(mintContractByteCode).payingWith(theAccount), updateLargeFile(theAccount, mintContractByteCode, extractByteCode(ContractResources.ORDINARY_CALLS_CONTRACT)), tokenCreate(fungibleToken).tokenType(FUNGIBLE_COMMON).initialSupply(0).treasury(TOKEN_TREASURY).adminKey(MULTI_KEY).supplyKey(MULTI_KEY).exposingCreatedIdTo(idLit -> fungibleNum.set(asDotDelimitedLongArray(idLit)[2]))).when(sourcing(() -> contractCreate(theContract).bytecode(mintContractByteCode).payingWith(theAccount).gas(GAS_TO_OFFER))).then(withOpContext((spec, opLog) -> allRunFor(spec, newKeyNamed("contractKey").shape(CONTRACT_KEY_SHAPE.signedWith(sigs(ON, theContract))), tokenUpdate(fungibleToken).supplyKey("contractKey"), contractCall(theContract, MINT_TOKEN_ORDINARY_CALL, asAddress(spec.registry().getTokenID(fungibleToken)), amount, new byte[] {}).via(firstMintTxn).payingWith(theAccount))), childRecordsCheck(firstMintTxn, SUCCESS, recordWith().status(SUCCESS).tokenTransfers(changingFungibleBalances().including(fungibleToken, TOKEN_TREASURY, 10)).newTotalSupply(10)), getTokenInfo(fungibleToken).hasTotalSupply(amount), getAccountBalance(TOKEN_TREASURY).hasTokenBalance(fungibleToken, amount));
}
Also used : SINGLE_TOKEN_DISSOCIATE(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SINGLE_TOKEN_DISSOCIATE) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TRANSACTION_REQUIRES_ZERO_TOKEN_BALANCES) ON(com.hedera.services.bdd.spec.keys.SigControl.ON) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) BURN_TOKEN_ORDINARY_CALL(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BURN_TOKEN_ORDINARY_CALL) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) ACCOUNT_IS_TREASURY(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_IS_TREASURY) DELEGATE_BURN_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_BURN_CALL_ABI) ExpectedTokenRel.relationshipWith(com.hedera.services.bdd.spec.queries.crypto.ExpectedTokenRel.relationshipWith) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) STATIC_ASSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_ASSOCIATE_CALL_ABI) Frozen(com.hederahashgraph.api.proto.java.TokenFreezeStatus.Frozen) SomeFungibleTransfers.changingFungibleBalances(com.hedera.services.bdd.spec.assertions.SomeFungibleTransfers.changingFungibleBalances) DELEGATE_ASSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_ASSOCIATE_CALL_ABI) ACCOUNT_STILL_OWNS_NFTS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_STILL_OWNS_NFTS) STATIC_DISSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_DISSOCIATE_CALL_ABI) STATIC_MINT_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_MINT_CALL_ABI) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_ALREADY_ASSOCIATED_TO_ACCOUNT) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TOKEN_NOT_ASSOCIATED_TO_ACCOUNT(com.hederahashgraph.api.proto.java.ResponseCodeEnum.TOKEN_NOT_ASSOCIATED_TO_ACCOUNT) TRANSFER_NFT_ORDINARY_CALL(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TRANSFER_NFT_ORDINARY_CALL) Utils.extractByteCode(com.hedera.services.bdd.suites.contract.Utils.extractByteCode) NonFungibleTransfers(com.hedera.services.bdd.spec.assertions.NonFungibleTransfers) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TxnVerbs.tokenUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUpdate) NotNull(org.jetbrains.annotations.NotNull) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) STATIC_TRANSFER_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_TRANSFER_CALL_ABI) KeyShape.sigs(com.hedera.services.bdd.spec.keys.KeyShape.sigs) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) MiscEETUtils.metadata(com.hedera.services.bdd.suites.utils.MiscEETUtils.metadata) ByteString.copyFromUtf8(com.google.protobuf.ByteString.copyFromUtf8) DELEGATE_MINT_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_MINT_CALL_ABI) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) Revoked(com.hederahashgraph.api.proto.java.TokenKycStatus.Revoked) HapiPropertySource.asToken(com.hedera.services.bdd.spec.HapiPropertySource.asToken) SINGLE_TOKEN_ASSOCIATE(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SINGLE_TOKEN_ASSOCIATE) AtomicReference(java.util.concurrent.atomic.AtomicReference) DELEGATE_CONTRACT(com.hedera.services.bdd.spec.keys.KeyShape.DELEGATE_CONTRACT) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) ArrayList(java.util.ArrayList) UtilVerbs.emptyChildRecordsCheck(com.hedera.services.bdd.spec.utilops.UtilVerbs.emptyChildRecordsCheck) TxnVerbs.cryptoUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoUpdate) TokenMovement.moving(com.hedera.services.bdd.spec.transactions.token.TokenMovement.moving) UtilVerbs.childRecordsCheck(com.hedera.services.bdd.spec.utilops.UtilVerbs.childRecordsCheck) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) HapiPropertySource.asDotDelimitedLongArray(com.hedera.services.bdd.spec.HapiPropertySource.asDotDelimitedLongArray) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) AccountID(com.hederahashgraph.api.proto.java.AccountID) MINT_TOKEN_ORDINARY_CALL(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MINT_TOKEN_ORDINARY_CALL) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) ACCOUNT_FROZEN_FOR_TOKEN(com.hederahashgraph.api.proto.java.ResponseCodeEnum.ACCOUNT_FROZEN_FOR_TOKEN) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) DELEGATE_DISSOCIATE_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_DISSOCIATE_CALL_ABI) UtilVerbs.updateLargeFile(com.hedera.services.bdd.spec.utilops.UtilVerbs.updateLargeFile) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) VANILLA_TOKEN(com.hedera.services.bdd.suites.token.TokenAssociationSpecs.VANILLA_TOKEN) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) BURN_TOKEN_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BURN_TOKEN_ABI) SIMPLE(com.hedera.services.bdd.spec.keys.KeyShape.SIMPLE) TokenType(com.hederahashgraph.api.proto.java.TokenType) AtomicLong(java.util.concurrent.atomic.AtomicLong) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) TokenID(com.hederahashgraph.api.proto.java.TokenID) STATIC_BURN_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.STATIC_BURN_CALL_ABI) Utils.asAddress(com.hedera.services.bdd.suites.contract.Utils.asAddress) CONTRACT_REVERT_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED) NON_FUNGIBLE_UNIQUE(com.hederahashgraph.api.proto.java.TokenType.NON_FUNGIBLE_UNIQUE) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) FUNGIBLE_COMMON(com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON) LogManager(org.apache.logging.log4j.LogManager) DELEGATE_TRANSFER_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DELEGATE_TRANSFER_CALL_ABI) TokenMovement.movingUnique(com.hedera.services.bdd.spec.transactions.token.TokenMovement.movingUnique) TokenSupplyType(com.hederahashgraph.api.proto.java.TokenSupplyType) TxnVerbs.tokenUnfreeze(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUnfreeze) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Aggregations

AccountID (com.hederahashgraph.api.proto.java.AccountID)3 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)3 TokenID (com.hederahashgraph.api.proto.java.TokenID)3 TokenType (com.hederahashgraph.api.proto.java.TokenType)3 FUNGIBLE_COMMON (com.hederahashgraph.api.proto.java.TokenType.FUNGIBLE_COMMON)3 List (java.util.List)3 ByteString (com.google.protobuf.ByteString)2 ByteString.copyFromUtf8 (com.google.protobuf.ByteString.copyFromUtf8)2 StringValue (com.google.protobuf.StringValue)2 ContractResult (com.hedera.mirror.common.domain.contract.ContractResult)2 EntityId (com.hedera.mirror.common.domain.entity.EntityId)2 EntityType (com.hedera.mirror.common.domain.entity.EntityType)2 RecordItem (com.hedera.mirror.common.domain.transaction.RecordItem)2 TestUtils (com.hedera.mirror.importer.TestUtils)2 AccountAmount (com.hederahashgraph.api.proto.java.AccountAmount)2 ContractFunctionResult (com.hederahashgraph.api.proto.java.ContractFunctionResult)2 Duration (com.hederahashgraph.api.proto.java.Duration)2 Timestamp (com.hederahashgraph.api.proto.java.Timestamp)2 TokenSupplyType (com.hederahashgraph.api.proto.java.TokenSupplyType)2 NON_FUNGIBLE_UNIQUE (com.hederahashgraph.api.proto.java.TokenType.NON_FUNGIBLE_UNIQUE)2