Skip to content

Commit

Permalink
rename BalanceOpCommand (#820)
Browse files Browse the repository at this point in the history
  • Loading branch information
wenlinlee authored Jan 30, 2024
1 parent 8f6ff7c commit 5c5d1a2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 36 deletions.
26 changes: 12 additions & 14 deletions src/main/java/console/command/category/BalanceOpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,33 +50,31 @@ public class BalanceOpCommand extends BasicCategoryCommand {
4);
public static final CommandInfo REGISTER_CALLER =
new CommandInfo(
"registerCaller",
"Register caller to the account",
HelpInfo::registerBalancePrecompiledCallerHelp,
"registerBalanceGovernor",
"Register the account to balanceGovernor",
HelpInfo::registerBalanceGovernorHelp,
(consoleInitializer, params, pwd) ->
consoleInitializer
.getPrecompiledFace()
.registerBalancePrecompiledCaller(params),
consoleInitializer.getPrecompiledFace().registerBalanceGovernor(params),
1,
1);
public static final CommandInfo UNREGISTER_CALLER =
new CommandInfo(
"unregisterCaller",
"Unregister caller from the account",
HelpInfo::unregisterBalancePrecompiledCallerHelp,
"unregisterBalanceGovernor",
"Unregister the account from balanceGovernor",
HelpInfo::unregisterBalanceGovernorHelp,
(consoleInitializer, params, pwd) ->
consoleInitializer
.getPrecompiledFace()
.unregisterBalancePrecompiledCaller(params),
.unregisterBalanceGovernor(params),
1,
1);
public static final CommandInfo LIST_CALLER =
new CommandInfo(
"listCaller",
"List all registered callers of balancePrecompiled",
HelpInfo::listCallerHelp,
"listBalanceGovernor",
"List all registered balanceGovernor",
HelpInfo::listBalanceGovernorHelp,
(consoleInitializer, params, pwd) ->
consoleInitializer.getPrecompiledFace().listCaller(),
consoleInitializer.getPrecompiledFace().listBalanceGovernor(),
0,
0);

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/console/command/model/HelpInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -507,25 +507,25 @@ public static void transferBalanceHelp() {
"[Note]: 1 ether = 10^18 wei = 10^15 kwei = 10^12 mwei = 10^9 gwei = 10^6 szabo = 10^3 finney");
}

public static void registerBalancePrecompiledCallerHelp() {
System.out.println("Register caller to the specified account");
System.out.println("Usage: \nregisterCaller accountAddress");
public static void registerBalanceGovernorHelp() {
System.out.println("Register the specified account to balanceGovernor");
System.out.println("Usage: \nregisterBalanceGovernor accountAddress");
System.out.println("* accountAddress -- The address of the account.");
System.out.println("[Note]: The caller must be a contract address.");
System.out.println("[Note]: The request initiator account must be governor.");
}

public static void unregisterBalancePrecompiledCallerHelp() {
System.out.println("Unregister caller from the specified account");
System.out.println("Usage: \nunregisterCaller accountAddress");
public static void unregisterBalanceGovernorHelp() {
System.out.println("Unregister the specified account from balanceGovernor");
System.out.println("Usage: \nunregisterBalanceGovernor to accountAddress");
System.out.println("* accountAddress -- The address of the account.");
System.out.println("[Note]: The caller must be a contract address.");
System.out.println("[Note]: The request initiator account must be governor.");
}

public static void listCallerHelp() {
System.out.println("List all registered balancePrecompiled caller.");
System.out.println("Usage: listCaller");
public static void listBalanceGovernorHelp() {
System.out.println("List all registered balanceGovernor.");
System.out.println("Usage: listBalanceGovernor");
}

public static void startHelp() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/console/precompiled/PrecompiledFace.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ void setSystemConfigByKey(ConsoleInitializer consoleInitializer, String[] params

void transferBalance(String[] params) throws Exception;

void registerBalancePrecompiledCaller(String[] params) throws Exception;
void registerBalanceGovernor(String[] params) throws Exception;

void unregisterBalancePrecompiledCaller(String[] params) throws Exception;
void unregisterBalanceGovernor(String[] params) throws Exception;

void listCaller() throws Exception;
void listBalanceGovernor() throws Exception;

String getPwd();
}
20 changes: 10 additions & 10 deletions src/main/java/console/precompiled/PrecompiledImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -832,41 +832,41 @@ public void transferBalance(String[] params) throws Exception {
}

@Override
public void registerBalancePrecompiledCaller(String[] params) throws Exception {
public void registerBalanceGovernor(String[] params) throws Exception {
String address = params[1];
RetCode retCode = this.balanceService.registerCaller(address);

logger.info("registerCaller: {}, retCode {}", address, retCode);
logger.info("registerBalanceGovernor: {}, retCode {}", address, retCode);
// parse the result
if (retCode == PrecompiledRetCode.CODE_SUCCESS) {
System.out.println(
"transaction hash:" + retCode.getTransactionReceipt().getTransactionHash());
System.out.println("register caller " + address + " success.");
System.out.println("register balanceGovernor " + address + " success.");
} else {
System.out.println("register caller " + address + " failed. ");
System.out.println("register balanceGovernor " + address + " failed. ");
}
}

@Override
public void unregisterBalancePrecompiledCaller(String[] params) throws Exception {
public void unregisterBalanceGovernor(String[] params) throws Exception {
String address = params[1];
RetCode retCode = this.balanceService.unregisterCaller(address);

logger.info("unregisterCaller: {}, retCode {}", address, retCode);
logger.info("unregisterBalanceGovernor: {}, retCode {}", address, retCode);
// parse the result
if (retCode == PrecompiledRetCode.CODE_SUCCESS) {
System.out.println(
"transaction hash:" + retCode.getTransactionReceipt().getTransactionHash());
System.out.println("unregister caller " + address + " success.");
System.out.println("unregister balanceGovernor " + address + " success.");
} else {
System.out.println("unregister caller " + address + " failed.");
System.out.println("unregister balanceGovernor " + address + " failed.");
}
}

@Override
public void listCaller() throws Exception {
public void listBalanceGovernor() throws Exception {
List<String> result = this.balanceService.listCaller();
System.out.println("list caller: " + result.toString());
System.out.println("listBalanceGovernor: " + result.toString());
}

@Override
Expand Down

0 comments on commit 5c5d1a2

Please sign in to comment.