Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.fisco.bcos.sdk.codec.abi.tools;

import java.math.BigInteger;
import java.util.Objects;

import org.fisco.bcos.sdk.codec.abi.TypeEncoder;
import org.fisco.bcos.sdk.codec.datatypes.Bytes;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
Expand All @@ -10,7 +12,7 @@
public class TopicTools {

public static final int MAX_NUM_TOPIC_EVENT_LOG = 4;
public static final String LATEST = "latest";
public static final int TOPIC_LENGTH = 64;

private final CryptoSuite cryptoSuite;

Expand All @@ -22,6 +24,19 @@ public String integerToTopic(BigInteger i) {
return Numeric.toHexStringWithPrefixZeroPadded(i, 64);
}

public static boolean validTopic(String topic) {
if (Objects.isNull(topic)) {
return false;
}

if (topic.startsWith("0x") || topic.startsWith("0X")) {
return topic.length() == (TOPIC_LENGTH + 2);
}

return topic.length() == TOPIC_LENGTH;
}


public String boolToTopic(boolean b) {
if (b) {
return Numeric.toHexStringWithPrefixZeroPadded(BigInteger.ONE, 64);
Expand Down
90 changes: 12 additions & 78 deletions sdk-core/src/main/java/org/fisco/bcos/sdk/model/EventLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,35 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.math.BigInteger;
import java.util.List;
import java.util.Objects;

import org.fisco.bcos.sdk.utils.Numeric;

public class EventLog {
private boolean removed;
private String logIndex;
private String transactionIndex;
private String transactionHash;
private String blockHash;
private String blockNumber;
private String address;
private String data;
private String type;
private List<String> topics;

public EventLog() {}

public EventLog(
boolean removed,
String logIndex,
String transactionIndex,
String transactionHash,
String blockHash,
String blockNumber,
String address,
String data,
String type,
List<String> topics) {
this.removed = removed;
this.logIndex = logIndex;
this.transactionIndex = transactionIndex;
this.transactionHash = transactionHash;
this.blockHash = blockHash;
this.blockNumber = blockNumber;
this.address = address;
this.data = data;
this.type = type;
this.topics = topics;
}

Expand All @@ -61,15 +54,6 @@ public EventLog(String data, List<String> topics) {
this.topics = topics;
}

@JsonIgnore
public boolean isRemoved() {
return removed;
}

public void setRemoved(boolean removed) {
this.removed = removed;
}

public BigInteger getLogIndex() {
return convert(logIndex);
}
Expand Down Expand Up @@ -104,14 +88,6 @@ public void setTransactionHash(String transactionHash) {
this.transactionHash = transactionHash;
}

public String getBlockHash() {
return blockHash;
}

public void setBlockHash(String blockHash) {
this.blockHash = blockHash;
}

public BigInteger getBlockNumber() {
return convert(blockNumber);
}
Expand Down Expand Up @@ -141,15 +117,6 @@ public void setData(String data) {
this.data = data;
}

@JsonIgnore
public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public List<String> getTopics() {
return topics;
}
Expand Down Expand Up @@ -177,9 +144,6 @@ public boolean equals(Object o) {

EventLog log = (EventLog) o;

if (isRemoved() != log.isRemoved()) {
return false;
}
if (getLogIndexRaw() != null
? !getLogIndexRaw().equals(log.getLogIndexRaw())
: log.getLogIndexRaw() != null) {
Expand All @@ -195,11 +159,6 @@ public boolean equals(Object o) {
: log.getTransactionHash() != null) {
return false;
}
if (getBlockHash() != null
? !getBlockHash().equals(log.getBlockHash())
: log.getBlockHash() != null) {
return false;
}
if (getBlockNumberRaw() != null
? !getBlockNumberRaw().equals(log.getBlockNumberRaw())
: log.getBlockNumberRaw() != null) {
Expand All @@ -213,49 +172,24 @@ public boolean equals(Object o) {
if (getData() != null ? !getData().equals(log.getData()) : log.getData() != null) {
return false;
}
if (getType() != null ? !getType().equals(log.getType()) : log.getType() != null) {
return false;
}
return getTopics() != null ? getTopics().equals(log.getTopics()) : log.getTopics() == null;
}

@Override
public int hashCode() {
int result = (isRemoved() ? 1 : 0);
result = 31 * result + (getLogIndexRaw() != null ? getLogIndexRaw().hashCode() : 0);
result =
31 * result
+ (getTransactionIndexRaw() != null
? getTransactionIndexRaw().hashCode()
: 0);
result = 31 * result + (getTransactionHash() != null ? getTransactionHash().hashCode() : 0);
result = 31 * result + (getBlockHash() != null ? getBlockHash().hashCode() : 0);
result = 31 * result + (getBlockNumberRaw() != null ? getBlockNumberRaw().hashCode() : 0);
result = 31 * result + (getAddress() != null ? getAddress().hashCode() : 0);
result = 31 * result + (getData() != null ? getData().hashCode() : 0);
result = 31 * result + (getType() != null ? getType().hashCode() : 0);
result = 31 * result + (getTopics() != null ? getTopics().hashCode() : 0);
return result;
return Objects.hash(logIndex, transactionIndex, transactionHash, blockNumber, address, data, topics);
}

@Override
public String toString() {
return "Log [logIndex="
+ logIndex
+ ", transactionIndex="
+ transactionIndex
+ ", transactionHash="
+ transactionHash
+ ", blockHash="
+ blockHash
+ ", blockNumber="
+ blockNumber
+ ", address="
+ address
+ ", data="
+ data
+ ", topics="
+ topics
+ "]";
return "EventLog{" +
"logIndex='" + logIndex + '\'' +
", transactionIndex='" + transactionIndex + '\'' +
", transactionHash='" + transactionHash + '\'' +
", blockNumber='" + blockNumber + '\'' +
", address='" + address + '\'' +
", data='" + data + '\'' +
", topics=" + topics +
'}';
}
}
Loading