Search in sources :

Example 1 with ReferenceType

use of com.hedera.services.bdd.spec.queries.crypto.ReferenceType in project hedera-services by hashgraph.

the class HapiCryptoDelete method opBodyDef.

@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
    AccountID target;
    if (referenceType == ReferenceType.REGISTRY_NAME) {
        target = TxnUtils.asId(account, spec);
    } else {
        account = lookUpAccountWithAlias(spec, aliasKeySource);
        target = asAccount(account);
    }
    CryptoDeleteTransactionBody opBody = spec.txns().<CryptoDeleteTransactionBody, CryptoDeleteTransactionBody.Builder>body(CryptoDeleteTransactionBody.class, b -> {
        transferAccount.ifPresent(a -> b.setTransferAccountID(spec.registry().getAccountID(a)));
        b.setDeleteAccountID(target);
    });
    return b -> b.setCryptoDelete(opBody);
}
Also used : CryptoDeleteTransactionBody(com.hederahashgraph.api.proto.java.CryptoDeleteTransactionBody) Transaction(com.hederahashgraph.api.proto.java.Transaction) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) MoreObjects(com.google.common.base.MoreObjects) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) Function(java.util.function.Function) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) Optional(java.util.Optional) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) ReferenceType(com.hedera.services.bdd.spec.queries.crypto.ReferenceType) AccountID(com.hederahashgraph.api.proto.java.AccountID) LogManager(org.apache.logging.log4j.LogManager) HapiPropertySource.asAccount(com.hedera.services.bdd.spec.HapiPropertySource.asAccount) QueryUtils.lookUpAccountWithAlias(com.hedera.services.bdd.spec.queries.QueryUtils.lookUpAccountWithAlias) AccountID(com.hederahashgraph.api.proto.java.AccountID) CryptoDeleteTransactionBody(com.hederahashgraph.api.proto.java.CryptoDeleteTransactionBody)

Example 2 with ReferenceType

use of com.hedera.services.bdd.spec.queries.crypto.ReferenceType in project hedera-services by hashgraph.

the class HapiCryptoUpdate method opBodyDef.

@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
    try {
        updKey = updKeyName.map(spec.registry()::getKey);
    } catch (Exception ignore) {
    }
    AccountID id;
    if (referenceType == ReferenceType.REGISTRY_NAME) {
        id = TxnUtils.asId(account, spec);
    } else {
        id = asIdForKeyLookUp(aliasKeySource, spec);
        account = asAccountString(id);
    }
    CryptoUpdateTransactionBody opBody = spec.txns().<CryptoUpdateTransactionBody, CryptoUpdateTransactionBody.Builder>body(CryptoUpdateTransactionBody.class, builder -> {
        builder.setAccountIDToUpdate(id);
        newProxy.ifPresent(p -> {
            var proxyId = TxnUtils.asId(p, spec);
            builder.setProxyAccountID(proxyId);
        });
        updSigRequired.ifPresent(u -> builder.setReceiverSigRequiredWrapper(BoolValue.of(u)));
        if (useContractKey) {
            builder.setKey(Key.newBuilder().setContractID(HapiPropertySource.asContract("0.0.1234")));
        } else {
            updKey.ifPresent(builder::setKey);
        }
        newAutoRenewPeriod.ifPresent(p -> builder.setAutoRenewPeriod(Duration.newBuilder().setSeconds(p)));
        entityMemo.ifPresent(m -> builder.setMemo(StringValue.newBuilder().setValue(m).build()));
        sendThreshold.ifPresent(v -> builder.setSendRecordThresholdWrapper(UInt64Value.newBuilder().setValue(v).build()));
        newExpiry.ifPresent(l -> builder.setExpirationTime(Timestamp.newBuilder().setSeconds(l).build()));
        newMaxAutomaticAssociations.ifPresent(p -> builder.setMaxAutomaticTokenAssociations(Int32Value.of(p)));
    });
    return builder -> builder.setCryptoUpdateAccount(opBody);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) CryptoGetInfoResponse(com.hederahashgraph.api.proto.java.CryptoGetInfoResponse) BoolValue(com.google.protobuf.BoolValue) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) UInt64Value(com.google.protobuf.UInt64Value) StringValue(com.google.protobuf.StringValue) Duration(com.hederahashgraph.api.proto.java.Duration) Function(java.util.function.Function) TxnUtils.defaultUpdateSigners(com.hedera.services.bdd.spec.transactions.TxnUtils.defaultUpdateSigners) OptionalLong(java.util.OptionalLong) PropertySource.asAccountString(com.hedera.services.bdd.spec.PropertySource.asAccountString) BaseTransactionMeta(com.hedera.services.usage.BaseTransactionMeta) QueryVerbs.getAccountInfo(com.hedera.services.bdd.spec.queries.QueryVerbs.getAccountInfo) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) UsageAccumulator(com.hedera.services.usage.state.UsageAccumulator) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) HapiApiSuite(com.hedera.services.bdd.suites.HapiApiSuite) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) CryptoUpdateMeta(com.hedera.services.usage.crypto.CryptoUpdateMeta) ReferenceType(com.hedera.services.bdd.spec.queries.crypto.ReferenceType) AccountID(com.hederahashgraph.api.proto.java.AccountID) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody) Int32Value(com.google.protobuf.Int32Value) MoreObjects(com.google.common.base.MoreObjects) HapiPropertySource(com.hedera.services.bdd.spec.HapiPropertySource) ExtantCryptoContext(com.hedera.services.usage.crypto.ExtantCryptoContext) SUCCESS(com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS) HapiGetAccountInfo(com.hedera.services.bdd.spec.queries.crypto.HapiGetAccountInfo) Consumer(java.util.function.Consumer) Key(com.hederahashgraph.api.proto.java.Key) List(java.util.List) Logger(org.apache.logging.log4j.Logger) TxnUtils.asIdForKeyLookUp(com.hedera.services.bdd.spec.transactions.TxnUtils.asIdForKeyLookUp) AdapterUtils(com.hedera.services.bdd.spec.fees.AdapterUtils) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) Optional(java.util.Optional) TxnUtils.suFrom(com.hedera.services.bdd.spec.transactions.TxnUtils.suFrom) FeeCalculator(com.hedera.services.bdd.spec.fees.FeeCalculator) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) AccountID(com.hederahashgraph.api.proto.java.AccountID) CryptoUpdateTransactionBody(com.hederahashgraph.api.proto.java.CryptoUpdateTransactionBody)

Aggregations

MoreObjects (com.google.common.base.MoreObjects)2 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)2 ReferenceType (com.hedera.services.bdd.spec.queries.crypto.ReferenceType)2 HapiTxnOp (com.hedera.services.bdd.spec.transactions.HapiTxnOp)2 TxnUtils (com.hedera.services.bdd.spec.transactions.TxnUtils)2 AccountID (com.hederahashgraph.api.proto.java.AccountID)2 HederaFunctionality (com.hederahashgraph.api.proto.java.HederaFunctionality)2 Key (com.hederahashgraph.api.proto.java.Key)2 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)2 Transaction (com.hederahashgraph.api.proto.java.Transaction)2 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)2 TransactionResponse (com.hederahashgraph.api.proto.java.TransactionResponse)2 List (java.util.List)2 Optional (java.util.Optional)2 Consumer (java.util.function.Consumer)2 Function (java.util.function.Function)2 LogManager (org.apache.logging.log4j.LogManager)2 Logger (org.apache.logging.log4j.Logger)2 BoolValue (com.google.protobuf.BoolValue)1 Int32Value (com.google.protobuf.Int32Value)1