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);
}
Aggregations