Skip to content

Commit f593a09

Browse files
authored
Merge pull request #22 from icon-project/mksong-support-logs-field-in-notifications
Support logs field in Block/EventNotification
2 parents c9ae14d + bf8e937 commit f593a09

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

library/src/main/java/foundation/icon/icx/data/BlockNotification.java

+18
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import foundation.icon.icx.transport.jsonrpc.RpcObject;
2222

2323
import java.math.BigInteger;
24+
import java.util.ArrayList;
25+
import java.util.List;
2426

2527
public class BlockNotification {
2628
private final RpcObject properties;
@@ -85,4 +87,20 @@ public static BigInteger[] asIntegerArray(RpcItem item) {
8587
public static BigInteger asInteger(RpcItem item) {
8688
return item != null ? item.asInteger() : null;
8789
}
90+
91+
public List<TransactionResult.EventLog> getLogs() {
92+
RpcItem item = properties.getItem("logs");
93+
List<TransactionResult.EventLog> eventLogs = new ArrayList<>();
94+
if (item != null) {
95+
for (RpcItem rpcItem : item.asArray()) {
96+
eventLogs.add(new TransactionResult.EventLog(rpcItem.asObject()));
97+
}
98+
}
99+
return eventLogs;
100+
}
101+
102+
@Override
103+
public String toString() {
104+
return "BlockNotification{Properties="+properties+"}";
105+
}
88106
}

library/src/main/java/foundation/icon/icx/data/EventNotification.java

+18
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import foundation.icon.icx.transport.jsonrpc.RpcObject;
2222

2323
import java.math.BigInteger;
24+
import java.util.ArrayList;
25+
import java.util.List;
2426

2527
public class EventNotification {
2628
private final RpcObject properties;
@@ -59,4 +61,20 @@ public BigInteger[] getEvents() {
5961
public static BigInteger asInteger(RpcItem item) {
6062
return item != null ? item.asInteger() : null;
6163
}
64+
65+
public List<TransactionResult.EventLog> getLogs() {
66+
RpcItem item = properties.getItem("logs");
67+
List<TransactionResult.EventLog> eventLogs = new ArrayList<>();
68+
if (item != null) {
69+
for (RpcItem rpcItem : item.asArray()) {
70+
eventLogs.add(new TransactionResult.EventLog(rpcItem.asObject()));
71+
}
72+
}
73+
return eventLogs;
74+
}
75+
76+
@Override
77+
public String toString() {
78+
return "EventNotification{Properties="+properties+"}";
79+
}
6280
}

0 commit comments

Comments
 (0)