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