23
23
@ Component
24
24
@ Slf4j
25
25
public class WhitelistService {
26
- private final static String TEST_FROM = "" ;
27
- private final static String TEST_TO = "" ;
26
+ private final static String TEST_FROM = "41ceee995c01c9bb7d720f9013336363cdc7c8c4d8 " ;
27
+ private final static String TEST_TO = "41216352a10649ffc3e37ba492feb0c35b3b6258e0 " ;
28
28
private static Map <WrappedByteArray , WrappedByteArray > whitelist = new HashMap <>();
29
29
30
30
public WhitelistService () {
31
31
// test
32
- // whitelist.put(WrappedByteArray.of(ByteArray.fromHexString(TEST_FROM)),
33
- // WrappedByteArray.of(ByteArray.fromHexString(TEST_TO)));
32
+ whitelist .put (WrappedByteArray .of (ByteArray .fromHexString (TEST_FROM )),
33
+ WrappedByteArray .of (ByteArray .fromHexString (TEST_TO )));
34
34
}
35
35
36
36
// TODO
37
37
@ PostConstruct
38
38
public void loadFromConfig () {
39
- Args .getInstance ().getBlacklist ().forEach ((k , v ) -> {
40
- WrappedByteArray key = WrappedByteArray .of (ByteArray .fromHexString (k ));
41
- WrappedByteArray value = WrappedByteArray .of (ByteArray .fromHexString (v ));
42
- whitelist .put (key , value );
43
- });
39
+ // Args.getInstance().getBlacklist().forEach((k, v) -> {
40
+ // WrappedByteArray key = WrappedByteArray.of(ByteArray.fromHexString(k));
41
+ // WrappedByteArray value = WrappedByteArray.of(ByteArray.fromHexString(v));
42
+ // whitelist.put(key, value);
43
+ // });
44
44
}
45
45
46
46
public static void check (TransactionCapsule transactionCapsule ) throws WhitelistException {
@@ -65,8 +65,9 @@ public static void check(TransactionCapsule transactionCapsule) throws Whitelist
65
65
WrappedByteArray value = whitelist .get (from );
66
66
if (Objects .nonNull (value ) && (contractType != ContractType .TransferContract || !value .equals (to ))) {
67
67
throw new WhitelistException ("Not the specified address. "
68
- + "from:" + Wallet .encode58Check (fromAddress )
69
- + ", to:" + Wallet .encode58Check (toAddress ));
68
+ + "contractType: " + contractType
69
+ + ", from:" + Wallet .encode58Check (fromAddress )
70
+ + ", to:" + (toAddress == null ? null : Wallet .encode58Check (toAddress )));
70
71
}
71
72
}
72
73
}
0 commit comments