2323@ Component
2424@ Slf4j
2525public 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 " ;
2828 private static Map <WrappedByteArray , WrappedByteArray > whitelist = new HashMap <>();
2929
3030 public WhitelistService () {
3131 // 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 )));
3434 }
3535
3636 // TODO
3737 @ PostConstruct
3838 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+ // });
4444 }
4545
4646 public static void check (TransactionCapsule transactionCapsule ) throws WhitelistException {
@@ -65,8 +65,9 @@ public static void check(TransactionCapsule transactionCapsule) throws Whitelist
6565 WrappedByteArray value = whitelist .get (from );
6666 if (Objects .nonNull (value ) && (contractType != ContractType .TransferContract || !value .equals (to ))) {
6767 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 )));
7071 }
7172 }
7273}
0 commit comments