This repository has been archived by the owner on Jan 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-- do not store failed contracts bytecode -- fix contract creation error detection -- serialize numbers as string
- Loading branch information
1 parent
c2d26be
commit 0b13557
Showing
11 changed files
with
150 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ fun String.toSearchHashFormat(): String { | |
} | ||
return this | ||
} | ||
|
||
fun String.isEmptyHexValue() = this == "0x" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
package fund.cyber.search | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
import com.fasterxml.jackson.core.JsonGenerator | ||
import com.fasterxml.jackson.databind.DeserializationFeature | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module | ||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule | ||
import com.fasterxml.jackson.module.kotlin.registerKotlinModule | ||
|
||
val jsonSerializer = ObjectMapper().registerKotlinModule() | ||
.registerModule(Jdk8Module()) | ||
.registerModule(JavaTimeModule()) | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL)!! | ||
.registerModule(Jdk8Module()) | ||
.registerModule(JavaTimeModule()) | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL) | ||
.enable(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS)!! | ||
|
||
val jsonDeserializer = ObjectMapper().registerKotlinModule() | ||
.registerModule(Jdk8Module()) | ||
.registerModule(JavaTimeModule()) | ||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)!! | ||
.registerModule(Jdk8Module()) | ||
.registerModule(JavaTimeModule()) | ||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
common/src/main/kotlin/fund/cyber/search/model/ethereum/TxTrace.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
common/src/test/kotlin/fund/cyber/node/common/JsonSerializationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package fund.cyber.node.common | ||
|
||
import fund.cyber.search.jsonDeserializer | ||
import fund.cyber.search.jsonSerializer | ||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.DisplayName | ||
import org.junit.jupiter.api.Test | ||
import java.math.BigDecimal | ||
|
||
@DisplayName("Json serialization/deserialization test") | ||
class JsonSerializationTest { | ||
|
||
@Test | ||
@DisplayName("should BigDecimal serialized to Json string") | ||
fun testBigDecimalShouldBeSerializedAsJsonString() { | ||
|
||
val valueAsString = "0.32784291897287934505879230273459823424" | ||
val classWithMoney = ClassWithMoney(BigDecimal(valueAsString)) | ||
val classAsString = jsonSerializer.writeValueAsString(classWithMoney) | ||
val deserializedClass = jsonDeserializer.readValue(classAsString, ClassWithMoney::class.java) | ||
|
||
Assertions.assertEquals("""{"money":"0.32784291897287934505879230273459823424"}""", classAsString) | ||
Assertions.assertEquals(classWithMoney, deserializedClass) | ||
} | ||
} | ||
|
||
|
||
private data class ClassWithMoney( | ||
val money: BigDecimal | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters