Skip to content

Commit

Permalink
1. Solidity generator: fixed issue where no-arg constructor functions…
Browse files Browse the repository at this point in the history
… were not being generated correctly.

 2. Updated Solidity generator.
 3. Added logic to test for file existence with wallet tools before asking for password.
 4. Fixed bug in wallet file generator where 12 hour clocks we being used in filename.
 5. Bumped version.
  • Loading branch information
conor10 committed Nov 10, 2016
1 parent 498d242 commit 03cc9c5
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 14 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ Maven
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
Gradle
------

.. code-block:: groovy
compile ('org.web3j:core:1.0.3')
compile ('org.web3j:core:1.0.4')
Start a client
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'application'

group 'org.web3j'
version '1.0.3'
version '1.0.4'

sourceCompatibility = 1.8

Expand Down
4 changes: 2 additions & 2 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ Maven
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>1.0.3</version>
<version>1.0.4</version>
</dependency>
Gradle
------

.. code-block:: groovy
compile ('org.web3j:core:1.0.3')
compile ('org.web3j:core:1.0.4')
Start a client
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.web3j.protocol.core.methods.response.AbiDefinition;
import org.web3j.protocol.core.methods.response.TransactionReceipt;

import static org.web3j.utils.Collection.tail;

/**
* Java wrapper source code generator for Solidity ABI format.
*/
Expand All @@ -43,7 +45,7 @@ public class SolidityFunctionWrapperGenerator extends Generator {
"Please use {@link " + SolidityFunctionWrapperGenerator.class.getName() +
"} to update.</p>\n";

private static final String USAGE = "solidity " +
private static final String USAGE = "solidity generate " +
"<input binary file>.bin <input abi file>.abi " +
"[-p|--package <base package name>] " +
"-o|--output <destination base directory>";
Expand All @@ -65,6 +67,14 @@ private SolidityFunctionWrapperGenerator(
this.basePackageName = basePackageName;
}

public static void run(String[] args) throws Exception {
if (args.length < 1 || !args[0].equals("generate")) {
exitError(USAGE);
} else {
main(tail(args));
}
}

public static void main(String[] args) throws Exception {

if (args.length != 6) {
Expand Down Expand Up @@ -244,11 +254,12 @@ private static MethodSpec buildDeploy(
"$T.asList($L)" +
")",
String.class, FunctionEncoder.class, Arrays.class, inputParams);
methodBuilder.addStatement("return deployAsync($L.class, $L, $L, $L, encodedConstructor, $L)",
className, WEB3J, CREDENTIALS, BINARY, INITIAL_VALUE);
} else {
methodBuilder.addStatement("return deployAsync($L.class, $L, $L, $L, \"\", $L)",
className, WEB3J, CREDENTIALS, BINARY, INITIAL_VALUE);
}

methodBuilder.addStatement("return deployAsync($L.class, $L, $L, $L, encodedConstructor, $L)",
className, WEB3J, CREDENTIALS, BINARY, INITIAL_VALUE);

return methodBuilder.build();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/web3j/console/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public static void main(String[] args) throws Exception {
} else {
switch (args[0]) {
case "wallet":
WalletRunner.main(tail(args));
WalletRunner.run(tail(args));
break;
case "solidity":
SolidityFunctionWrapperGenerator.main(tail(args));
SolidityFunctionWrapperGenerator.run(tail(args));
break;
default:
Console.exitError(USAGE);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/org/web3j/console/WalletManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ File createDir(String destinationDir) {
}

Credentials getCredentials(File walletFile) {
if (!walletFile.exists() || !walletFile.isFile()) {
exitError("Unable to read wallet file: " + walletFile);
}
return loadWalletFile(walletFile);
}

private Credentials loadWalletFile(File walletFile) {
while (true) {
char[] password = console.readPassword(
"Please enter your existing your wallet file password: ");
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/web3j/console/WalletRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
public class WalletRunner {
private static final String USAGE = "wallet create|update|send";

public static void run(String[] args) {
main(args);
}

public static void main(String[] args) {
if (args.length < 1) {
Console.exitError(USAGE);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/web3j/console/WalletUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void run(String walletFileLocation) {
if (!walletFile.delete()) {
exitError("Unable to remove wallet file\n");
} else {
console.printf("File successfully removed\n");
console.printf("Deleted previous wallet file: %s\n", walletFile.getName());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/web3j/crypto/WalletUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public static Credentials loadCredentials(String password, File source)

private static String getWalletFileName(WalletFile walletFile) {
DateTimeFormatter format = DateTimeFormatter.ofPattern(
"'UTC--'yyyy-MM-dd'T'hh-mm-ss.nVV'--'");
"'UTC--'yyyy-MM-dd'T'HH-mm-ss.nVV'--'");
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);

return now.format(format) + walletFile.getAddress() + ".json";
Expand Down

0 comments on commit 03cc9c5

Please sign in to comment.