remove etherjar dependency
This commit is contained in:
@@ -79,8 +79,6 @@ dependencies {
|
||||
}
|
||||
implementation libs.brave.instrumentation.grpc
|
||||
|
||||
implementation libs.bundles.etherjar
|
||||
|
||||
implementation libs.logstash.encoder
|
||||
|
||||
implementation libs.janino
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
[versions]
|
||||
detekt = "1.23.1"
|
||||
etherjar = "0.11.1"
|
||||
groovy = "4.0.15"
|
||||
protoc = "3.21.7"
|
||||
jackson = "2.11.0"
|
||||
@@ -37,15 +36,6 @@ detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting",
|
||||
|
||||
equals-verifier = "nl.jqno.equalsverifier:equalsverifier:3.10.1"
|
||||
|
||||
etherjar-domain = { module = "io.emeraldpay.etherjar:etherjar-domain", version.ref = "etherjar" }
|
||||
etherjar-hex = { module = "io.emeraldpay.etherjar:etherjar-hex", version.ref = "etherjar" }
|
||||
etherjar-rpc-api = { module = "io.emeraldpay.etherjar:etherjar-rpc-api", version.ref = "etherjar" }
|
||||
etherjar-rpc-http = { module = "io.emeraldpay.etherjar:etherjar-rpc-http", version.ref = "etherjar" }
|
||||
etherjar-rpc-ws = { module = "io.emeraldpay.etherjar:etherjar-rpc-ws", version.ref = "etherjar" }
|
||||
etherjar-tx = { module = "io.emeraldpay.etherjar:etherjar-tx", version.ref = "etherjar" }
|
||||
etherjar-contract = { module = "io.emeraldpay.etherjar:etherjar-contract", version.ref = "etherjar" }
|
||||
etherjar-erc20 = { module = "io.emeraldpay.etherjar:etherjar-erc20", version.ref = "etherjar" }
|
||||
|
||||
groovy = { module = "org.apache.groovy:groovy", version.ref = "groovy" }
|
||||
|
||||
grpc-proto-util = { module = "com.google.protobuf:protobuf-java-util", version.ref = "protoc" }
|
||||
@@ -132,7 +122,6 @@ mockito-inline = "org.mockito:mockito-inline:4.0.0"
|
||||
|
||||
[bundles]
|
||||
apache-commons = ["commons-io", "apache-commons-lang3", "apache-commons-collections4"]
|
||||
etherjar = ["etherjar-domain", "etherjar-hex", "etherjar-rpc-api", "etherjar-rpc-http", "etherjar-rpc-ws", "etherjar-tx", "etherjar-contract", "etherjar-erc20"]
|
||||
grpc = ["grpc-protobuf", "grpc-stub", "grpc-netty", "grpc-proto-util", "grpc-services"]
|
||||
httpcomponents = ["httpcomponents-httpmime", "httpcomponents-httpclient"]
|
||||
jackson = ["jackson-core", "jackson-databind", "jackson-datatype-jdk8", "jackson-datatype-jsr310", "jackson-module-kotlin"]
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.domain;
|
||||
|
||||
import io.emeraldpay.etherjar.hex.Hex32;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
import org.bouncycastle.jcajce.provider.digest.Keccak;
|
||||
import org.bouncycastle.util.encoders.Hex;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.domain;
|
||||
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
public class BlockHash extends HexData {
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.domain;
|
||||
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
import org.bouncycastle.jcajce.provider.digest.Keccak;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.domain;
|
||||
|
||||
import io.emeraldpay.etherjar.hex.Hex32;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
import org.bouncycastle.jcajce.provider.digest.Keccak;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.domain;
|
||||
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
/**
|
||||
* An address, followed by a function selector.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.domain;
|
||||
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
import org.bouncycastle.jcajce.provider.digest.Keccak;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.domain;
|
||||
|
||||
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
public class Nonce extends HexData {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.domain;
|
||||
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
/**
|
||||
* Transaction Hash value
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.domain;
|
||||
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 2020 EmeraldPay Inc, All Rights Reserved.
|
||||
* Copyright (c) 2016-2017 Infinitape Inc, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.hex;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Fixed-size 32-bytes hex value.
|
||||
*/
|
||||
public class Hex32 extends HexData {
|
||||
|
||||
// 0x1000 > MAX_NUMBER
|
||||
private static final BigInteger NUMBER_LIMIT = BigInteger.valueOf(2).pow(256);
|
||||
// 0xffff.... as for 256-bit value
|
||||
private static final BigInteger MAX_NUMBER = NUMBER_LIMIT.subtract(BigInteger.ONE);
|
||||
|
||||
public static final int SIZE_BYTES = 32;
|
||||
public static final int SIZE_HEX = 2 + SIZE_BYTES * 2;
|
||||
|
||||
/**
|
||||
* Use {@link Hex32#empty()}
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Hex32 EMPTY =
|
||||
Hex32.from("0x0000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
public static Hex32 from(HexData data) {
|
||||
if (data instanceof Hex32)
|
||||
return (Hex32) data;
|
||||
|
||||
if (data.getSize() != Hex32.SIZE_BYTES)
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Data length is not %d: %d", Hex32.SIZE_BYTES, data.getSize()));
|
||||
|
||||
return from(data.getBytes());
|
||||
}
|
||||
|
||||
public Hex32(byte[] value) {
|
||||
super(value, SIZE_BYTES);
|
||||
}
|
||||
|
||||
public static Hex32 from(byte[] value) {
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Null Hex32");
|
||||
}
|
||||
if (value.length != SIZE_BYTES) {
|
||||
throw new IllegalArgumentException("Invalid Hex32 length: " + value.length);
|
||||
}
|
||||
return new Hex32(value);
|
||||
}
|
||||
|
||||
public static Hex32 from(String value) {
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Null Hex32");
|
||||
}
|
||||
if (value.length() != SIZE_HEX) {
|
||||
throw new IllegalArgumentException("Invalid Hex32 length: " + value.length());
|
||||
}
|
||||
return new Hex32(HexData.from(value).getBytes());
|
||||
}
|
||||
|
||||
public static Hex32 empty() {
|
||||
return new Hex32(new byte[SIZE_BYTES]);
|
||||
}
|
||||
|
||||
public static Hex32 extendFrom(HexData value) {
|
||||
return extendFrom(value.getBytes());
|
||||
}
|
||||
|
||||
public static Hex32 extendFrom(HexQuantity value) {
|
||||
if (value.getValue().signum() < 0) {
|
||||
// use .add() because it's already negative
|
||||
BigInteger asNegative = MAX_NUMBER.add(value.getValue()).add(BigInteger.ONE);
|
||||
|
||||
byte[] bytesAll = asNegative.toByteArray();
|
||||
// usually it have a 0-byte prefix and we need to remove it
|
||||
if (bytesAll[0] == 0) {
|
||||
byte[] bytesClean = new byte[bytesAll.length - 1];
|
||||
System.arraycopy(bytesAll, 1, bytesClean, 0, bytesClean.length);
|
||||
|
||||
return extendFrom(bytesClean);
|
||||
} else {
|
||||
return extendFrom(bytesAll);
|
||||
}
|
||||
}
|
||||
return extendFrom(value.asData());
|
||||
}
|
||||
|
||||
public static Hex32 extendFrom(Long value) {
|
||||
return extendFrom(HexQuantity.from(value));
|
||||
}
|
||||
|
||||
public static Hex32 extendFrom(BigInteger value) {
|
||||
return extendFrom(HexQuantity.from(value));
|
||||
}
|
||||
|
||||
public static Hex32 extendFrom(byte[] value) {
|
||||
if (value.length > SIZE_BYTES) {
|
||||
throw new IllegalArgumentException("Data is too long: " + value.length);
|
||||
}
|
||||
if (value.length == SIZE_BYTES) {
|
||||
return new Hex32(value);
|
||||
}
|
||||
if (value.length == 0) {
|
||||
return empty();
|
||||
}
|
||||
byte[] base = new byte[SIZE_BYTES];
|
||||
System.arraycopy(value, 0, base, base.length - value.length, value.length);
|
||||
return new Hex32(base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert bytes to an unsigned number. I.e., <code>uint</code> -> <code>BigInteger</code>
|
||||
* @return number
|
||||
*/
|
||||
public BigInteger asUInt() {
|
||||
return new BigInteger(1, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert bytes to a signed number. I.e., <code>int</code> -> <code>BigInteger</code>
|
||||
* @return number
|
||||
*/
|
||||
public BigInteger asInt() {
|
||||
BigInteger number = new BigInteger(1, value);
|
||||
// for negative value the highest bit is set to 1
|
||||
if (value[0] >= 0) {
|
||||
// just positive number, return as is
|
||||
return number;
|
||||
} else {
|
||||
// calculate signed part
|
||||
return NUMBER_LIMIT.subtract(number).negate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
/*
|
||||
* Copyright (c) 2020 EmeraldPay Inc, All Rights Reserved.
|
||||
* Copyright (c) 2016-2017 Infinitape Inc, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.hex;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.IntFunction;
|
||||
import java.util.stream.IntStream;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Fixed size value, such as Wallet Address, represented in Hex.
|
||||
*/
|
||||
public class HexData implements Serializable {
|
||||
|
||||
/**
|
||||
* Use {@link HexData#empty()}
|
||||
*/
|
||||
@Deprecated
|
||||
public final static HexData EMPTY = new HexData(new byte[0]);
|
||||
|
||||
private final static char[] HEX_DIGITS = "0123456789abcdef".toCharArray();
|
||||
|
||||
/**
|
||||
* Combine an array of hex data into single instance.
|
||||
*
|
||||
* @param data an array of hex data
|
||||
* @return a hex data
|
||||
* @see #combine(Collection)
|
||||
*/
|
||||
public static HexData combine(HexData... data) {
|
||||
return combine(Arrays.asList(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Combine a collection of hex data into single instance.
|
||||
*
|
||||
* @param data a collection of hex data
|
||||
* @return a hex data
|
||||
* @see #combine(HexData...)
|
||||
*/
|
||||
public static HexData combine(Collection<? extends HexData> data) {
|
||||
return empty().concat(data);
|
||||
}
|
||||
|
||||
public static HexData from(long value) {
|
||||
return new HexData(BigInteger.valueOf(value).toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse hex representation for a number, should start with {@code 0x}.
|
||||
*
|
||||
* @param value hex value
|
||||
* @return parsed value
|
||||
*/
|
||||
public static HexData from(String value) {
|
||||
if (value.isEmpty())
|
||||
throw new IllegalArgumentException("Empty value");
|
||||
|
||||
if (!value.startsWith("0x"))
|
||||
throw new IllegalArgumentException("Invalid hex format: " + value);
|
||||
|
||||
value = value.substring(2);
|
||||
|
||||
if (value.length() <= 0) return empty();
|
||||
|
||||
byte[] bytes = new BigInteger(value, 16).toByteArray();
|
||||
|
||||
int len = (value.length() / 2) + (value.length() % 2);
|
||||
|
||||
if (bytes.length == len)
|
||||
return new HexData(bytes);
|
||||
|
||||
byte[] buf = new byte[len];
|
||||
|
||||
// for values like 0xffffff it produces extra 0 byte in the beginning, we need to skip it
|
||||
int pos = bytes.length > buf.length ? bytes.length - buf.length : 0;
|
||||
System.arraycopy(bytes, pos, buf, buf.length - bytes.length + pos, bytes.length - pos);
|
||||
|
||||
return new HexData(buf);
|
||||
}
|
||||
|
||||
public static HexData empty(int size) {
|
||||
if (size < 0) {
|
||||
throw new IllegalArgumentException("Size cannot be less than zero");
|
||||
}
|
||||
return new HexData(new byte[size]);
|
||||
}
|
||||
|
||||
public static HexData empty() {
|
||||
return empty(0);
|
||||
}
|
||||
|
||||
protected final byte[] value;
|
||||
|
||||
public HexData(byte[] value) {
|
||||
this(value, value.length);
|
||||
}
|
||||
|
||||
public HexData(byte[] value, int size) {
|
||||
if (value.length != size)
|
||||
throw new IllegalArgumentException("Invalid data size: " + value.length);
|
||||
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Concat with an array of {@link HexData}.
|
||||
*
|
||||
* @param data an array of {@link HexData}
|
||||
* @return hex value
|
||||
* @see #concat(Collection)
|
||||
*/
|
||||
public HexData concat(HexData... data) {
|
||||
return concat(Arrays.asList(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Concat with a collection of {@link HexData}.
|
||||
*
|
||||
* @param data a collection of {@link HexData}
|
||||
* @return hex value
|
||||
* @see #concat(HexData...)
|
||||
*/
|
||||
public HexData concat(Collection<? extends HexData> data) {
|
||||
ByteArrayOutputStream buf = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
buf.write(getBytes());
|
||||
|
||||
for (HexData param: data) {
|
||||
buf.write(param.getBytes());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return new HexData(buf.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a {@link HexData} instance by required {@code size} bytes from start.
|
||||
*
|
||||
* @param size a size in bytes
|
||||
* @return an extracted {@link HexData} instance
|
||||
* @see #extract(int, int)
|
||||
*/
|
||||
public HexData extract(int size) {
|
||||
return extract(size, 0, Function.identity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a new object by required {@code size} bytes from start.
|
||||
*
|
||||
* @param size a size in bytes
|
||||
* @param conv a converter from hex data into required object type
|
||||
* @param <T> a java object type is needed to return
|
||||
* @return an extracted object
|
||||
*
|
||||
* @see #extract(int, int, Function)
|
||||
*/
|
||||
public <T> T extract(int size, Function<? super HexData, T> conv) {
|
||||
return extract(size, 0, conv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a {@link HexData} instance by required {@code size} bytes
|
||||
* and with {@code offset}.
|
||||
*
|
||||
* @param size a size in bytes
|
||||
* @param offset an offset in bytes
|
||||
* @return an extracted {@link HexData} instance
|
||||
* @see #extract(int, int, Function)
|
||||
*/
|
||||
public HexData extract(int size, int offset) {
|
||||
return extract(size, offset, Function.identity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract tail of the underlying data, skipping {@code offset} bytes.
|
||||
*
|
||||
* @param offset size in bytes to skip
|
||||
* @return extracted data
|
||||
*/
|
||||
public HexData skip(int offset) {
|
||||
if (offset == 0) {
|
||||
return this;
|
||||
}
|
||||
if (offset > this.value.length) {
|
||||
throw new IndexOutOfBoundsException("Cannot skip " + offset + " of " + this.value.length);
|
||||
}
|
||||
if (offset == this.value.length) {
|
||||
return HexData.empty();
|
||||
}
|
||||
return extract(this.value.length - offset, offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a new object by required {@code size} bytes
|
||||
* and from {@code offset}.
|
||||
*
|
||||
* @param size a size in bytes
|
||||
* @param offset an offset in bytes
|
||||
* @param conv a converter from hex data into required object type
|
||||
* @param <T> a java object type is needed to return
|
||||
* @return an extracted object
|
||||
* @see #extract(int, Function)
|
||||
*/
|
||||
public <T> T extract(int size, int offset, Function<? super HexData, T> conv) {
|
||||
Objects.requireNonNull(conv);
|
||||
|
||||
if (size < 0 || offset < 0)
|
||||
throw new IllegalArgumentException("Negative extract arguments");
|
||||
|
||||
if (getSize() < size + offset)
|
||||
throw new IllegalArgumentException("Insufficient size to extract");
|
||||
|
||||
if (size == 0)
|
||||
return conv.apply(empty());
|
||||
|
||||
return conv.apply(
|
||||
new HexData(Arrays.copyOfRange(value, offset, size + offset)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of {@link HexData} were split by required {@code size}
|
||||
* bytes from start.
|
||||
*
|
||||
* @param size a size in bytes to split by
|
||||
* @return an array of split hex data
|
||||
* @throws IllegalArgumentException if the hex data length
|
||||
* is not a multiple of given {@code size}
|
||||
* @see #split(int, int)
|
||||
*/
|
||||
public HexData[] split(int size) {
|
||||
return split(size, 0, HexData[]::new, Function.identity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of {@link Hex32} by splitting the value bytes
|
||||
*
|
||||
* @return an array of split 32-bytes data
|
||||
* @throws IllegalArgumentException if the summary length to split
|
||||
* is not a multiple of given {@code size}
|
||||
* @see #split32(int)
|
||||
*/
|
||||
public Hex32[] split32() {
|
||||
return split32(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the elements were split by required {@code size}
|
||||
* bytes from start.
|
||||
*
|
||||
* @param size a size in bytes to split by
|
||||
* @param gen a function which produces a new array of the desired
|
||||
* type and the provided length
|
||||
* @param conv a converter from hex data into required object type
|
||||
* @param <T> the element type of the resulting array
|
||||
* @return an array of split type instances
|
||||
* @throws IllegalArgumentException if the hex data length
|
||||
* is not a multiple of given {@code size}
|
||||
* @see #split(int, int, IntFunction, Function)
|
||||
*/
|
||||
public <T> T[] split(int size, IntFunction<T[]> gen, Function<? super HexData, T> conv) {
|
||||
return split(size, 0, gen, conv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of {@link HexData} were split by required {@code size}
|
||||
* bytes and from {@code offset}.
|
||||
*
|
||||
* @param size a size in bytes to split by
|
||||
* @param offset an offset in bytes to split from
|
||||
* @return an array of split hex data
|
||||
* @throws IllegalArgumentException if the summary length to split
|
||||
* is not a multiple of given {@code size}
|
||||
* @see #split(int)
|
||||
*/
|
||||
public HexData[] split(int size, int offset) {
|
||||
return split(size, offset, HexData[]::new, Function.identity());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of {@link Hex32} by splitting the value bytes starting from {@code offset}.
|
||||
*
|
||||
* @param offset an offset in bytes to split from
|
||||
* @return an array of split 32-bytes data
|
||||
* @throws IllegalArgumentException if the summary length to split
|
||||
* is not a multiple of given {@code size}
|
||||
* @see #split32()
|
||||
*/
|
||||
public Hex32[] split32(int offset) {
|
||||
return split(Hex32.SIZE_BYTES, offset, Hex32[]::new, v -> Hex32.from(v.value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the elements were split by required {@code size}
|
||||
* bytes and from {@code offset}, using the provided {@code conv}
|
||||
* function to convert {@link HexData} into required object type.
|
||||
*
|
||||
* <pre>{@code
|
||||
* List<String> coll = data.split(32, 0, String[]::new, data::toHex);
|
||||
* }</pre>
|
||||
*
|
||||
* @param size a size in bytes to split by
|
||||
* @param offset an offset in bytes to split from
|
||||
* @param gen a function which produces a new array of the desired
|
||||
* type and the provided length
|
||||
* @param conv a converter from hex data into required object type
|
||||
* @param <T> the element type of the resulting array
|
||||
* @return an array of split type instances
|
||||
* @throws IllegalArgumentException if the summary length to split
|
||||
* is not a multiple of given {@code size}
|
||||
* @see #split(int, IntFunction, Function)
|
||||
*/
|
||||
public <T> T[] split(int size, int offset, IntFunction<T[]> gen, Function<? super HexData, T> conv) {
|
||||
Objects.requireNonNull(conv);
|
||||
|
||||
if (size < 0 || offset < 0)
|
||||
throw new IllegalArgumentException("Negative extract arguments");
|
||||
|
||||
if (getSize() < offset)
|
||||
throw new IllegalArgumentException("Insufficient size to extract");
|
||||
|
||||
if (size != 0 && (getSize() - offset) % size != 0)
|
||||
throw new IllegalArgumentException("Length to split is not a multiple of " + size);
|
||||
|
||||
if (size == 0)
|
||||
return gen.apply(0);
|
||||
|
||||
Stream<byte[]> stream = IntStream.range(0, (getSize() - offset) / size)
|
||||
.map(i -> i * size + offset).mapToObj(j -> Arrays.copyOfRange(value, j, j + size));
|
||||
|
||||
return stream.map(HexData::new).map(conv::apply).toArray(gen);
|
||||
}
|
||||
|
||||
public String toHex() {
|
||||
char[] hex = new char[value.length * 2 + 2];
|
||||
|
||||
hex[0] = '0';
|
||||
hex[1] = 'x';
|
||||
|
||||
for(int i = 0, j = 2; i < value.length; i++){
|
||||
hex[j++] = HEX_DIGITS[(0xF0 & value[i]) >>> 4];
|
||||
hex[j++] = HEX_DIGITS[0x0F & value[i]];
|
||||
}
|
||||
|
||||
return new String(hex);
|
||||
}
|
||||
|
||||
public HexQuantity asQuantity() {
|
||||
return new HexQuantity(new BigInteger(1, value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to extract an array of Hex32 packed into the value. The array is encoded with 32 bytes of offset
|
||||
* value, 32 bytes of length and following items.
|
||||
*
|
||||
* @return array of values
|
||||
* @throws IllegalArgumentException if invalid structure or length
|
||||
*/
|
||||
public Hex32[] asEncodedArray() {
|
||||
HexData[] parts = split(Hex32.SIZE_BYTES);
|
||||
if (parts.length < 2) {
|
||||
throw new IllegalArgumentException("Not an encoded array");
|
||||
}
|
||||
Hex32 _offset = Hex32.from(parts[0]);
|
||||
int len = parts[1].asQuantity().getValue().intValue();
|
||||
if (parts.length != 2 + len) {
|
||||
throw new IllegalArgumentException("Invalid data length. " + parts.length + " != " + (2 + len));
|
||||
}
|
||||
Hex32[] result = new Hex32[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
result[i] = Hex32.from(parts[2 + i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to extract an array of <T> packed into the value. The array is encoded with 32 bytes of offset
|
||||
* value, 32 bytes of length and following items.
|
||||
*
|
||||
* The conversion function must extract actual value (ex. an Address, or Number) from the Hex32 representation.
|
||||
*
|
||||
* @param converter conversion function to extract actual value
|
||||
* @param <T> target type
|
||||
* @return array of values
|
||||
* @throws IllegalArgumentException if invalid structure or length
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] asEncodedArray(Function<Hex32, T> converter) {
|
||||
Hex32[] values = asEncodedArray();
|
||||
return (T[]) Arrays.stream(values).map(converter).toArray();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return toHex();
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return value.clone();
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return value.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null) return false;
|
||||
if (!(o instanceof HexData)) return false;
|
||||
|
||||
HexData hexData = (HexData) o;
|
||||
|
||||
return Arrays.equals(value, hexData.value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2021 EmeraldPay Inc, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.hex;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class HexDataComparator implements Comparator<HexData> {
|
||||
|
||||
@Override
|
||||
public int compare(HexData o1, HexData o2) {
|
||||
if (o1.getSize() != o2.getSize()) {
|
||||
throw new IllegalArgumentException("Cannot compare HexData with different lengths. " + o1.getSize() + " and " + o2.getSize());
|
||||
}
|
||||
byte[] val1 = o1.getBytes();
|
||||
byte[] val2 = o2.getBytes();
|
||||
for (int i = 0; i < val1.length; i++) {
|
||||
if (val1[i] < val2[i]) {
|
||||
return -1;
|
||||
}
|
||||
if (val1[i] > val2[i]) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2020 EmeraldPay Inc, All Rights Reserved.
|
||||
* Copyright (c) 2016-2017 Infinitape Inc, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.hex;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* Hex-encoded {@link String} for {@link BigInteger} instances.
|
||||
*/
|
||||
public interface HexEncoding {
|
||||
|
||||
/**
|
||||
* The prefix used for non naked hex encoding format.
|
||||
*
|
||||
* @see #toHex(long)
|
||||
* @see #toHex(BigInteger)
|
||||
*/
|
||||
String HEX_PREFIX = "0x";
|
||||
|
||||
/**
|
||||
* @param hex hex-encoded {@link String} with optional {@value #HEX_PREFIX}
|
||||
* @return {@link BigInteger} instance
|
||||
* @see #HEX_PREFIX
|
||||
*/
|
||||
static BigInteger fromHex(String hex) {
|
||||
return new BigInteger(
|
||||
hex.startsWith(HEX_PREFIX) ?
|
||||
hex.substring(HEX_PREFIX.length()) : hex, 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val a long value
|
||||
* @return Hex-encoded {@link String} with {@value #HEX_PREFIX}
|
||||
* and padded with zero to an even number of digits
|
||||
* @see #HEX_PREFIX
|
||||
*/
|
||||
static String toHex(long val) {
|
||||
String str = toNakedHex(val);
|
||||
|
||||
return HEX_PREFIX.concat(str.length() % 2 == 0 ? "" : "0").concat(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param num {@link BigInteger} instance
|
||||
* @return Hex-encoded {@link String} with {@value #HEX_PREFIX}
|
||||
* and padded with zero to an even number of digits
|
||||
* @see #HEX_PREFIX
|
||||
*/
|
||||
static String toHex(BigInteger num) {
|
||||
String str = toNakedHex(num);
|
||||
|
||||
return HEX_PREFIX.concat(str.length() % 2 == 0 ? "" : "0").concat(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param val a long value
|
||||
* @return Naked hex-encoded {@link String} without {@value #HEX_PREFIX}
|
||||
* @see #toHex(long)
|
||||
*/
|
||||
static String toNakedHex(long val) {
|
||||
return Long.toHexString(val);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param num {@link BigInteger} instance
|
||||
* @return Naked hex-encoded {@link String} without {@value #HEX_PREFIX}
|
||||
* @see #toHex(BigInteger)
|
||||
*/
|
||||
static String toNakedHex(BigInteger num) {
|
||||
return num.toString(16);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.hex;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Objects;
|
||||
|
||||
public class HexQuantity implements Serializable {
|
||||
|
||||
private final BigInteger value;
|
||||
|
||||
public HexQuantity(BigInteger value) {
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Can't create instance of null quantity");
|
||||
}
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static HexQuantity from(Long value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return new HexQuantity(BigInteger.valueOf(value));
|
||||
}
|
||||
|
||||
public static HexQuantity from(BigInteger value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return new HexQuantity(value);
|
||||
}
|
||||
|
||||
public static HexQuantity from(String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
int signum = 1;
|
||||
if (value.startsWith("-")) {
|
||||
signum = -1;
|
||||
value = value.substring(1);
|
||||
}
|
||||
if (!value.startsWith("0x")) {
|
||||
throw new IllegalArgumentException("Input must be formatted as a hex value");
|
||||
}
|
||||
value = value.substring(2);
|
||||
if (value.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
BigInteger num = new BigInteger(value, 16);
|
||||
if (signum == -1) {
|
||||
num = num.negate();
|
||||
}
|
||||
return new HexQuantity(num);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("Invalid quantity value: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
public String toHex() {
|
||||
return (value.signum() == -1 ? "-" : "") + "0x" + value.abs().toString(16);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return toHex();
|
||||
}
|
||||
|
||||
public BigInteger getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public HexData asData() {
|
||||
return new HexData(value.toByteArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
HexQuantity that = (HexQuantity) o;
|
||||
return value.equals(that.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(value);
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.domain.Address;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Bloom;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Wei;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigInteger;
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Bloom;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
|
||||
@@ -24,8 +24,8 @@ import io.emeraldpay.dshackle.upstream.ethereum.domain.Address;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Wei;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.etherjar.hex.HexEncoding;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexEncoding;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Wei;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HexDataSerializer extends StdSerializer<HexData> {
|
||||
|
||||
public HexDataSerializer() {
|
||||
super(HexData.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(HexData value, JsonGenerator gen, SerializerProvider provider) throws IOException {
|
||||
if (value == null) {
|
||||
gen.writeNull();
|
||||
} else {
|
||||
gen.writeString(value.toHex());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020 EmeraldPay Inc, All Rights Reserved.
|
||||
* Copyright (c) 2016-2017 Infinitape Inc, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RequestJson<T> {
|
||||
|
||||
private String jsonrpc = "2.0";
|
||||
private String method;
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
private List params;
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
private T id;
|
||||
|
||||
public RequestJson(String method, List params, T id) {
|
||||
if (!(
|
||||
Integer.class.isAssignableFrom(id.getClass())
|
||||
|| Long.class.isAssignableFrom(id.getClass())
|
||||
|| String.class.isAssignableFrom(id.getClass())
|
||||
)) {
|
||||
throw new IllegalArgumentException("ID must be String or Integer/Long");
|
||||
}
|
||||
this.method = method;
|
||||
this.params = params;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getJsonrpc() {
|
||||
return jsonrpc;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public List getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
public T getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2020 EmeraldPay Inc, All Rights Reserved.
|
||||
* Copyright (c) 2016-2017 Infinitape Inc, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError;
|
||||
|
||||
@JsonSerialize(using = ResponseJsonSerializer.class)
|
||||
public class ResponseJson<DATA, ID> {
|
||||
|
||||
private String jsonrpc = "2.0";
|
||||
private ID id;
|
||||
private DATA result;
|
||||
private RpcResponseError error;
|
||||
|
||||
public String getJsonrpc() {
|
||||
return jsonrpc;
|
||||
}
|
||||
|
||||
public void setJsonrpc(String jsonrpc) {
|
||||
this.jsonrpc = jsonrpc;
|
||||
}
|
||||
|
||||
public ID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(ID id) {
|
||||
if (!(
|
||||
Integer.class.isAssignableFrom(id.getClass())
|
||||
|| Long.class.isAssignableFrom(id.getClass())
|
||||
|| String.class.isAssignableFrom(id.getClass())
|
||||
)) {
|
||||
throw new IllegalArgumentException("ID must be String or Integer/Long");
|
||||
}
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public DATA getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(DATA result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public RpcResponseError getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(RpcResponseError error) {
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> ResponseJson<T, ID> cast(Class<T> clazz) {
|
||||
if (result == null || clazz.isAssignableFrom(result.getClass())) {
|
||||
return (ResponseJson<T, ID>) this;
|
||||
}
|
||||
throw new ClassCastException("Value of " + result.getClass() + " is not assignable to " + clazz);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ResponseJsonSerializer<X,T> extends JsonSerializer<ResponseJson<X,T>> {
|
||||
|
||||
@Override
|
||||
public void serialize(ResponseJson<X, T> value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
gen.writeStartObject();
|
||||
gen.writeStringField("jsonrpc", "2.0");
|
||||
gen.writeObjectField("id", value.getId());
|
||||
if (value.getError() != null) {
|
||||
gen.writeObjectField("error", value.getError());
|
||||
} else {
|
||||
gen.writeObjectField("result", value.getResult());
|
||||
}
|
||||
gen.writeEndObject();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
@JsonDeserialize(using = SyncingJsonDeserializer.class)
|
||||
@JsonSerialize(using = SyncingJsonSerializer.class)
|
||||
public class SyncingJson {
|
||||
|
||||
private boolean syncing;
|
||||
|
||||
private Long startingBlock;
|
||||
private Long currentBlock;
|
||||
private Long highestBlock;
|
||||
|
||||
public boolean isSyncing() {
|
||||
return syncing;
|
||||
}
|
||||
|
||||
public void setSyncing(boolean syncing) {
|
||||
this.syncing = syncing;
|
||||
}
|
||||
|
||||
public Long getStartingBlock() {
|
||||
return startingBlock;
|
||||
}
|
||||
|
||||
public void setStartingBlock(Long startingBlock) {
|
||||
this.startingBlock = startingBlock;
|
||||
}
|
||||
|
||||
public Long getCurrentBlock() {
|
||||
return currentBlock;
|
||||
}
|
||||
|
||||
public void setCurrentBlock(Long currentBlock) {
|
||||
this.currentBlock = currentBlock;
|
||||
}
|
||||
|
||||
public Long getHighestBlock() {
|
||||
return highestBlock;
|
||||
}
|
||||
|
||||
public void setHighestBlock(Long highestBlock) {
|
||||
this.highestBlock = highestBlock;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class SyncingJsonDeserializer extends EtherJsonDeserializer<SyncingJson> {
|
||||
|
||||
@Override
|
||||
public SyncingJson deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
|
||||
JsonNode node = jp.readValueAsTree();
|
||||
SyncingJson resp = new SyncingJson();
|
||||
if (node.isBoolean()) {
|
||||
resp.setSyncing(node.asBoolean());
|
||||
} else {
|
||||
resp.setSyncing(true);
|
||||
resp.setStartingBlock(getLong(node, "startingBlock"));
|
||||
resp.setCurrentBlock(getLong(node, "currentBlock"));
|
||||
resp.setHighestBlock(getLong(node, "highestBlock"));
|
||||
}
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2019 Igor Artamonov, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class SyncingJsonSerializer extends EtherJsonSerializer<SyncingJson> {
|
||||
|
||||
@Override
|
||||
public void serialize(SyncingJson value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
|
||||
if (value == null) {
|
||||
gen.writeNull();
|
||||
} else if (value.isSyncing()) {
|
||||
gen.writeStartObject();
|
||||
writeField(gen, "startingBlock", value.getStartingBlock());
|
||||
writeField(gen, "currentBlock", value.getCurrentBlock());
|
||||
writeField(gen, "highestBlock", value.getHighestBlock());
|
||||
gen.writeEndObject();
|
||||
} else {
|
||||
gen.writeBoolean(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Wei;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonSerializer;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import io.emeraldpay.etherjar.hex.HexEncoding;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexEncoding;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
|
||||
@@ -24,8 +24,8 @@ import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionRef;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionSignature;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Wei;
|
||||
import io.emeraldpay.etherjar.hex.Hex32;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.ChainId;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionSignature;
|
||||
import io.emeraldpay.etherjar.hex.Hex32;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionSignature;
|
||||
import io.emeraldpay.etherjar.hex.Hex32;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@@ -23,8 +23,8 @@ import io.emeraldpay.dshackle.upstream.ethereum.domain.Address;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionRef;
|
||||
import io.emeraldpay.etherjar.hex.Hex32;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
@@ -79,7 +79,6 @@ public class TransactionLogJson implements TransactionRef, Serializable {
|
||||
*
|
||||
* In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)),
|
||||
* except you declared the event with the anonymous specifier.
|
||||
* @see io.emeraldpay.etherjar.domain.EventId
|
||||
*/
|
||||
private List<Hex32> topics;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.emeraldpay.etherjar.hex.Hex32;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -17,7 +17,7 @@ package io.emeraldpay.dshackle.upstream.ethereum.json;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Bloom;
|
||||
import io.emeraldpay.etherjar.hex.HexData;
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (c) 2020 EmeraldPay Inc, All Rights Reserved.
|
||||
* Copyright (c) 2016-2017 Infinitape Inc, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.rpc;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Igor Artamonov
|
||||
*/
|
||||
public class RpcException extends RuntimeException {
|
||||
|
||||
private int code;
|
||||
private String rpcMessage;
|
||||
private Object details;
|
||||
|
||||
public RpcException(int code, String rpcMessage, Object details, Throwable cause) {
|
||||
super("RPC Error " + code + ": " + rpcMessage, cause);
|
||||
this.code = code;
|
||||
this.rpcMessage = rpcMessage;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public RpcException(int code, String rpcMessage, Object details) {
|
||||
this(code, rpcMessage, details, null);
|
||||
}
|
||||
|
||||
public RpcException(int code, String rpcMessage) {
|
||||
this(code, rpcMessage, null);
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getRpcMessage() {
|
||||
return rpcMessage;
|
||||
}
|
||||
|
||||
public Object getDetails() {
|
||||
return details;
|
||||
}
|
||||
|
||||
public RpcResponseError getError() {
|
||||
return new RpcResponseError(code, rpcMessage, details);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "RpcException(" + code + " " + rpcMessage
|
||||
+ (details == null ? "" : ", " + details.toString())
|
||||
+ ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
RpcException that = (RpcException) o;
|
||||
return code == that.code &&
|
||||
Objects.equals(rpcMessage, that.rpcMessage) &&
|
||||
Objects.equals(details, that.details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code, rpcMessage);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2020 EmeraldPay Inc, All Rights Reserved.
|
||||
* Copyright (c) 2016-2017 Infinitape Inc, All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.ethereum.rpc;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
/**
|
||||
* @author Igor Artamonov
|
||||
*/
|
||||
public class RpcResponseError {
|
||||
|
||||
public static int CODE_INVALID_JSON = -32700;
|
||||
public static int CODE_INVALID_REQUEST = -32600;
|
||||
public static int CODE_METHOD_NOT_EXIST = -32601;
|
||||
public static int CODE_INVALID_METHOD_PARAMS = -32602;
|
||||
public static int CODE_INTERNAL_ERROR = -32603;
|
||||
|
||||
public static int CODE_RESERVED_0 = -32000;
|
||||
public static int CODE_RESERVED_99 = -32099;
|
||||
|
||||
public static int CODE_UPSTREAM_INVALID_RESPONSE = -32000;
|
||||
public static int CODE_UPSTREAM_CONNECTION_ERROR = -32001;
|
||||
|
||||
/**
|
||||
* -32700 - Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.
|
||||
* -32600 - The JSON sent is not a valid Request object.
|
||||
* -32601 - The method does not exist / is not available.
|
||||
* -32602 - Invalid method parameter(s).
|
||||
* -32603 - Internal JSON-RPC error.
|
||||
* -32000 to -32099 - Reserved for implementation-defined server-errors.
|
||||
*/
|
||||
private int code;
|
||||
|
||||
/**
|
||||
* A String providing a short description of the error.
|
||||
* The message SHOULD be limited to a concise single sentence.
|
||||
*/
|
||||
private String message;
|
||||
|
||||
|
||||
/**
|
||||
* A Primitive or Structured value that contains additional information about the error.
|
||||
* This may be omitted.
|
||||
* The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
private Object data;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public RpcResponseError() {
|
||||
}
|
||||
|
||||
public RpcResponseError(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public RpcResponseError(int code, String message, Object data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert it ot RpcException
|
||||
*
|
||||
* @return same error as exception
|
||||
* @see RpcException
|
||||
*/
|
||||
public RpcException asException() {
|
||||
return new RpcException(code, message, data);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "RPC Response Error (code: " + code + "; message: " + message + ")";
|
||||
}
|
||||
}
|
||||
@@ -20,8 +20,8 @@ import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.config.ProxyConfig
|
||||
import io.emeraldpay.dshackle.monitoring.accesslog.AccessHandlerHttp
|
||||
import io.emeraldpay.dshackle.rpc.NativeCall
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.netty.buffer.ByteBuf
|
||||
import io.netty.buffer.Unpooled
|
||||
import org.reactivestreams.Publisher
|
||||
|
||||
@@ -20,10 +20,10 @@ import com.fasterxml.jackson.databind.ObjectMapper
|
||||
import com.google.protobuf.ByteString
|
||||
import io.emeraldpay.api.proto.BlockchainOuterClass
|
||||
import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.RequestJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.etherjar.rpc.json.RequestJson
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.stereotype.Service
|
||||
import java.io.IOException
|
||||
|
||||
@@ -23,8 +23,8 @@ import io.emeraldpay.dshackle.config.ProxyConfig
|
||||
import io.emeraldpay.dshackle.monitoring.accesslog.AccessHandlerHttp
|
||||
import io.emeraldpay.dshackle.rpc.NativeCall
|
||||
import io.emeraldpay.dshackle.rpc.NativeSubscribe
|
||||
import io.emeraldpay.etherjar.rpc.json.RequestJson
|
||||
import io.emeraldpay.etherjar.rpc.json.ResponseJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.RequestJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.ResponseJson
|
||||
import io.netty.buffer.ByteBufInputStream
|
||||
import org.reactivestreams.Publisher
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package io.emeraldpay.dshackle.quorum
|
||||
|
||||
import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexQuantity
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
||||
import io.emeraldpay.etherjar.hex.HexQuantity
|
||||
|
||||
class MaximumValueQuorum : CallQuorum, ValueAwareQuorum<String>(String::class.java) {
|
||||
private var max: Long? = null
|
||||
|
||||
@@ -24,12 +24,12 @@ import io.emeraldpay.dshackle.reader.RpcReader
|
||||
import io.emeraldpay.dshackle.reader.SpannedReader
|
||||
import io.emeraldpay.dshackle.upstream.ApiSource
|
||||
import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcUpstreamException
|
||||
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.cloud.sleuth.Tracer
|
||||
import reactor.core.publisher.Flux
|
||||
|
||||
@@ -18,11 +18,11 @@ package io.emeraldpay.dshackle.quorum
|
||||
|
||||
import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
abstract class ValueAwareQuorum<T>(
|
||||
|
||||
@@ -6,13 +6,13 @@ import io.emeraldpay.dshackle.reader.RpcReader.Result
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.stream.Chunk
|
||||
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import org.springframework.cloud.sleuth.Tracer
|
||||
import reactor.core.publisher.Flux
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
@@ -41,13 +41,13 @@ import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.MultistreamHolder
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.calls.DefaultEthereumMethods
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.stream.Chunk
|
||||
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.micrometer.core.instrument.Metrics
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import org.reactivestreams.Publisher
|
||||
|
||||
@@ -4,7 +4,7 @@ import io.emeraldpay.dshackle.quorum.AlwaysQuorum
|
||||
import io.emeraldpay.dshackle.quorum.BroadcastQuorum
|
||||
import io.emeraldpay.dshackle.quorum.CallQuorum
|
||||
import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
|
||||
class DefaultSolanaMethods : CallMethods {
|
||||
companion object {
|
||||
|
||||
@@ -21,10 +21,10 @@ import io.emeraldpay.dshackle.reader.JsonRpcReader
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.RpcUnspent
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.data.SimpleUnspent
|
||||
import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import org.bitcoinj.core.Address
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.emeraldpay.dshackle.quorum.AlwaysQuorum
|
||||
import io.emeraldpay.dshackle.quorum.BroadcastQuorum
|
||||
import io.emeraldpay.dshackle.quorum.CallQuorum
|
||||
import io.emeraldpay.dshackle.quorum.NotNullQuorum
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import java.util.Collections
|
||||
|
||||
class DefaultBitcoinMethods : CallMethods {
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.emeraldpay.dshackle.quorum.BroadcastQuorum
|
||||
import io.emeraldpay.dshackle.quorum.CallQuorum
|
||||
import io.emeraldpay.dshackle.quorum.MaximumValueQuorum
|
||||
import io.emeraldpay.dshackle.quorum.NotNullQuorum
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
|
||||
/**
|
||||
* Default configuration for Ethereum based RPC. Defines optimal Quorum strategies for different methods, and provides
|
||||
|
||||
@@ -19,7 +19,7 @@ package io.emeraldpay.dshackle.upstream.calls
|
||||
import io.emeraldpay.dshackle.quorum.AlwaysQuorum
|
||||
import io.emeraldpay.dshackle.quorum.BroadcastQuorum
|
||||
import io.emeraldpay.dshackle.quorum.CallQuorum
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
|
||||
/**
|
||||
* Default configuration for Ethereum based RPC. Defines optimal Quorum strategies for different methods, and provides
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.emeraldpay.dshackle.quorum.BroadcastQuorum
|
||||
import io.emeraldpay.dshackle.quorum.CallQuorum
|
||||
import io.emeraldpay.dshackle.quorum.MaximumValueQuorum
|
||||
import io.emeraldpay.dshackle.quorum.NotNullQuorum
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
|
||||
/**
|
||||
* Default configuration for Ethereum based RPC. Defines optimal Quorum strategies for different methods, and provides
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.emeraldpay.dshackle.cache.Caches
|
||||
import io.emeraldpay.dshackle.data.BlockId
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.etherjar.hex.HexQuantity
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexQuantity
|
||||
import org.bouncycastle.util.encoders.DecoderException
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -2,9 +2,9 @@ package io.emeraldpay.dshackle.upstream.ethereum
|
||||
|
||||
import io.emeraldpay.dshackle.Chain
|
||||
import io.emeraldpay.dshackle.reader.JsonRpcReader
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexQuantity
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.hex.HexQuantity
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
private const val ARBITRUM_NITRO_BLOCK = "0x152DD47" // 22207815
|
||||
|
||||
@@ -21,16 +21,16 @@ import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Wei
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexQuantity
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.BlockJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionJsonSnapshot
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionLogJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionReceiptJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionRefJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.etherjar.hex.HexQuantity
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import org.apache.commons.collections4.Factory
|
||||
import org.apache.commons.lang3.exception.ExceptionUtils
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
@@ -5,10 +5,10 @@ import io.emeraldpay.dshackle.upstream.EgressSubscription
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.ConnectLogs
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.ConnectNewHeads
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.PendingTxesSource
|
||||
import io.emeraldpay.etherjar.hex.Hex32
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.scheduler.Scheduler
|
||||
|
||||
@@ -22,11 +22,11 @@ import io.emeraldpay.dshackle.reader.JsonRpcReader
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.LogsOracle
|
||||
import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexQuantity
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.hex.HexQuantity
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.kotlin.core.publisher.switchIfEmpty
|
||||
import java.math.BigInteger
|
||||
|
||||
@@ -27,11 +27,11 @@ import io.emeraldpay.dshackle.upstream.UpstreamAvailability
|
||||
import io.emeraldpay.dshackle.upstream.UpstreamValidator
|
||||
import io.emeraldpay.dshackle.upstream.ValidateUpstreamSettingsResult
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.SyncingJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionCallJson
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import io.emeraldpay.etherjar.rpc.json.SyncingJson
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.scheduling.concurrent.CustomizableThreadFactory
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -20,6 +20,7 @@ import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.config.AuthConfig
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.WsConnection.ConnectionState.CONNECTED
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.WsConnection.ConnectionState.DISCONNECTED
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
@@ -27,7 +28,6 @@ import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcWsMessage
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ResponseWSParser
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.RpcMetrics
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.micrometer.core.instrument.Metrics
|
||||
import io.netty.buffer.ByteBufInputStream
|
||||
import io.netty.handler.codec.http.HttpHeaderNames
|
||||
|
||||
@@ -19,9 +19,9 @@ import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.dshackle.upstream.SubscriptionConnect
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexDataComparator
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.LogMessage
|
||||
import io.emeraldpay.etherjar.hex.Hex32
|
||||
import io.emeraldpay.etherjar.hex.HexDataComparator
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.scheduler.Scheduler
|
||||
import java.util.function.Function
|
||||
|
||||
@@ -22,9 +22,9 @@ import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.upstream.Multistream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumCachingReader
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.EthereumDirectReader.Result
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionLogJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.LogMessage
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -17,8 +17,8 @@ package io.emeraldpay.dshackle.upstream.ethereum.subscribe
|
||||
|
||||
import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.upstream.Head
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.NewHeadMessage
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import reactor.core.publisher.Flux
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,9 +20,9 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.hex.Hex32
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import io.emeraldpay.etherjar.rpc.json.HexDataSerializer
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.HexDataSerializer
|
||||
|
||||
data class LogMessage(
|
||||
@get:JsonSerialize(using = HexDataSerializer::class)
|
||||
|
||||
@@ -22,8 +22,8 @@ import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Bloom
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import io.emeraldpay.etherjar.rpc.json.HexDataSerializer
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.HexDataSerializer
|
||||
import java.math.BigInteger
|
||||
import java.time.Instant
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.emeraldpay.dshackle.upstream.ethereum.subscribe.json
|
||||
import com.fasterxml.jackson.core.JsonGenerator
|
||||
import com.fasterxml.jackson.databind.JsonSerializer
|
||||
import com.fasterxml.jackson.databind.SerializerProvider
|
||||
import io.emeraldpay.etherjar.hex.HexQuantity
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexQuantity
|
||||
import java.math.BigInteger
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,10 +2,10 @@ package io.emeraldpay.dshackle.upstream.generic
|
||||
|
||||
import io.emeraldpay.dshackle.reader.JsonRpcReader
|
||||
import io.emeraldpay.dshackle.upstream.calls.CallMethods
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
class LocalReader(private val methods: CallMethods) : JsonRpcReader {
|
||||
|
||||
@@ -34,11 +34,11 @@ import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.UpstreamAvailability
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.BitcoinUpstream
|
||||
import io.emeraldpay.dshackle.upstream.bitcoin.ExtractBlock
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.forkchoice.MostWorkForkChoice
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcGrpcClient
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import org.reactivestreams.Publisher
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
|
||||
data class JsonRpcError(val code: Int, val message: String, val details: Any?) {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
|
||||
open class JsonRpcException(
|
||||
val id: JsonRpcResponse.Id,
|
||||
|
||||
@@ -22,9 +22,9 @@ import io.emeraldpay.api.proto.ReactorBlockchainGrpc
|
||||
import io.emeraldpay.dshackle.Chain
|
||||
import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.reader.JsonRpcReader
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.grpc.StatusRuntimeException
|
||||
import org.apache.commons.lang3.time.StopWatch
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
@@ -17,13 +17,13 @@ package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
import io.emeraldpay.dshackle.config.AuthConfig
|
||||
import io.emeraldpay.dshackle.reader.JsonRpcHttpReader
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.stream.AggregateResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.stream.JsonRpcStreamParser
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.stream.Response
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.stream.SingleResponse
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.stream.StreamResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.micrometer.core.instrument.Metrics
|
||||
import io.netty.buffer.Unpooled
|
||||
import io.netty.handler.codec.http.HttpHeaderNames
|
||||
|
||||
@@ -17,7 +17,7 @@ package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
import io.emeraldpay.dshackle.reader.JsonRpcReader
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.WsConnectionPool
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
class JsonRpcWsClient(
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.fasterxml.jackson.core.JsonParseException
|
||||
import com.fasterxml.jackson.core.JsonParser
|
||||
import com.fasterxml.jackson.core.JsonToken
|
||||
import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ package io.emeraldpay.dshackle.upstream.rpcclient.stream
|
||||
import com.fasterxml.jackson.core.JsonFactory
|
||||
import com.fasterxml.jackson.core.JsonParser
|
||||
import com.fasterxml.jackson.core.JsonToken
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.ResponseRpcParser
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import org.slf4j.LoggerFactory
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.emeraldpay.dshackle.config.ProxyConfig
|
||||
import io.emeraldpay.dshackle.monitoring.accesslog.AccessHandlerHttp
|
||||
import io.emeraldpay.dshackle.rpc.NativeCall
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.micrometer.core.instrument.Counter
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -18,7 +18,7 @@ package io.emeraldpay.dshackle.proxy
|
||||
|
||||
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import spock.lang.Specification
|
||||
|
||||
class ReadRpcJsonSpec extends Specification {
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.emeraldpay.dshackle.monitoring.accesslog.AccessHandlerHttp
|
||||
import io.emeraldpay.dshackle.rpc.NativeCall
|
||||
import io.emeraldpay.dshackle.rpc.NativeSubscribe
|
||||
import io.emeraldpay.dshackle.upstream.Selector
|
||||
import io.emeraldpay.etherjar.rpc.json.RequestJson
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.RequestJson
|
||||
import io.micrometer.core.instrument.Counter
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Sinks
|
||||
|
||||
@@ -24,8 +24,8 @@ import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import org.springframework.cloud.sleuth.Tracer
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.test.StepVerifier
|
||||
|
||||
@@ -40,8 +40,8 @@ import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcException
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.signature.ResponseSigner
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import org.springframework.cloud.sleuth.Tracer
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.publisher.Mono
|
||||
|
||||
@@ -24,7 +24,7 @@ import io.emeraldpay.dshackle.reader.Reader
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcError
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.grpc.stub.StreamObserver
|
||||
import io.netty.buffer.ByteBuf
|
||||
import io.netty.buffer.ByteBufAllocator
|
||||
|
||||
@@ -20,7 +20,7 @@ import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.generic.GenericMultistream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.subscribe.PendingTxesSource
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.etherjar.hex.Hex32
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -26,8 +26,8 @@ import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcResponse
|
||||
import io.emeraldpay.dshackle.upstream.Upstream
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionCallJson
|
||||
import reactor.core.publisher.Mono
|
||||
import reactor.util.function.Tuples
|
||||
|
||||
@@ -22,7 +22,7 @@ import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.dshackle.upstream.DefaultUpstream
|
||||
import io.emeraldpay.dshackle.upstream.rpcclient.JsonRpcRequest
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionJson
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.scheduler.Schedulers
|
||||
|
||||
@@ -20,8 +20,8 @@ import io.emeraldpay.dshackle.upstream.ethereum.subscribe.json.LogMessage
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.hex.Hex32
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import reactor.core.publisher.Flux
|
||||
import reactor.core.scheduler.Schedulers
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -23,7 +23,7 @@ import io.emeraldpay.dshackle.upstream.ethereum.EthereumDirectReader
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.json.TransactionLogJson
|
||||
import reactor.core.publisher.Mono
|
||||
import spock.lang.Specification
|
||||
|
||||
@@ -20,8 +20,8 @@ import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.TransactionId
|
||||
import io.emeraldpay.etherjar.hex.Hex32
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.Hex32
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import spock.lang.Specification
|
||||
|
||||
class LogMessageSpec extends Specification {
|
||||
|
||||
@@ -5,7 +5,7 @@ import io.emeraldpay.dshackle.Global
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Address
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.BlockHash
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.domain.Bloom
|
||||
import io.emeraldpay.etherjar.hex.HexData
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.hex.HexData
|
||||
import spock.lang.Specification
|
||||
|
||||
import java.time.Instant
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import nl.jqno.equalsverifier.EqualsVerifier
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import io.emeraldpay.api.proto.BlockchainOuterClass
|
||||
import io.emeraldpay.api.proto.Common
|
||||
import io.emeraldpay.dshackle.Chain
|
||||
import io.emeraldpay.dshackle.test.MockGrpcServer
|
||||
import io.emeraldpay.etherjar.rpc.RpcException
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcException
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.grpc.stub.StreamObserver
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
|
||||
import io.emeraldpay.dshackle.test.TestingCommons
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import io.micrometer.core.instrument.Counter
|
||||
import io.micrometer.core.instrument.Timer
|
||||
import org.mockserver.integration.ClientAndServer
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package io.emeraldpay.dshackle.upstream.rpcclient
|
||||
|
||||
import io.emeraldpay.etherjar.rpc.RpcResponseError
|
||||
import io.emeraldpay.dshackle.upstream.ethereum.rpc.RpcResponseError
|
||||
import spock.lang.Specification
|
||||
|
||||
class ResponseRpcParserSpec extends Specification {
|
||||
|
||||
Reference in New Issue
Block a user