diff --git a/ethers-core/src/main/kotlin/io/ethers/core/Extensions.kt b/ethers-core/src/main/kotlin/io/ethers/core/Extensions.kt new file mode 100644 index 0000000..77db661 --- /dev/null +++ b/ethers-core/src/main/kotlin/io/ethers/core/Extensions.kt @@ -0,0 +1,11 @@ +package io.ethers.core + +import io.ethers.core.types.Bytes +import io.ethers.rlp.RlpDecodable + +/** + * Decode RLP-encoded [data] and return instance of [T], or null if decoding fails. + */ +fun RlpDecodable.rlpDecode(data: Bytes): T? { + return rlpDecode(data.asByteArray()) +} diff --git a/ethers-providers/src/main/kotlin/io/ethers/providers/middleware/EthApi.kt b/ethers-providers/src/main/kotlin/io/ethers/providers/middleware/EthApi.kt index d8d1c2e..990e218 100644 --- a/ethers-providers/src/main/kotlin/io/ethers/providers/middleware/EthApi.kt +++ b/ethers-providers/src/main/kotlin/io/ethers/providers/middleware/EthApi.kt @@ -349,7 +349,8 @@ interface EthApi { /** * Get gas fee history for block range between [lastBlockName] and ([lastBlockName] - [blockCount] + 1). */ - fun getFeeHistory(blockCount: Long, lastBlockName: BlockId.Name) = getFeeHistory(blockCount, lastBlockName, emptyList()) + fun getFeeHistory(blockCount: Long, lastBlockName: BlockId.Name) = + getFeeHistory(blockCount, lastBlockName, emptyList()) /** * Get gas fee history for block range between [lastBlockNumber] and ([lastBlockNumber] - [blockCount] + 1). @@ -359,7 +360,8 @@ interface EthApi { /** * Get gas fee history for block range between [lastBlockNumber] and ([lastBlockNumber] - [blockCount] + 1). */ - fun getFeeHistory(blockCount: Long, lastBlockNumber: BlockId.Number) = getFeeHistory(blockCount, lastBlockNumber, emptyList()) + fun getFeeHistory(blockCount: Long, lastBlockNumber: BlockId.Number) = + getFeeHistory(blockCount, lastBlockNumber, emptyList()) /** * Get gas fee history for block range between [lastBlockName] and ([lastBlockName] - [blockCount] + 1). @@ -496,6 +498,11 @@ interface EthApi { */ fun sendRawTransaction(signedTransaction: TransactionSigned) = sendRawTransaction(signedTransaction.toRlp()) + /** + * Submit signed transaction bytes. + */ + fun sendRawTransaction(signedTransaction: Bytes) = sendRawTransaction(signedTransaction.asByteArray()) + /** * Submit signed transaction bytes. */ diff --git a/ethers-rlp/src/main/kotlin/io/ethers/rlp/RlpDecodable.kt b/ethers-rlp/src/main/kotlin/io/ethers/rlp/RlpDecodable.kt index f3f1903..3138b25 100644 --- a/ethers-rlp/src/main/kotlin/io/ethers/rlp/RlpDecodable.kt +++ b/ethers-rlp/src/main/kotlin/io/ethers/rlp/RlpDecodable.kt @@ -2,7 +2,7 @@ package io.ethers.rlp interface RlpDecodable { /** - * Decode [data] and return instance of [T]. + * Decode RLP-encoded [data] and return instance of [T], or null if decoding fails. */ fun rlpDecode(data: ByteArray): T? { if (data.isEmpty()) {