github.com/lmittmann/w3@v0.20.0/module/eth/uncle.go (about)

     1  package eth
     2  
     3  import (
     4  	"math/big"
     5  
     6  	"github.com/ethereum/go-ethereum/common"
     7  	"github.com/ethereum/go-ethereum/common/hexutil"
     8  	"github.com/ethereum/go-ethereum/core/types"
     9  	"github.com/lmittmann/w3/internal/module"
    10  	"github.com/lmittmann/w3/w3types"
    11  )
    12  
    13  // UncleByBlockHashAndIndex requests the uncle of the block with the given hash
    14  // at the given index.
    15  func UncleByBlockHashAndIndex(hash common.Hash, index uint) w3types.RPCCallerFactory[*types.Header] {
    16  	return module.NewFactory[*types.Header](
    17  		"eth_getUncleByBlockHashAndIndex",
    18  		[]any{hash, hexutil.Uint(index)},
    19  	)
    20  }
    21  
    22  // UncleByBlockNumberAndIndex requests the uncle of the block with the given
    23  // number at the given index.
    24  func UncleByBlockNumberAndIndex(number *big.Int, index uint) w3types.RPCCallerFactory[*types.Header] {
    25  	return module.NewFactory[*types.Header](
    26  		"eth_getUncleByBlockNumberAndIndex",
    27  		[]any{module.BlockNumberArg(number), hexutil.Uint(index)},
    28  	)
    29  }
    30  
    31  // UncleCountByBlockHash requests the number of uncles of the block with the
    32  // given hash.
    33  func UncleCountByBlockHash(hash common.Hash) w3types.RPCCallerFactory[uint] {
    34  	return module.NewFactory(
    35  		"eth_getUncleCountByBlockHash",
    36  		[]any{hash},
    37  		module.WithRetWrapper(module.HexUintRetWrapper),
    38  	)
    39  }
    40  
    41  // UncleCountByBlockNumber requests the number of uncles of the block with the
    42  // given number.
    43  func UncleCountByBlockNumber(number *big.Int) w3types.RPCCallerFactory[uint] {
    44  	return module.NewFactory(
    45  		"eth_getUncleCountByBlockNumber",
    46  		[]any{module.BlockNumberArg(number)},
    47  		module.WithRetWrapper(module.HexUintRetWrapper),
    48  	)
    49  }