Skip to content

Commit

Permalink
feat: add additional Bytes overloads where ByteArray can be used
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtificialPB committed Oct 8, 2024
1 parent b53151c commit 693050b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
11 changes: 11 additions & 0 deletions ethers-core/src/main/kotlin/io/ethers/core/Extensions.kt
Original file line number Diff line number Diff line change
@@ -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 <T> RlpDecodable<T>.rlpDecode(data: Bytes): T? {
return rlpDecode(data.asByteArray())
}
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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).
Expand Down Expand Up @@ -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.
*/
Expand Down
2 changes: 1 addition & 1 deletion ethers-rlp/src/main/kotlin/io/ethers/rlp/RlpDecodable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package io.ethers.rlp

interface RlpDecodable<T> {
/**
* 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()) {
Expand Down

0 comments on commit 693050b

Please sign in to comment.