• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lmittmann / w3 / 7496150241

12 Jan 2024 12:19AM UTC coverage: 77.601%. Remained the same
7496150241

Pull #99

github

web-flow
build(deps): bump github.com/ethereum/go-ethereum in /examples

Bumps [github.com/ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) from 1.13.8 to 1.13.10.
- [Release notes](https://github.com/ethereum/go-ethereum/releases)
- [Commits](https://github.com/ethereum/go-ethereum/compare/v1.13.8...v1.13.10)

---
updated-dependencies:
- dependency-name: github.com/ethereum/go-ethereum
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #99: build(deps): bump github.com/ethereum/go-ethereum from 1.13.8 to 1.13.10 in /examples

1805 of 2326 relevant lines covered (77.6%)

1420.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.81
/module/eth/get_logs.go
1
package eth
2

3
import (
4
        "fmt"
5

6
        "github.com/ethereum/go-ethereum"
7
        "github.com/ethereum/go-ethereum/core/types"
8
        "github.com/ethereum/go-ethereum/rpc"
9
        "github.com/lmittmann/w3/internal/module"
10
        "github.com/lmittmann/w3/w3types"
11
)
12

13
// Logs requests the logs of the given ethereum.FilterQuery q.
14
func Logs(q ethereum.FilterQuery) w3types.CallerFactory[[]types.Log] {
1✔
15
        return &logsFactory{filterQuery: q}
1✔
16
}
1✔
17

18
type logsFactory struct {
19
        // args
20
        filterQuery ethereum.FilterQuery
21

22
        // returns
23
        returns *[]types.Log
24
}
25

26
func (f *logsFactory) Returns(logs *[]types.Log) w3types.Caller {
1✔
27
        f.returns = logs
1✔
28
        return f
1✔
29
}
1✔
30

31
// CreateRequest implements the w3types.RequestCreator interface.
32
func (f *logsFactory) CreateRequest() (rpc.BatchElem, error) {
1✔
33
        arg, err := toFilterArg(f.filterQuery)
1✔
34
        if err != nil {
1✔
35
                return rpc.BatchElem{}, err
×
36
        }
×
37

38
        return rpc.BatchElem{
1✔
39
                Method: "eth_getLogs",
1✔
40
                Args:   []any{arg},
1✔
41
                Result: f.returns,
1✔
42
        }, nil
1✔
43
}
44

45
// HandleResponse implements the w3types.ResponseHandler interface.
46
func (f *logsFactory) HandleResponse(elem rpc.BatchElem) error {
1✔
47
        if err := elem.Error; err != nil {
1✔
48
                return err
×
49
        }
×
50
        return nil
1✔
51
}
52

53
func toFilterArg(q ethereum.FilterQuery) (any, error) {
1✔
54
        arg := map[string]any{
1✔
55
                "topics": q.Topics,
1✔
56
        }
1✔
57
        if len(q.Addresses) > 0 {
1✔
58
                arg["address"] = q.Addresses
×
59
        }
×
60
        if q.BlockHash != nil {
1✔
61
                arg["blockHash"] = *q.BlockHash
×
62
                if q.FromBlock != nil || q.ToBlock != nil {
×
63
                        return nil, fmt.Errorf("cannot specify both BlockHash and FromBlock/ToBlock")
×
64
                }
×
65
        } else {
1✔
66
                if q.FromBlock == nil {
1✔
67
                        arg["fromBlock"] = "0x0"
×
68
                } else {
1✔
69
                        arg["fromBlock"] = module.BlockNumberArg(q.FromBlock)
1✔
70
                }
1✔
71
                arg["toBlock"] = module.BlockNumberArg(q.ToBlock)
1✔
72
        }
73
        return arg, nil
1✔
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc