Skip to content

Commit bbadea9

Browse files
committed
problem: == instead of equals; not all methods are defined for encoding
1 parent 8c5a600 commit bbadea9

File tree

1 file changed

+15
-6
lines changed
  • etherjar-erc20/src/main/java/io/infinitape/etherjar/erc20

1 file changed

+15
-6
lines changed

Diff for: etherjar-erc20/src/main/java/io/infinitape/etherjar/erc20/ERC20Call.java

+15-6
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@
1212

1313
public class ERC20Call {
1414

15-
public Base decode(HexData input) {
15+
public static Base decode(HexData input) {
1616
MethodId methodId = MethodId.fromInput(input);
17-
Base parsed = null;
18-
if (methodId == ERC20Method.BALANCE_OF.getMethodId()) {
17+
Base parsed;
18+
if (methodId.equals(ERC20Method.ALLOWANCE.getMethodId())) {
19+
parsed = new Allowance();
20+
} else if (methodId.equals(ERC20Method.APPROVE.getMethodId())) {
21+
parsed = new Approve();
22+
} else if (methodId.equals(ERC20Method.BALANCE_OF.getMethodId())) {
1923
parsed = new BalanceOf();
20-
}
21-
if (parsed == null) {
24+
} else if (methodId.equals(ERC20Method.TOTAL_SUPPLY.getMethodId())) {
25+
parsed = new TotalSupply();
26+
} else if (methodId.equals(ERC20Method.TRANSFER.getMethodId())) {
27+
parsed = new Transfer();
28+
} else if (methodId.equals(ERC20Method.TRANSFER_FROM.getMethodId())) {
29+
parsed = new TransferFrom();
30+
} else {
2231
throw new IllegalStateException("Unsupported method: " + methodId);
2332
}
2433
parsed.decode(input);
@@ -50,7 +59,7 @@ public void verifyMethod(HexData input) {
5059
throw new IllegalArgumentException("Empty or short methodId");
5160
}
5261
MethodId methodId = MethodId.fromInput(input);
53-
if (methodId != getMethod().getMethodId()) {
62+
if (!methodId.equals(getMethod().getMethodId())) {
5463
throw new IllegalArgumentException("Invalid method id: " + methodId + " != " + getMethod().getMethodId());
5564
}
5665
}

0 commit comments

Comments
 (0)