Search in sources :

Example 1 with HEXED_EVM_ADDRESS_LEN

use of com.hedera.services.bdd.spec.transactions.contract.HapiContractCall.HEXED_EVM_ADDRESS_LEN in project hedera-services by hashgraph.

the class HapiContractUpdate method opBodyDef.

@Override
protected Consumer<TransactionBody.Builder> opBodyDef(HapiApiSpec spec) throws Throwable {
    Optional<Key> key = newKey.map(spec.registry()::getKey);
    ContractUpdateTransactionBody opBody = spec.txns().<ContractUpdateTransactionBody, ContractUpdateTransactionBody.Builder>body(ContractUpdateTransactionBody.class, b -> {
        if (contract.length() == HEXED_EVM_ADDRESS_LEN) {
            b.setContractID(ContractID.newBuilder().setEvmAddress(ByteString.copyFrom(CommonUtils.unhex(contract))));
        } else {
            b.setContractID(TxnUtils.asContractId(contract, spec));
        }
        if (useDeprecatedAdminKey) {
            b.setAdminKey(DEPRECATED_CID_ADMIN_KEY);
        } else if (wipeToThresholdKey) {
            b.setAdminKey(TxnUtils.EMPTY_THRESHOLD_KEY);
        } else if (useEmptyAdminKeyList) {
            b.setAdminKey(TxnUtils.EMPTY_KEY_LIST);
        } else {
            key.ifPresent(b::setAdminKey);
        }
        newExpirySecs.ifPresent(t -> b.setExpirationTime(Timestamp.newBuilder().setSeconds(t).build()));
        newMemo.ifPresent(s -> {
            if (useDeprecatedMemoField) {
                b.setMemo(s);
            } else {
                b.setMemoWrapper(StringValue.newBuilder().setValue(s).build());
            }
        });
        newAutoRenew.ifPresent(autoRenew -> b.setAutoRenewPeriod(Duration.newBuilder().setSeconds(autoRenew).build()));
        bytecode.ifPresent(f -> b.setFileID(TxnUtils.asFileId(bytecode.get(), spec)).build());
    });
    return builder -> builder.setContractUpdateInstance(opBody);
}
Also used : Transaction(com.hederahashgraph.api.proto.java.Transaction) HapiTxnOp(com.hedera.services.bdd.spec.transactions.HapiTxnOp) StringValue(com.google.protobuf.StringValue) HEXED_EVM_ADDRESS_LEN(com.hedera.services.bdd.spec.transactions.contract.HapiContractCall.HEXED_EVM_ADDRESS_LEN) ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) Duration(com.hederahashgraph.api.proto.java.Duration) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ContractID(com.hederahashgraph.api.proto.java.ContractID) OptionalLong(java.util.OptionalLong) TxnFactory(com.hedera.services.bdd.spec.transactions.TxnFactory) TxnUtils(com.hedera.services.bdd.spec.transactions.TxnUtils) TransactionBody(com.hederahashgraph.api.proto.java.TransactionBody) TransactionResponse(com.hederahashgraph.api.proto.java.TransactionResponse) Timestamp(com.hederahashgraph.api.proto.java.Timestamp) 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) CommonUtils(com.swirlds.common.CommonUtils) DEPRECATED_CID_ADMIN_KEY(com.hedera.services.bdd.spec.transactions.contract.HapiContractCreate.DEPRECATED_CID_ADMIN_KEY) HederaFunctionality(com.hederahashgraph.api.proto.java.HederaFunctionality) Optional(java.util.Optional) FeeCalculator(com.hedera.services.bdd.spec.fees.FeeCalculator) HapiApiSpec(com.hedera.services.bdd.spec.HapiApiSpec) LogManager(org.apache.logging.log4j.LogManager) ContractUpdateTransactionBody(com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody) Key(com.hederahashgraph.api.proto.java.Key)

Aggregations

MoreObjects (com.google.common.base.MoreObjects)1 ByteString (com.google.protobuf.ByteString)1 StringValue (com.google.protobuf.StringValue)1 HapiApiSpec (com.hedera.services.bdd.spec.HapiApiSpec)1 FeeCalculator (com.hedera.services.bdd.spec.fees.FeeCalculator)1 HapiTxnOp (com.hedera.services.bdd.spec.transactions.HapiTxnOp)1 TxnFactory (com.hedera.services.bdd.spec.transactions.TxnFactory)1 TxnUtils (com.hedera.services.bdd.spec.transactions.TxnUtils)1 HEXED_EVM_ADDRESS_LEN (com.hedera.services.bdd.spec.transactions.contract.HapiContractCall.HEXED_EVM_ADDRESS_LEN)1 DEPRECATED_CID_ADMIN_KEY (com.hedera.services.bdd.spec.transactions.contract.HapiContractCreate.DEPRECATED_CID_ADMIN_KEY)1 ContractID (com.hederahashgraph.api.proto.java.ContractID)1 ContractUpdateTransactionBody (com.hederahashgraph.api.proto.java.ContractUpdateTransactionBody)1 Duration (com.hederahashgraph.api.proto.java.Duration)1 HederaFunctionality (com.hederahashgraph.api.proto.java.HederaFunctionality)1 Key (com.hederahashgraph.api.proto.java.Key)1 SUCCESS (com.hederahashgraph.api.proto.java.ResponseCodeEnum.SUCCESS)1 Timestamp (com.hederahashgraph.api.proto.java.Timestamp)1 Transaction (com.hederahashgraph.api.proto.java.Transaction)1 TransactionBody (com.hederahashgraph.api.proto.java.TransactionBody)1 TransactionResponse (com.hederahashgraph.api.proto.java.TransactionResponse)1