use of com.hedera.services.bdd.spec.infrastructure.meta.ActionableContractCallLocal in project hedera-services by hashgraph.
the class HapiContractCallLocal method getContractCallLocal.
private Query getContractCallLocal(HapiApiSpec spec, Transaction payment, boolean costOnly) {
if (details.isPresent()) {
ActionableContractCallLocal actionable = spec.registry().getActionableLocalCall(details.get());
contract = actionable.getContract();
abi = actionable.getDetails().getAbi();
params = actionable.getDetails().getExampleArgs();
} else if (paramsFn.isPresent()) {
params = paramsFn.get().apply(spec);
}
byte[] callData = (abi != FALLBACK_ABI) ? CallTransaction.Function.fromJsonInterface(abi).encode(params) : new byte[] {};
final var opBuilder = ContractCallLocalQuery.newBuilder().setHeader(costOnly ? answerCostHeader(payment) : answerHeader(payment)).setFunctionParameters(ByteString.copyFrom(callData)).setGas(gas.orElse(spec.setup().defaultCallGas())).setMaxResultSize(maxResultSize.orElse(spec.setup().defaultMaxLocalCallRetBytes()));
if (contract.length() == HEXED_EVM_ADDRESS_LEN) {
opBuilder.setContractID(ContractID.newBuilder().setEvmAddress(ByteString.copyFrom(CommonUtils.unhex(contract))));
} else {
opBuilder.setContractID(TxnUtils.asContractId(contract, spec));
}
return Query.newBuilder().setContractCallLocal(opBuilder).build();
}
use of com.hedera.services.bdd.spec.infrastructure.meta.ActionableContractCallLocal in project hedera-services by hashgraph.
the class RandomContract method get.
@Override
public Optional<HapiSpecOperation> get() {
if (contracts.numPresent() >= ceilingNum) {
return Optional.empty();
}
Optional<String> key = keys.getQualifying();
if (key.isEmpty()) {
return Optional.empty();
}
int n = opNo.getAndIncrement();
final String tentativeContract = my("contract" + n);
final SupportedContract choice = choices[n % choices.length];
HapiContractCreate op = contractCreate(tentativeContract).adminKey(key.get()).bytecode(fileFor(choice)).skipAccountRegistration().hasPrecheckFrom(STANDARD_PERMISSIBLE_PRECHECKS).hasKnownStatusFrom(permissibleOutcomes).uponSuccess(registry -> {
registry.saveContractChoice(tentativeContract, choice);
AtomicInteger tag = new AtomicInteger();
choice.getCallDetails().forEach(detail -> {
ActionableContractCall call = new ActionableContractCall(tentativeContract, detail);
registry.saveActionableCall(tentativeContract + "-" + tag.getAndIncrement(), call);
});
choice.getLocalCallDetails().forEach(detail -> {
ActionableContractCallLocal call = new ActionableContractCallLocal(tentativeContract, detail);
registry.saveActionableLocalCall(tentativeContract + "-" + tag.getAndIncrement(), call);
});
});
return Optional.of(op);
}
Aggregations