diff --git a/library/src/main/java/foundation/icon/icx/data/BlockNotification.java b/library/src/main/java/foundation/icon/icx/data/BlockNotification.java index 46e5287..80142fe 100644 --- a/library/src/main/java/foundation/icon/icx/data/BlockNotification.java +++ b/library/src/main/java/foundation/icon/icx/data/BlockNotification.java @@ -21,6 +21,8 @@ import foundation.icon.icx.transport.jsonrpc.RpcObject; import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; public class BlockNotification { private final RpcObject properties; @@ -85,4 +87,20 @@ public static BigInteger[] asIntegerArray(RpcItem item) { public static BigInteger asInteger(RpcItem item) { return item != null ? item.asInteger() : null; } + + public List getLogs() { + RpcItem item = properties.getItem("logs"); + List eventLogs = new ArrayList<>(); + if (item != null) { + for (RpcItem rpcItem : item.asArray()) { + eventLogs.add(new TransactionResult.EventLog(rpcItem.asObject())); + } + } + return eventLogs; + } + + @Override + public String toString() { + return "BlockNotification{Properties="+properties+"}"; + } } diff --git a/library/src/main/java/foundation/icon/icx/data/EventNotification.java b/library/src/main/java/foundation/icon/icx/data/EventNotification.java index 29d0b96..c702a6b 100644 --- a/library/src/main/java/foundation/icon/icx/data/EventNotification.java +++ b/library/src/main/java/foundation/icon/icx/data/EventNotification.java @@ -21,6 +21,8 @@ import foundation.icon.icx.transport.jsonrpc.RpcObject; import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; public class EventNotification { private final RpcObject properties; @@ -59,4 +61,20 @@ public BigInteger[] getEvents() { public static BigInteger asInteger(RpcItem item) { return item != null ? item.asInteger() : null; } + + public List getLogs() { + RpcItem item = properties.getItem("logs"); + List eventLogs = new ArrayList<>(); + if (item != null) { + for (RpcItem rpcItem : item.asArray()) { + eventLogs.add(new TransactionResult.EventLog(rpcItem.asObject())); + } + } + return eventLogs; + } + + @Override + public String toString() { + return "EventNotification{Properties="+properties+"}"; + } }