Search in sources :

Example 6 with TokenType

use of com.hederahashgraph.api.proto.java.TokenType 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 7 with TokenType

use of com.hederahashgraph.api.proto.java.TokenType 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)

Example 8 with TokenType

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

the class ContractCallSuite method workingHoursDemo.

private HapiApiSpec workingHoursDemo() {
    final var initcode = "initcode";
    final var gasToOffer = 4_000_000;
    final var workingHours = "workingHours";
    final var ticketToken = "ticketToken";
    final var adminKey = "admin";
    final var treasury = "treasury";
    final var user = "user";
    final var newSupplyKey = "newSupplyKey";
    final var ticketTaking = "ticketTaking";
    final var ticketWorking = "ticketWorking";
    final var mint = "minting";
    final var burn = "burning";
    final var preMints = List.of(ByteString.copyFromUtf8("HELLO"), ByteString.copyFromUtf8("GOODBYE"));
    final AtomicLong ticketSerialNo = new AtomicLong();
    return defaultHapiSpec("WorkingHoursDemo").given(newKeyNamed(adminKey), cryptoCreate(treasury), // we need a new user, expiry to 1 Jan 2100 costs 11M gas for token associate
    cryptoCreate(user), cryptoTransfer(TokenMovement.movingHbar(ONE_HUNDRED_HBARS).between(GENESIS, user)), tokenCreate(ticketToken).treasury(treasury).tokenType(TokenType.NON_FUNGIBLE_UNIQUE).initialSupply(0L).supplyType(TokenSupplyType.INFINITE).adminKey(adminKey).supplyKey(adminKey), mintToken(ticketToken, preMints).via(mint), burnToken(ticketToken, List.of(1L)).via(burn), fileCreate(initcode), updateLargeFile(GENESIS, initcode, extractByteCode(WORKING_HOURS_USER_BYTECODE_PATH))).when(withOpContext((spec, opLog) -> {
        final var registry = spec.registry();
        final var tokenId = registry.getTokenID(ticketToken);
        final var treasuryId = registry.getAccountID(treasury);
        final var creation = contractCreate(workingHours, WORKING_HOURS_CONS, tokenId.getTokenNum(), treasuryId.getAccountNum()).bytecode(initcode).gas(gasToOffer);
        allRunFor(spec, creation);
    }), newKeyNamed(newSupplyKey).shape(KeyShape.CONTRACT.signedWith(workingHours)), tokenUpdate(ticketToken).supplyKey(newSupplyKey)).then(/* Take a ticket */
    contractCall(workingHours, WORKING_HOURS_TAKE_TICKET).payingWith(user).gas(4_000_000).via(ticketTaking).alsoSigningWithFullPrefix(treasury).exposingResultTo(result -> {
        log.info("Explicit mint result is {}", result);
        ticketSerialNo.set(((BigInteger) result[0]).longValueExact());
    }), getTxnRecord(ticketTaking), getAccountBalance(user).hasTokenBalance(ticketToken, 1L), /* Our ticket number is 3 (b/c of the two pre-mints), so we must call
						 * work twice before the contract will actually accept our ticket. */
    sourcing(() -> contractCall(workingHours, WORKING_HOURS_WORK_TICKET, ticketSerialNo.get()).gas(2_000_000).payingWith(user)), getAccountBalance(user).hasTokenBalance(ticketToken, 1L), sourcing(() -> contractCall(workingHours, WORKING_HOURS_WORK_TICKET, ticketSerialNo.get()).gas(2_000_000).payingWith(user).via(ticketWorking)), getAccountBalance(user).hasTokenBalance(ticketToken, 0L), getTokenInfo(ticketToken).hasTotalSupply(1L), /* Review the history */
    getTxnRecord(ticketTaking).andAllChildRecords().logged(), getTxnRecord(ticketWorking).andAllChildRecords().logged());
}
Also used : IMAP_USER_BYTECODE_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.IMAP_USER_BYTECODE_PATH) UtilVerbs.createLargeFile(com.hedera.services.bdd.spec.utilops.UtilVerbs.createLargeFile) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) QueryVerbs.getContractRecords(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractRecords) CallTransaction(org.ethereum.core.CallTransaction) TxnVerbs.contractDelete(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractDelete) MINT_ADD_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MINT_ADD_ABI) HapiGetTxnRecord(com.hedera.services.bdd.spec.queries.meta.HapiGetTxnRecord) OC_TOKEN_BYTECODE_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.OC_TOKEN_BYTECODE_PATH) OBTAINER_SAME_CONTRACT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OBTAINER_SAME_CONTRACT_ID) TOKEN_ERC20_CONSTRUCTOR_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TOKEN_ERC20_CONSTRUCTOR_ABI) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) QueryVerbs.contractCallLocal(com.hedera.services.bdd.spec.queries.QueryVerbs.contractCallLocal) BigInteger(java.math.BigInteger) CONTRACT_DELETED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_DELETED) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) ContractFnResultAsserts.resultWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith) TransactionRecordAsserts.recordWith(com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) TokenMovement(com.hedera.services.bdd.spec.transactions.token.TokenMovement) Logger(org.apache.logging.log4j.Logger) UtilVerbs.assertionsHold(com.hedera.services.bdd.spec.utilops.UtilVerbs.assertionsHold) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) UtilVerbs.balanceSnapshot(com.hedera.services.bdd.spec.utilops.UtilVerbs.balanceSnapshot) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) Bytes(org.apache.tuweni.bytes.Bytes) WORKING_HOURS_USER_BYTECODE_PATH(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.WORKING_HOURS_USER_BYTECODE_PATH) BiConsumer(java.util.function.BiConsumer) UtilVerbs.newKeyListNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyListNamed) AccountID(com.hederahashgraph.api.proto.java.AccountID) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) ContractResources.literalInitcodeFor(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.literalInitcodeFor) UtilVerbs.updateLargeFile(com.hedera.services.bdd.spec.utilops.UtilVerbs.updateLargeFile) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) TxnVerbs.burnToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.burnToken) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) QueryVerbs(com.hedera.services.bdd.spec.queries.QueryVerbs) HapiPropertySource.asSolidityAddress(com.hedera.services.bdd.spec.HapiPropertySource.asSolidityAddress) WORKING_HOURS_WORK_TICKET(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.WORKING_HOURS_WORK_TICKET) TokenType(com.hederahashgraph.api.proto.java.TokenType) AtomicLong(java.util.concurrent.atomic.AtomicLong) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) INSUFFICIENT_GAS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_GAS) CommonUtils(com.swirlds.common.CommonUtils) DECIMALS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.DECIMALS_ABI) CONTRACT_REVERT_EXECUTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.CONTRACT_REVERT_EXECUTED) INVALID_SOLIDITY_ADDRESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SOLIDITY_ADDRESS) ContractFunctionResult(com.hederahashgraph.api.proto.java.ContractFunctionResult) ContractInfoAsserts.contractWith(com.hedera.services.bdd.spec.assertions.ContractInfoAsserts.contractWith) INSUFFICIENT_TX_FEE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INSUFFICIENT_TX_FEE) WORKING_HOURS_TAKE_TICKET(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.WORKING_HOURS_TAKE_TICKET) OK(com.hederahashgraph.api.proto.java.ResponseCodeEnum.OK) CryptoGetInfoResponse(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) TxnVerbs.contractUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractUpdate) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) ContractLogAsserts.logWith(com.hedera.services.bdd.spec.assertions.ContractLogAsserts.logWith) QueryVerbs.getContractInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getContractInfo) HapiSpecSetup(com.hedera.services.bdd.spec.HapiSpecSetup) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) TxnUtils.asId(com.hedera.services.bdd.spec.transactions.TxnUtils.asId) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) AccountInfoAsserts.changeFromSnapshot(com.hedera.services.bdd.spec.assertions.AccountInfoAsserts.changeFromSnapshot) NOT_SUPPORTED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.NOT_SUPPORTED) HapiPropertySource.asHexedSolidityAddress(com.hedera.services.bdd.spec.HapiPropertySource.asHexedSolidityAddress) JURISDICTION_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.JURISDICTION_ABI) IMAP_USER_REMOVE(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.IMAP_USER_REMOVE) TRANSFER_FROM_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TRANSFER_FROM_ABI) WORKING_HOURS_CONS(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.WORKING_HOURS_CONS) UtilVerbs.logIt(com.hedera.services.bdd.spec.utilops.UtilVerbs.logIt) UtilVerbs.newKeyNamed(com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed) MINT_OWNER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MINT_OWNER_ABI) SYMBOL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.SYMBOL_ABI) Utils.extractByteCode(com.hedera.services.bdd.suites.contract.Utils.extractByteCode) ByteString(com.google.protobuf.ByteString) List(java.util.List) IMAP_USER_INSERT(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.IMAP_USER_INSERT) TxnVerbs.tokenUpdate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenUpdate) MINT_SEVEN_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MINT_SEVEN_ABI) BALANCE_OF_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.BALANCE_OF_ABI) TransactionRecord(com.hederahashgraph.api.proto.java.TransactionRecord) TRANSFER_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.TRANSFER_ABI) FeeBuilder(com.hederahashgraph.fee.FeeBuilder) ContractGetInfoResponse(com.hederahashgraph.api.proto.java.ContractGetInfoResponse) AtomicReference(java.util.concurrent.atomic.AtomicReference) INVALID_SIGNATURE(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_SIGNATURE) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) TxnVerbs(com.hedera.services.bdd.spec.transactions.TxnVerbs) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) MAX_GAS_LIMIT_EXCEEDED(com.hederahashgraph.api.proto.java.ResponseCodeEnum.MAX_GAS_LIMIT_EXCEEDED) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) JURISDICTION_ISVALID_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.JURISDICTION_ISVALID_ABI) TxnVerbs.mintToken(com.hedera.services.bdd.spec.transactions.TxnVerbs.mintToken) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) APPROVE_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.APPROVE_ABI) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) ContractFnResultAsserts.isLiteralResult(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.isLiteralResult) Key(com.hederahashgraph.api.proto.java.Key) UtilVerbs(com.hedera.services.bdd.spec.utilops.UtilVerbs) THRESHOLD(com.hedera.services.bdd.spec.keys.KeyFactory.KeyType.THRESHOLD) INVALID_CONTRACT_ID(com.hederahashgraph.api.proto.java.ResponseCodeEnum.INVALID_CONTRACT_ID) Assertions(org.junit.jupiter.api.Assertions) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) AssertUtils.inOrder(com.hedera.services.bdd.spec.assertions.AssertUtils.inOrder) LogManager(org.apache.logging.log4j.LogManager) TokenSupplyType(com.hederahashgraph.api.proto.java.TokenSupplyType) AtomicLong(java.util.concurrent.atomic.AtomicLong) BigInteger(java.math.BigInteger)

Example 9 with TokenType

use of com.hederahashgraph.api.proto.java.TokenType 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)

Example 10 with TokenType

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

the class ContractMintHTSSuite method helloWorldFungibleMint.

private HapiApiSpec helloWorldFungibleMint() {
    final var hwMintInitcode = "hwMintInitcode";
    final var amount = 1_234_567L;
    final var fungibleToken = "fungibleToken";
    final var multiKey = "purpose";
    final var contractKey = "meaning";
    final var hwMint = "hwMint";
    final var firstMintTxn = "firstMintTxn";
    final var secondMintTxn = "secondMintTxn";
    final AtomicLong fungibleNum = new AtomicLong();
    return defaultHapiSpec("HelloWorldFungibleMint").given(newKeyNamed(multiKey), fileCreate(hwMintInitcode).path(ContractResources.HW_MINT_PATH), tokenCreate(fungibleToken).tokenType(TokenType.FUNGIBLE_COMMON).initialSupply(0).adminKey(multiKey).supplyKey(multiKey).exposingCreatedIdTo(idLit -> fungibleNum.set(asDotDelimitedLongArray(idLit)[2]))).when(sourcing(() -> contractCreate(hwMint, HW_MINT_CONS_ABI, fungibleNum.get()).bytecode(hwMintInitcode).gas(GAS_TO_OFFER))).then(contractCall(hwMint, HW_BRRR_CALL_ABI, amount).via(firstMintTxn).alsoSigningWithFullPrefix(multiKey), getTxnRecord(firstMintTxn).andAllChildRecords().logged(), getTokenInfo(fungibleToken).hasTotalSupply(amount), /* And now make the token contract-controlled so no explicit supply sig is required */
    newKeyNamed(contractKey).shape(DELEGATE_CONTRACT.signedWith(hwMint)), tokenUpdate(fungibleToken).supplyKey(contractKey), getTokenInfo(fungibleToken).logged(), contractCall(hwMint, HW_BRRR_CALL_ABI, amount).via(secondMintTxn), getTxnRecord(secondMintTxn).andAllChildRecords().logged(), getTokenInfo(fungibleToken).hasTotalSupply(2 * amount), childRecordsCheck(secondMintTxn, SUCCESS, recordWith().status(SUCCESS).newTotalSupply(2469134L).tokenTransfers(changingFungibleBalances().including(fungibleToken, DEFAULT_PAYER, amount))));
}
Also used : QueryVerbs.getTokenNftInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenNftInfo) Arrays(java.util.Arrays) TxnVerbs.cryptoCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate) UtilVerbs.sourcing(com.hedera.services.bdd.spec.utilops.UtilVerbs.sourcing) ON(com.hedera.services.bdd.spec.keys.SigControl.ON) TxnVerbs.cryptoTransfer(com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer) ContractLogAsserts.logWith(com.hedera.services.bdd.spec.assertions.ContractLogAsserts.logWith) QueryVerbs.getTxnRecord(com.hedera.services.bdd.spec.queries.QueryVerbs.getTxnRecord) HapiApiSpec.defaultHapiSpec(com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec) SomeFungibleTransfers.changingFungibleBalances(com.hedera.services.bdd.spec.assertions.SomeFungibleTransfers.changingFungibleBalances) TxnVerbs.contractCall(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall) ContractFnResultAsserts.resultWith(com.hedera.services.bdd.spec.assertions.ContractFnResultAsserts.resultWith) 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) 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) KeyShape.sigs(com.hedera.services.bdd.spec.keys.KeyShape.sigs) HW_MINT_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.HW_MINT_CALL_ABI) TxnVerbs.tokenAssociate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenAssociate) UtilVerbs.withOpContext(com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext) QueryVerbs.getTokenInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getTokenInfo) MINT_CONS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MINT_CONS_ABI) DELEGATE_CONTRACT(com.hedera.services.bdd.spec.keys.KeyShape.DELEGATE_CONTRACT) ContractResources(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources) MINT_FUNGIBLE_WITH_EVENT_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MINT_FUNGIBLE_WITH_EVENT_CALL_ABI) 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) HW_MINT_CONS_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.HW_MINT_CONS_ABI) KeyShape(com.hedera.services.bdd.spec.keys.KeyShape) HTSPrecompileResult.htsPrecompileResult(com.hedera.services.bdd.suites.utils.contracts.precompile.HTSPrecompileResult.htsPrecompileResult) HW_BRRR_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.HW_BRRR_CALL_ABI) TxnVerbs.tokenCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate) HTSPrecompileResult(com.hedera.services.bdd.suites.utils.contracts.precompile.HTSPrecompileResult) ResponseCodeEnum(com.hederahashgraph.api.proto.java.ResponseCodeEnum) MINT_NON_FUNGIBLE_WITH_EVENT_CALL_ABI(com.hedera.services.bdd.spec.infrastructure.meta.ContractResources.MINT_NON_FUNGIBLE_WITH_EVENT_CALL_ABI) UtilVerbs.updateLargeFile(com.hedera.services.bdd.spec.utilops.UtilVerbs.updateLargeFile) QueryVerbs.getAccountBalance(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance) CustomSpecAssert.allRunFor(com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor) TokenType(com.hederahashgraph.api.proto.java.TokenType) AtomicLong(java.util.concurrent.atomic.AtomicLong) TxnVerbs.fileCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate) Utils.asAddress(com.hedera.services.bdd.suites.contract.Utils.asAddress) TxnVerbs.contractCreate(com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate) Utils.parsedToByteString(com.hedera.services.bdd.suites.contract.Utils.parsedToByteString) AssertUtils.inOrder(com.hedera.services.bdd.spec.assertions.AssertUtils.inOrder) LogManager(org.apache.logging.log4j.LogManager) TokenSupplyType(com.hederahashgraph.api.proto.java.TokenSupplyType) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Aggregations

TokenType (com.hederahashgraph.api.proto.java.TokenType)11 ResponseCodeEnum (com.hederahashgraph.api.proto.java.ResponseCodeEnum)10 List (java.util.List)10 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)9 HapiApiSpec.defaultHapiSpec (com.hedera.services.bdd.spec.HapiApiSpec.defaultHapiSpec)9 TransactionRecordAsserts.recordWith (com.hedera.services.bdd.spec.assertions.TransactionRecordAsserts.recordWith)9 ContractResources (com.hedera.services.bdd.spec.infrastructure.meta.ContractResources)9 QueryVerbs.getAccountBalance (com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountBalance)9 TxnVerbs.contractCall (com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCall)9 TxnVerbs.contractCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.contractCreate)9 TxnVerbs.cryptoCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoCreate)9 TxnVerbs.cryptoTransfer (com.hedera.services.bdd.spec.transactions.TxnVerbs.cryptoTransfer)9 TxnVerbs.fileCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.fileCreate)9 TxnVerbs.tokenCreate (com.hedera.services.bdd.spec.transactions.TxnVerbs.tokenCreate)9 CustomSpecAssert.allRunFor (com.hedera.services.bdd.spec.utilops.CustomSpecAssert.allRunFor)9 UtilVerbs.newKeyNamed (com.hedera.services.bdd.spec.utilops.UtilVerbs.newKeyNamed)9 UtilVerbs.updateLargeFile (com.hedera.services.bdd.spec.utilops.UtilVerbs.updateLargeFile)9 UtilVerbs.withOpContext (com.hedera.services.bdd.spec.utilops.UtilVerbs.withOpContext)9 HapiApiSuite (com.hedera.services.bdd.suites.HapiApiSuite)9 Utils.extractByteCode (com.hedera.services.bdd.suites.contract.Utils.extractByteCode)9