Skip to content

Commit

Permalink
Merge pull request #76 from iikirilov/default-wallet-pass
Browse files Browse the repository at this point in the history
final cleanup
  • Loading branch information
iikirilov authored Aug 18, 2020
2 parents 1901ad7 + 08de435 commit 7ab30e6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
5 changes: 5 additions & 0 deletions src/main/java/io/epirus/console/EpirusCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ private void maybeCreateDefaultWallet() {
config.setDefaultWalletPath(walletPath);
config.setDefaultWalletPassword(walletPassword);
}

if (config.getDefaultWalletPassword() == null) {
// default wallet password was introduced in v1.2.0
config.setDefaultWalletPassword("");
}
}

private void performTelemetryUpload() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private String[] getWalletEnvironment(
"-v",
walletPath.getParent().toAbsolutePath().toString() + ":/root/key");

if (walletPassword != null) {
if (!walletPassword.isEmpty()) {
return ArrayUtils.addAll(
walletArgs,
"--env",
Expand Down
38 changes: 16 additions & 22 deletions src/main/java/io/epirus/console/run/RunCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private Credentials createCredentials() throws IOException, CipherException {
}

public void deploy() throws Exception {
coloredPrinter.println("Preparing to deploy your Web3App");
coloredPrinter.println("Preparing to run your Web3App");
System.out.print(System.lineSeparator());
AccountUtils.accountInit(accountService);
if (accountService.checkIfAccountIsConfirmed(20)) {
Expand Down Expand Up @@ -232,21 +232,7 @@ private void runGradle(Path runLocation) throws Exception {
private void executeProcess(File workingDir, String[] command) throws Exception {
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.environment().put("DEPLOY_NETWORK", network.getNetworkName());
processBuilder
.environment()
.putIfAbsent(
"WEB3J_WALLET_PATH",
credentialsOptions.getWalletPath() == null
? config.getDefaultWalletPath()
: credentialsOptions.getWalletPath().toString());
processBuilder
.environment()
.putIfAbsent(
"WEB3J_WALLET_PASSWORD",
credentialsOptions.getWalletPath() == null
? config.getDefaultWalletPassword()
: credentialsOptions.getWalletPassword());
setOpenAPIEnvironment(processBuilder);
setEnvironment(processBuilder);

int exitCode =
processBuilder
Expand All @@ -268,27 +254,35 @@ private void executeProcess(File workingDir, String[] command) throws Exception
}
}

private void setOpenAPIEnvironment(final ProcessBuilder processBuilder) {
private void setEnvironment(final ProcessBuilder processBuilder) {
if (credentialsOptions.getWalletPath() != null) {
processBuilder
.environment()
.putIfAbsent(
"WEB3J_WALLET_PATH", credentialsOptions.getWalletPath().toString());
} else if (credentialsOptions.getRawKey() != null) {
if (credentialsOptions.getWalletPassword() != null) {
processBuilder
.environment()
.putIfAbsent(
"WEB3J_WALLET_PASSWORD", credentialsOptions.getWalletPassword());
}
} else if (!credentialsOptions.getRawKey().isEmpty()) {
processBuilder
.environment()
.putIfAbsent("WEB3J_PRIVATE_KEY", credentialsOptions.getRawKey());
} else if (credentialsOptions.getJson() != null) {
} else if (!credentialsOptions.getJson().isEmpty()) {
processBuilder
.environment()
.putIfAbsent("WEB3J_WALLET_JSON", credentialsOptions.getJson());
} else {
processBuilder
.environment()
.putIfAbsent("WEB3J_WALLET_PATH", config.getDefaultWalletPath());
processBuilder
.environment()
.putIfAbsent("WEB3J_WALLET_PASSWORD", config.getDefaultWalletPassword());
if (!config.getDefaultWalletPassword().isEmpty()) {
processBuilder
.environment()
.putIfAbsent("WEB3J_WALLET_PASSWORD", config.getDefaultWalletPassword());
}
}
processBuilder.environment().putIfAbsent("WEB3J_NETWORK", network.getNetworkName());
processBuilder.environment().putIfAbsent("WEB3J_PORT", Integer.toString(9090));
Expand Down

0 comments on commit 7ab30e6

Please sign in to comment.