use of com.quorum.gauge.ext.PrivateClientTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class AccumulatorService method createAccumulatorPrivateContract.
public Observable<? extends Accumulator> createAccumulatorPrivateContract(QuorumNetworkProperty.Node source, List<QuorumNetworkProperty.Node> targets, BigInteger gas, int initVal, List<PrivacyFlag> flags) {
Quorum client = connectionFactory().getConnection(source);
final List<String> privateFor;
if (null != targets) {
privateFor = targets.stream().filter(Objects::nonNull).map(q -> privacyService.id(q)).collect(Collectors.toList());
} else {
privateFor = null;
}
return accountService.getDefaultAccountAddress(source).flatMap(address -> {
PrivateClientTransactionManager clientTransactionManager = new PrivateClientTransactionManager(client, address, null, privateFor, flags, DEFAULT_MAX_RETRY, DEFAULT_SLEEP_DURATION_IN_MILLIS);
return Accumulator.deploy(client, clientTransactionManager, BigInteger.valueOf(0), gas, BigInteger.valueOf(initVal)).flowable().toObservable();
});
}
use of com.quorum.gauge.ext.PrivateClientTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class AccumulatorService method incAccumulatorPrivate.
public Observable<TransactionReceipt> incAccumulatorPrivate(final QuorumNetworkProperty.Node source, final List<QuorumNetworkProperty.Node> target, final String contractAddress, final BigInteger gasLimit, final int increment, final List<PrivacyFlag> flags) {
final Quorum client = connectionFactory().getConnection(source);
final BigInteger value = BigInteger.valueOf(increment);
final List<String> privateFor = target.stream().map(q -> privacyService.id(q)).collect(Collectors.toList());
return accountService.getDefaultAccountAddress(source).flatMap(acctAddress -> {
PrivateClientTransactionManager txManager = new PrivateClientTransactionManager(client, acctAddress, null, privateFor, flags, DEFAULT_MAX_RETRY, DEFAULT_SLEEP_DURATION_IN_MILLIS);
Accumulator accumulator = Accumulator.load(contractAddress, client, txManager, BigInteger.ZERO, gasLimit);
return accumulator.inc(value).flowable().toObservable();
});
}
use of com.quorum.gauge.ext.PrivateClientTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class ContractService method createSimpleContract.
public Observable<? extends Contract> createSimpleContract(int initialValue, Node source, String ethAccount, String privateFromAliases, List<String> privateForAliases, List<PrivacyFlag> flags, BigInteger gas) {
if (CollectionUtils.isEmpty(flags)) {
flags = emptyList();
}
Quorum client = connectionFactory().getConnection(source);
List<PrivacyFlag> finalFlags = flags;
return accountService.getAccountAddress(source, ethAccount).flatMap(address -> {
PrivateClientTransactionManager clientTransactionManager = new PrivateClientTransactionManager(client, address, privacyService.id(privateFromAliases), privateForAliases.stream().map(privacyService::id).collect(Collectors.toList()), finalFlags);
return SimpleStorage.deploy(client, clientTransactionManager, BigInteger.valueOf(0), gas, BigInteger.valueOf(initialValue)).flowable().toObservable();
});
}
use of com.quorum.gauge.ext.PrivateClientTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class ContractService method setGenericStoreContractSetValue.
public Observable<TransactionReceipt> setGenericStoreContractSetValue(QuorumNetworkProperty.Node node, String contractAddress, String contractName, String methodName, int value, boolean isPrivate, QuorumNode target, PrivacyFlag privacyType) {
Quorum client = connectionFactory().getConnection(node);
String fromAddress = accountService.getDefaultAccountAddress(node).blockingFirst();
TransactionManager txManager;
if (isPrivate) {
txManager = new PrivateClientTransactionManager(client, fromAddress, null, Arrays.asList(privacyService.id(target)), Arrays.asList(privacyType));
} else {
txManager = new PrivateClientTransactionManager(client, fromAddress, null, null, List.of(PrivacyFlag.StandardPrivate));
}
try {
switch(contractName.toLowerCase().trim()) {
case "storea":
switch(methodName.toLowerCase().trim()) {
case "seta":
return Storea.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).seta(BigInteger.valueOf(value)).flowable().toObservable();
case "setb":
return Storea.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).setb(BigInteger.valueOf(value)).flowable().toObservable();
case "setc":
return Storea.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).setc(BigInteger.valueOf(value)).flowable().toObservable();
default:
throw new Exception("invalid method name " + methodName + " for contract " + contractName);
}
case "storeb":
switch(methodName.toLowerCase().trim()) {
case "setb":
return Storeb.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).setb(BigInteger.valueOf(value)).flowable().toObservable();
case "setc":
return Storeb.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).setc(BigInteger.valueOf(value)).flowable().toObservable();
default:
throw new Exception("invalid method name " + methodName + " for contract " + contractName);
}
case "storec":
switch(methodName.toLowerCase().trim()) {
case "setc":
return Storec.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).setc(BigInteger.valueOf(value)).flowable().toObservable();
default:
throw new Exception("invalid method name " + methodName + " for contract " + contractName);
}
default:
throw new Exception("invalid contract name " + contractName);
}
} catch (Exception e) {
logger.debug("setStoreContractValue() " + contractName + " " + methodName, e);
throw new RuntimeException(e);
}
}
use of com.quorum.gauge.ext.PrivateClientTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class ContractService method updatePublicSimpleStorageContract.
public Observable<TransactionReceipt> updatePublicSimpleStorageContract(final int newValue, final String contractAddress, final Node source, String ethAccount) {
final Quorum client = connectionFactory().getConnection(source);
final BigInteger value = BigInteger.valueOf(newValue);
return accountService.getAccountAddress(source, ethAccount).map(address -> new PrivateClientTransactionManager(client, address, null, null, Collections.emptyList())).flatMap(txManager -> SimpleStorage.load(contractAddress, client, txManager, BigInteger.ZERO, DEFAULT_GAS_LIMIT).set(value).flowable().toObservable());
}
Aggregations