Skip to content

Commit 03cc9c5

Browse files
committed
1. Solidity generator: fixed issue where no-arg constructor functions 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.
1 parent 498d242 commit 03cc9c5

9 files changed

+36
-14
lines changed

README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ Maven
6969
<dependency>
7070
<groupId>org.web3j</groupId>
7171
<artifactId>core</artifactId>
72-
<version>1.0.3</version>
72+
<version>1.0.4</version>
7373
</dependency>
7474
7575
Gradle
7676
------
7777

7878
.. code-block:: groovy
7979
80-
compile ('org.web3j:core:1.0.3')
80+
compile ('org.web3j:core:1.0.4')
8181
8282
8383
Start a client

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
2626
apply plugin: 'application'
2727

2828
group 'org.web3j'
29-
version '1.0.3'
29+
version '1.0.4'
3030

3131
sourceCompatibility = 1.8
3232

docs/source/getting_started.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ Maven
1111
<dependency>
1212
<groupId>org.web3j</groupId>
1313
<artifactId>core</artifactId>
14-
<version>1.0.3</version>
14+
<version>1.0.4</version>
1515
</dependency>
1616
1717
Gradle
1818
------
1919

2020
.. code-block:: groovy
2121
22-
compile ('org.web3j:core:1.0.3')
22+
compile ('org.web3j:core:1.0.4')
2323
2424
2525
Start a client

src/main/java/org/web3j/codegen/SolidityFunctionWrapperGenerator.java

+16-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import org.web3j.protocol.core.methods.response.AbiDefinition;
2828
import org.web3j.protocol.core.methods.response.TransactionReceipt;
2929

30+
import static org.web3j.utils.Collection.tail;
31+
3032
/**
3133
* Java wrapper source code generator for Solidity ABI format.
3234
*/
@@ -43,7 +45,7 @@ public class SolidityFunctionWrapperGenerator extends Generator {
4345
"Please use {@link " + SolidityFunctionWrapperGenerator.class.getName() +
4446
"} to update.</p>\n";
4547

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

70+
public static void run(String[] args) throws Exception {
71+
if (args.length < 1 || !args[0].equals("generate")) {
72+
exitError(USAGE);
73+
} else {
74+
main(tail(args));
75+
}
76+
}
77+
6878
public static void main(String[] args) throws Exception {
6979

7080
if (args.length != 6) {
@@ -244,11 +254,12 @@ private static MethodSpec buildDeploy(
244254
"$T.asList($L)" +
245255
")",
246256
String.class, FunctionEncoder.class, Arrays.class, inputParams);
257+
methodBuilder.addStatement("return deployAsync($L.class, $L, $L, $L, encodedConstructor, $L)",
258+
className, WEB3J, CREDENTIALS, BINARY, INITIAL_VALUE);
259+
} else {
260+
methodBuilder.addStatement("return deployAsync($L.class, $L, $L, $L, \"\", $L)",
261+
className, WEB3J, CREDENTIALS, BINARY, INITIAL_VALUE);
247262
}
248-
249-
methodBuilder.addStatement("return deployAsync($L.class, $L, $L, $L, encodedConstructor, $L)",
250-
className, WEB3J, CREDENTIALS, BINARY, INITIAL_VALUE);
251-
252263
return methodBuilder.build();
253264
}
254265

src/main/java/org/web3j/console/Runner.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public static void main(String[] args) throws Exception {
3030
} else {
3131
switch (args[0]) {
3232
case "wallet":
33-
WalletRunner.main(tail(args));
33+
WalletRunner.run(tail(args));
3434
break;
3535
case "solidity":
36-
SolidityFunctionWrapperGenerator.main(tail(args));
36+
SolidityFunctionWrapperGenerator.run(tail(args));
3737
break;
3838
default:
3939
Console.exitError(USAGE);

src/main/java/org/web3j/console/WalletManager.java

+7
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ File createDir(String destinationDir) {
7070
}
7171

7272
Credentials getCredentials(File walletFile) {
73+
if (!walletFile.exists() || !walletFile.isFile()) {
74+
exitError("Unable to read wallet file: " + walletFile);
75+
}
76+
return loadWalletFile(walletFile);
77+
}
78+
79+
private Credentials loadWalletFile(File walletFile) {
7380
while (true) {
7481
char[] password = console.readPassword(
7582
"Please enter your existing your wallet file password: ");

src/main/java/org/web3j/console/WalletRunner.java

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
public class WalletRunner {
1111
private static final String USAGE = "wallet create|update|send";
1212

13+
public static void run(String[] args) {
14+
main(args);
15+
}
16+
1317
public static void main(String[] args) {
1418
if (args.length < 1) {
1519
Console.exitError(USAGE);

src/main/java/org/web3j/console/WalletUpdater.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private void run(String walletFileLocation) {
4848
if (!walletFile.delete()) {
4949
exitError("Unable to remove wallet file\n");
5050
} else {
51-
console.printf("File successfully removed\n");
51+
console.printf("Deleted previous wallet file: %s\n", walletFile.getName());
5252
}
5353
}
5454
}

src/main/java/org/web3j/crypto/WalletUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static Credentials loadCredentials(String password, File source)
5555

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

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

0 commit comments

Comments
 (0)