use of org.web3j.tx.ReadonlyTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class AccumulatorService method subscribeTo.
public Disposable subscribeTo(QuorumNetworkProperty.Node node, String contractAddress, List<Accumulator.IncEventEventResponse> list) {
Quorum client = connectionFactory().getConnection(node, POLLING_INTERVAL);
String address;
try {
address = client.ethCoinbase().send().getAddress();
ReadonlyTransactionManager txManager = new ReadonlyTransactionManager(client, address);
Accumulator acc = Accumulator.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT);
return acc.incEventEventFlowable(DefaultBlockParameterName.EARLIEST, DefaultBlockParameterName.LATEST).subscribe(list::add);
} catch (Exception e) {
logger.error("accumulator.subscribe()", e);
throw new RuntimeException(e);
}
}
use of org.web3j.tx.ReadonlyTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class AccumulatorService method get.
public int get(QuorumNetworkProperty.Node node, String contractAddress) {
Quorum client = connectionFactory().getConnection(node);
String address;
try {
address = client.ethCoinbase().send().getAddress();
ReadonlyTransactionManager txManager = new ReadonlyTransactionManager(client, address);
return Accumulator.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).get().send().intValue();
} catch (ContractCallException cce) {
if (cce.getMessage().contains("Empty value (0x)")) {
return 0;
}
logger.error("accumulator.get()", cce);
throw new RuntimeException(cce);
} catch (Exception e) {
logger.error("accumulator.get()", e);
throw new RuntimeException(e);
}
}
use of org.web3j.tx.ReadonlyTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class ContractService method readSimpleContractValue.
// Read-only contract
public int readSimpleContractValue(QuorumNode node, String contractAddress) {
Quorum client = connectionFactory().getConnection(node);
String address;
try {
address = client.ethCoinbase().send().getAddress();
ReadonlyTransactionManager txManager = new ReadonlyTransactionManager(client, address);
return SimpleStorage.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).get().send().intValue();
} catch (ContractCallException cce) {
if (cce.getMessage().contains("Empty value (0x)")) {
return 0;
}
logger.error("readSimpleContractValue()", cce);
throw new RuntimeException(cce);
} catch (Exception e) {
logger.error("readSimpleContractValue()", e);
throw new RuntimeException(e);
}
}
use of org.web3j.tx.ReadonlyTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class NestedContractService method readC2Value.
// Read-only contract
public int readC2Value(QuorumNode node, String contractAddress) {
Quorum client = connectionFactory().getConnection(node);
String address;
try {
address = client.ethCoinbase().send().getAddress();
ReadonlyTransactionManager txManager = new ReadonlyTransactionManager(client, address);
return C2.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).get().send().intValue();
} catch (ContractCallException cce) {
if (cce.getMessage().contains("Empty value (0x)")) {
return 0;
}
logger.error("readSimpleContractValue()", cce);
throw new RuntimeException(cce);
} catch (Exception e) {
logger.error("readSimpleContractValue()", e);
throw new RuntimeException(e);
}
}
use of org.web3j.tx.ReadonlyTransactionManager in project quorum-acceptance-tests by ConsenSys.
the class ContractService method readGenericStoreContractGetValue.
public int readGenericStoreContractGetValue(QuorumNode node, String contractAddress, String contractName, String methodName) {
Quorum client = connectionFactory().getConnection(node);
String address;
try {
address = client.ethCoinbase().send().getAddress();
ReadonlyTransactionManager txManager = new ReadonlyTransactionManager(client, address);
switch(contractName.toLowerCase().trim()) {
case "storea":
switch(methodName.toLowerCase().trim()) {
case "geta":
return Storea.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).geta().send().intValue();
case "getb":
return Storea.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).getb().send().intValue();
case "getc":
return Storea.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).getc().send().intValue();
default:
throw new Exception("invalid method name " + methodName + " for contract " + contractName);
}
case "storeb":
switch(methodName.toLowerCase().trim()) {
case "getb":
return Storeb.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).getb().send().intValue();
case "getc":
return Storeb.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).getc().send().intValue();
default:
throw new Exception("invalid method name " + methodName + " for contract " + contractName);
}
case "storec":
switch(methodName.toLowerCase().trim()) {
case "getc":
return Storec.load(contractAddress, client, txManager, BigInteger.valueOf(0), DEFAULT_GAS_LIMIT).getc().send().intValue();
default:
throw new Exception("invalid method name " + methodName + " for contract " + contractName);
}
default:
throw new Exception("invalid contract name ");
}
} catch (Exception e) {
logger.debug("readStoreContractValue() " + contractName + " " + methodName, e);
throw new RuntimeException(e);
}
}
Aggregations