Skip to content

Commit

Permalink
Merge pull request #22 from icon-project/mksong-support-logs-field-in…
Browse files Browse the repository at this point in the history
…-notifications

Support logs field in Block/EventNotification
  • Loading branch information
mksong76 authored Nov 2, 2023
2 parents c9ae14d + bf8e937 commit f593a09
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,4 +87,20 @@ public static BigInteger[] asIntegerArray(RpcItem item) {
public static BigInteger asInteger(RpcItem item) {
return item != null ? item.asInteger() : null;
}

public List<TransactionResult.EventLog> getLogs() {
RpcItem item = properties.getItem("logs");
List<TransactionResult.EventLog> 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+"}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -59,4 +61,20 @@ public BigInteger[] getEvents() {
public static BigInteger asInteger(RpcItem item) {
return item != null ? item.asInteger() : null;
}

public List<TransactionResult.EventLog> getLogs() {
RpcItem item = properties.getItem("logs");
List<TransactionResult.EventLog> 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+"}";
}
}

0 comments on commit f593a09

Please sign in to comment.