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 Original file line number Diff line number Diff line change 12
12
13
13
public class ERC20Call {
14
14
15
- public Base decode (HexData input ) {
15
+ public static Base decode (HexData input ) {
16
16
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 ())) {
19
23
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 {
22
31
throw new IllegalStateException ("Unsupported method: " + methodId );
23
32
}
24
33
parsed .decode (input );
@@ -50,7 +59,7 @@ public void verifyMethod(HexData input) {
50
59
throw new IllegalArgumentException ("Empty or short methodId" );
51
60
}
52
61
MethodId methodId = MethodId .fromInput (input );
53
- if (methodId != getMethod ().getMethodId ()) {
62
+ if (! methodId . equals ( getMethod ().getMethodId () )) {
54
63
throw new IllegalArgumentException ("Invalid method id: " + methodId + " != " + getMethod ().getMethodId ());
55
64
}
56
65
}
You can’t perform that action at this time.
0 commit comments