Skip to content

Commit

Permalink
Merge pull request #72 from rwth-acis/release_v1.0.1
Browse files Browse the repository at this point in the history
Release v1.0.1
  • Loading branch information
AlexanderNeumann authored Dec 3, 2020
2 parents 16378b7 + ce7b161 commit 8f04117
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<classpathentry kind="lib" path="core/lib/junit-4.12.jar"/>
<classpathentry kind="lib" path="core/lib/xpp3-1.1.4c.jar"/>
<classpathentry kind="lib" path="core/lib/abi-4.0.1.jar"/>
<classpathentry kind="lib" path="core/lib/core-4.0.1.jar"/>
<classpathentry kind="lib" path="core/lib/crypto-4.0.1.jar"/>
<classpathentry kind="lib" path="core/lib/rlp-4.0.1.jar"/>
<classpathentry kind="lib" path="core/lib/tuples-4.0.1.jar"/>
Expand Down Expand Up @@ -73,5 +72,6 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="core/lib/slf4j-api-1.7.25.jar"/>
<classpathentry kind="lib" path="core/lib/slf4j-simple-1.7.25.jar"/>
<classpathentry kind="lib" path="core/lib/core-4.5.5.jar"/>
<classpathentry kind="output" path="output"/>
</classpath>
2 changes: 1 addition & 1 deletion bundle/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<property name="ivy.organisation" value="i5"/>
<property name="ivy.revision" value="1.0"/>
<property name="ivy.build.number" value="0"/>
<property name="ivy.build.number" value="1"/>
<property name="ivy.deliver.revision" value="${ivy.revision}"/>
<property name="ivy.pom.version" value="${ivy.revision}"/>

Expand Down
2 changes: 1 addition & 1 deletion core/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<property name="ivy.organisation" value="i5"/>
<property name="ivy.revision" value="1.0"/>
<property name="ivy.build.number" value="0"/>
<property name="ivy.build.number" value="1"/>
<property name="ivy.deliver.revision" value="${ivy.revision}"/>
<property name="ivy.pom.version" value="${ivy.revision}"/>

Expand Down
2 changes: 1 addition & 1 deletion core/ivy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<dependency org="ch.qos.logback" name="logback-core" rev="1.2.3">
<artifact name="logback-core" type="jar"/>
</dependency>
<dependency org="org.web3j" name="core" rev="4.0.1"/>
<dependency org="org.web3j" name="core" rev="4.5.5"/>
<dependency org="org.slf4j" name="slf4j-simple" rev="1.7.25"/>
<!--dependency org="ch.qos.logback" name="logback-classic" rev="1.2.3" /-->
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package i5.las2peer.registry;

import java.io.IOException;
import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
Expand All @@ -9,13 +10,17 @@

import org.web3j.abi.datatypes.Function;
import org.web3j.crypto.Credentials;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.core.Response;
import org.web3j.protocol.core.methods.request.Transaction;
import org.web3j.protocol.core.methods.response.EthSendTransaction;
import org.web3j.protocol.core.methods.response.TransactionReceipt;
import org.web3j.protocol.exceptions.TransactionException;
import org.web3j.tx.Contract;
import org.web3j.tx.FastRawTransactionManager;
import org.web3j.tx.Transfer;
import org.web3j.tx.gas.ContractGasProvider;
import org.web3j.tx.gas.StaticGasProvider;
import org.web3j.utils.Convert;
import org.web3j.utils.Convert.Unit;

Expand Down Expand Up @@ -225,7 +230,7 @@ public String addUserRating(EthereumAgent receivingAgent, Integer rating) throws
}

public boolean hasReputationProfile(String profileName)
throws EthereumException {
throws EthereumException {
Boolean hasProfile = Boolean.FALSE;
try {
hasProfile = contracts.reputationRegistry.hasProfile(profileName).sendAsync().get();
Expand All @@ -245,7 +250,7 @@ public boolean hasReputationProfile(String profileName)
* @param agent Ethereum agent of the service author
*/
public void registerService(String serviceName, EthereumAgent agent) throws EthereumException,
AgentLockedException {
AgentLockedException {
byte[] authorName = Util.padAndConvertString(agent.getLoginName(), 32);

final Function function = new Function(ServiceRegistry.FUNC_REGISTER,
Expand All @@ -257,7 +262,7 @@ public void registerService(String serviceName, EthereumAgent agent) throws Ethe

try {
contracts.serviceRegistry.delegatedRegister(serviceName, authorName, consentee, signature).sendAsync()
.get();
.get();
} catch (Exception e) {
throw new EthereumException("Failed to register service", e);
}
Expand Down Expand Up @@ -347,12 +352,12 @@ public void releaseService(String serviceName, int versionMajor, int versionMino
* @param nodeId identifier of the node running the deployment
*/
public void announceDeployment(String servicePackageName, String serviceClassName,
int versionMajor, int versionMinor, int versionPatch,
String nodeId) throws EthereumException {
int versionMajor, int versionMinor, int versionPatch,
String nodeId) throws EthereumException {
try {
contracts.serviceRegistry.announceDeployment(servicePackageName, serviceClassName,
BigInteger.valueOf(versionMajor), BigInteger.valueOf(versionMinor), BigInteger.valueOf(versionPatch),
nodeId).sendAsync().get();
BigInteger.valueOf(versionMajor), BigInteger.valueOf(versionMinor), BigInteger.valueOf(versionPatch),
nodeId).sendAsync().get();
} catch (Exception e) {
throw new EthereumException("Failed to submit service deployment announcement ("
+ "DEBUG: " + serviceClassName + ", " + e.getMessage() + ")", e);
Expand All @@ -374,12 +379,12 @@ public void announceDeployment(String servicePackageName, String serviceClassNam
// TODO: is there a more elegant way? referencing the tx is possible of course
// but not really preferable
public void announceDeploymentEnd(String servicePackageName, String serviceClassName,
int versionMajor, int versionMinor, int versionPatch,
String nodeId) throws EthereumException {
int versionMajor, int versionMinor, int versionPatch,
String nodeId) throws EthereumException {
try {
contracts.serviceRegistry.announceDeploymentEnd(servicePackageName, serviceClassName,
BigInteger.valueOf(versionMajor), BigInteger.valueOf(versionMinor), BigInteger.valueOf(versionPatch),
nodeId).sendAsync().get();
BigInteger.valueOf(versionMajor), BigInteger.valueOf(versionMinor), BigInteger.valueOf(versionPatch),
nodeId).sendAsync().get();
} catch (Exception e) {
throw new EthereumException("Failed to submit service deployment *end* announcement ("
+ "DEBUG: " + serviceClassName + ", " + e.getMessage() + ")", e);
Expand All @@ -392,10 +397,10 @@ public String sendEtherManaged(String senderAddress, String recipientAddress, Bi
BigInteger gasPrice = GAS_PRICE;
BigInteger gasLimit = GAS_LIMIT_ETHER_TX;
logger.info("[ETH] Preparing raw transaction between accounts...");

Transfer transfer = new Transfer(this.web3j, this.contracts.transactionManager);





Expand Down Expand Up @@ -443,7 +448,7 @@ public String sendEtherManaged(String senderAddress, String recipientAddress, Bi
@Deprecated
public TransactionReceipt sendEther(String senderAddress, String recipientAddress, BigInteger valueInWei)
throws EthereumException {

TransactionReceipt txR;
String txHash;
BigInteger nonce = BigInteger.valueOf(-1);
Expand All @@ -468,12 +473,12 @@ public TransactionReceipt sendEther(String senderAddress, String recipientAddres
throw new EthereumException("Eth Transaction Error [" + error.getCode() + "]: " + error.getMessage());
}
txHash = ethSendTransaction.getTransactionHash();

if (txHash.length() < 2) {
throw new EthereumException("Could not create ethereum transaction");
}


logger.info("[ETH] waiting for receipt on [" + txHash + "]... ");
txR = waitForReceipt(txHash);

Expand Down Expand Up @@ -512,6 +517,32 @@ public String sendEtherFromCoinbase(String recipientAddress, BigInteger valueInW
logger.info("[ETH] Sending Faucet Transaction");
return sendEtherManaged(coinbase, recipientAddress, valueInWei);
}



public <T extends Contract> T deploySmartContract(Class<T> contractClass, String contractBinary) {
T contract = null;
try {
contract = T.deployRemoteCall(contractClass, web3j, credentials, gasPrice, gasLimit, contractBinary, "", BigInteger.ZERO).send();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return contract;
}

public <T extends Contract> T loadSmartContract(Class<T> contractClass, String contractAddress) {
T contract = null;
try {
Constructor<T> constructor = contractClass.getDeclaredConstructor(
String.class,
Web3j.class,
Credentials.class,
ContractGasProvider.class);
constructor.setAccessible(true);
contract = constructor.newInstance(contractAddress, web3j, credentials, new StaticGasProvider(gasPrice, gasLimit));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return contract;
}
}
31 changes: 31 additions & 0 deletions core/src/main/java/i5/las2peer/serialization/XmlTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
Expand Down Expand Up @@ -162,6 +164,35 @@ public static Element getOptionalElement(Element parent, String tagName) throws
return null;
}
}

/**
* Gets all elements with the given child tag from given parent XML element.
*
* @param parent The parent XML element.
* @param tagName The tag name of the child elements. CASE SENSITIVE
* @return Returns the child elements with the given tag name or null if no child matches the given tag name.
* @throws MalformedXMLException If it's not a node itself.
*/
public static List<Element> getElementList(Element parent, String tagName) throws MalformedXMLException {
NodeList nodeList = parent.getElementsByTagName(tagName);
int len = nodeList.getLength();
if (len > 0) {
ArrayList<Element> elements = new ArrayList<>();
for (int i = 0; i < len; i++) {
org.w3c.dom.Node firstNode = nodeList.item(i);
short nodeType = firstNode.getNodeType();
if (nodeType != org.w3c.dom.Node.ELEMENT_NODE) {
throw new MalformedXMLException(
"Node type (" + nodeType + ") is not type element (" + org.w3c.dom.Node.ELEMENT_NODE + ")");
}
elements.add((Element) firstNode);
}
return elements;
} else {
// no child elements with tag name found
return null;
}
}

public static String escapeString(String str) {
return str.replace("&", "&amp;").replace("'", "&apos;").replace("<", "&lt;").replace(">", "&gt;");
Expand Down
2 changes: 1 addition & 1 deletion restmapper/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<property name="ivy.organisation" value="i5"/>
<property name="ivy.revision" value="1.0"/>
<property name="ivy.build.number" value="0"/>
<property name="ivy.build.number" value="1"/>
<property name="ivy.deliver.revision" value="${ivy.revision}"/>
<property name="ivy.pom.version" value="${ivy.revision}"/>

Expand Down
2 changes: 1 addition & 1 deletion webconnector/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<property name="ivy.organisation" value="i5"/>
<property name="ivy.revision" value="1.0"/>
<property name="ivy.build.number" value="0"/>
<property name="ivy.build.number" value="1"/>
<property name="ivy.deliver.revision" value="${ivy.revision}"/>
<property name="ivy.pom.version" value="${ivy.revision}"/>

Expand Down

0 comments on commit 8f04117

Please sign in to comment.