Skip to content

Commit dc3484a

Browse files
committed
Merge pull request #123 from KyberNetwork/ft/custom-client-flag
ft/custom client flag
2 parents 8c3bec5 + 172e4eb commit dc3484a

File tree

6 files changed

+72
-149
lines changed

6 files changed

+72
-149
lines changed

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ require (
77
github.com/KyberNetwork/kyber-trace-go v0.1.1
88
github.com/TheZeroSlave/zapsentry v1.12.0
99
github.com/emirpasic/gods v1.18.1
10-
github.com/ethereum/go-ethereum v1.14.11
10+
github.com/ethereum/go-ethereum v1.14.13
1111
github.com/getsentry/sentry-go v0.27.0
1212
github.com/gorilla/websocket v1.5.0
1313
github.com/redis/go-redis/v9 v9.2.1
1414
github.com/stretchr/testify v1.9.0
1515
github.com/urfave/cli/v2 v2.25.7
1616
go.opentelemetry.io/otel/metric v1.22.0
1717
go.uber.org/zap v1.26.0
18-
golang.org/x/crypto v0.29.0
1918
golang.org/x/sync v0.9.0
2019
google.golang.org/protobuf v1.34.2
2120
)
@@ -24,7 +23,6 @@ require (
2423
github.com/DataDog/zstd v1.5.2 // indirect
2524
github.com/Microsoft/go-winio v0.6.2 // indirect
2625
github.com/bits-and-blooms/bitset v1.14.3 // indirect
27-
github.com/btcsuite/btcd/btcec/v2 v2.3.4 // indirect
2826
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
2927
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3028
github.com/consensys/bavard v0.1.22 // indirect
@@ -41,7 +39,6 @@ require (
4139
github.com/eapache/queue v1.1.0 // indirect
4240
github.com/ethereum/c-kzg-4844 v1.0.3 // indirect
4341
github.com/ethereum/go-verkle v0.2.2 // indirect
44-
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 // indirect
4542
github.com/go-logr/logr v1.4.1 // indirect
4643
github.com/go-logr/stdr v1.2.2 // indirect
4744
github.com/go-ole/go-ole v1.3.0 // indirect
@@ -86,6 +83,7 @@ require (
8683
go.opentelemetry.io/otel/trace v1.22.0 // indirect
8784
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
8885
go.uber.org/multierr v1.10.0 // indirect
86+
golang.org/x/crypto v0.29.0 // indirect
8987
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
9088
golang.org/x/net v0.25.0 // indirect
9189
golang.org/x/sys v0.27.0 // indirect

go.sum

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
1818
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
1919
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
2020
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
21-
github.com/btcsuite/btcd/btcec/v2 v2.3.4 h1:3EJjcN70HCu/mwqlUsGK8GcNVyLVxFDlWurTXGPFfiQ=
22-
github.com/btcsuite/btcd/btcec/v2 v2.3.4/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
23-
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
24-
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
2521
github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM=
2622
github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
2723
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
@@ -72,19 +68,15 @@ github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc
7268
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
7369
github.com/ethereum/c-kzg-4844 v1.0.3 h1:IEnbOHwjixW2cTvKRUlAAUOeleV7nNM/umJR+qy4WDs=
7470
github.com/ethereum/c-kzg-4844 v1.0.3/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
75-
github.com/ethereum/go-ethereum v1.14.11 h1:8nFDCUUE67rPc6AKxFj7JKaOa2W/W1Rse3oS6LvvxEY=
76-
github.com/ethereum/go-ethereum v1.14.11/go.mod h1:+l/fr42Mma+xBnhefL/+z11/hcmJ2egl+ScIVPjhc7E=
71+
github.com/ethereum/go-ethereum v1.14.13 h1:L81Wmv0OUP6cf4CW6wtXsr23RUrDhKs2+Y9Qto+OgHU=
72+
github.com/ethereum/go-ethereum v1.14.13/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY=
7773
github.com/ethereum/go-verkle v0.2.2 h1:I2W0WjnrFUIzzVPwm8ykY+7pL2d4VhlsePn4j7cnFk8=
7874
github.com/ethereum/go-verkle v0.2.2/go.mod h1:M3b90YRnzqKyyzBEWJGqj8Qff4IDeXnzFw0P9bFw3uk=
7975
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
8076
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
8177
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
8278
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
8379
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
84-
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
85-
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
86-
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
87-
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
8880
github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps=
8981
github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY=
9082
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
@@ -102,8 +94,8 @@ github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
10294
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
10395
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
10496
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
105-
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
106-
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
97+
github.com/golang-jwt/jwt/v4 v4.5.1 h1:JdqV9zKUdtaa9gdPlywC3aeoEsR681PlKC+4F5gQgeo=
98+
github.com/golang-jwt/jwt/v4 v4.5.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
10799
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
108100
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
109101
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
@@ -126,8 +118,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
126118
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
127119
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
128120
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
129-
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
130-
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
131121
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
132122
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
133123
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
@@ -235,8 +225,6 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
235225
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
236226
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
237227
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
238-
github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA=
239-
github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg=
240228
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
241229
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
242230
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -256,8 +244,6 @@ github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFA
256244
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
257245
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
258246
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
259-
github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8=
260-
github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U=
261247
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
262248
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
263249
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=

internal/app/app.go

Lines changed: 36 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package app
22

33
import (
4-
"context"
54
"net/http"
6-
"strconv"
75
"time"
86

97
"github.com/KyberNetwork/evmlistener/pkg/block"
@@ -21,7 +19,7 @@ const (
2119
defaultRequestTimeout = 10 * time.Second
2220
)
2321

24-
// NewApp creates a new cli App instance with common flags pre-loaded.
22+
// NewApp creates a new cli App instance with common flags preloaded.
2523
func NewApp() *cli.App {
2624
app := cli.NewApp()
2725
app.Flags = NewFlags()
@@ -31,18 +29,18 @@ func NewApp() *cli.App {
3129

3230
func redisConfigFromCli(c *cli.Context) redis.Config {
3331
cfg := redis.Config{
34-
MasterName: c.String(redisMasterNameFlag.Name),
35-
Addrs: c.StringSlice(redisAddrsFlag.Name),
36-
DB: c.Int(redisDBFlag.Name),
37-
KeyPrefix: c.String(redisKeyPrefixFlag.Name),
38-
ReadTimeout: c.Duration(redisReadTimeoutFlag.Name),
39-
WriteTimeout: c.Duration(redisWriteTimeoutFlag.Name),
32+
MasterName: redisMasterNameFlag.Value,
33+
Addrs: redisAddrsFlag.Get(c),
34+
DB: redisDBFlag.Value,
35+
KeyPrefix: redisKeyPrefixFlag.Value,
36+
ReadTimeout: redisReadTimeoutFlag.Value,
37+
WriteTimeout: redisWriteTimeoutFlag.Value,
4038
}
4139

42-
cfg.SentinelUsername = c.String(redisUsernameFlag.Name)
43-
cfg.SentinelPassword = c.String(redisPasswordFlag.Name)
44-
cfg.Username = c.String(redisUsernameFlag.Name)
45-
cfg.Password = c.String(redisPasswordFlag.Name)
40+
cfg.SentinelUsername = redisUsernameFlag.Value
41+
cfg.SentinelPassword = redisPasswordFlag.Value
42+
cfg.Username = redisUsernameFlag.Value
43+
cfg.Password = redisPasswordFlag.Value
4644

4745
return cfg
4846
}
@@ -51,50 +49,52 @@ func redisConfigFromCli(c *cli.Context) redis.Config {
5149
func NewListener(c *cli.Context) (*listener.Listener, error) {
5250
l := zap.S()
5351

54-
rpcRequestTimeout := c.Duration(rpcRequestTimeoutFlag.Name)
52+
evmclient.UseCustomClient = useCustomClientFlag.Value
53+
54+
rpcRequestTimeout := rpcRequestTimeoutFlag.Value
5555
if rpcRequestTimeout == 0 {
5656
rpcRequestTimeout = defaultRequestTimeout
5757
}
5858

5959
httpClient := &http.Client{
6060
Timeout: rpcRequestTimeout,
6161
}
62-
wsRPC := c.String(wsRPCFlag.Name)
62+
wsRPC := wsRPCFlag.Value
6363
l.Infow("Connect to node websocket rpc", "rpc", wsRPC)
6464
wsEVMClient, err := evmclient.DialContextWithTimeout(
65-
context.Background(), wsRPC, httpClient, rpcRequestTimeout)
65+
c.Context, wsRPC, httpClient, rpcRequestTimeout)
6666
if err != nil {
6767
l.Errorw("Fail to connect to node", "rpc", wsRPC, "error", err)
6868

6969
return nil, err
7070
}
7171

72-
httpRPC := c.String(httpRPCFlag.Name)
72+
httpRPC := httpRPCFlag.Value
7373
l.Infow("Connect to node http rpc", "rpc", httpRPC)
7474
httpEVMClient, err := evmclient.DialContextWithTimeout(
75-
context.Background(), httpRPC, httpClient, rpcRequestTimeout)
75+
c.Context, httpRPC, httpClient, rpcRequestTimeout)
7676
if err != nil {
7777
l.Errorw("Fail to connect to node", "rpc", httpRPC, "error", err)
7878

7979
return nil, err
8080
}
8181

8282
l.Infow("Get chainID from node")
83-
chainID, err := httpEVMClient.ChainID(context.Background())
83+
chainID, err := httpEVMClient.ChainID(c.Context)
8484
if err != nil {
8585
l.Errorw("Fail to get chainID", "error", err)
8686

8787
return nil, err
8888
}
8989

90-
l = l.With("chainName", chainIDToName(chainID.Int64()))
90+
l = l.With("chainID", chainID.Int64())
9191

92-
sanityCheckInterval := c.Duration(sanityCheckIntervalFlag.Name)
92+
sanityCheckInterval := sanityCheckIntervalFlag.Value
9393
var sanityEVMClient evmclient.IClient
94-
sanityRPC := c.String(sanityNodeRPCFlag.Name)
94+
sanityRPC := sanityNodeRPCFlag.Value
9595
if sanityRPC != "" {
9696
l.Infow("Connect to public node rpc for sanity check", "rpc", sanityRPC)
97-
sanityEVMClient, err = evmclient.DialContext(context.Background(), sanityRPC, httpClient)
97+
sanityEVMClient, err = evmclient.DialContext(c.Context, sanityRPC, httpClient)
9898
if err != nil {
9999
l.Errorw("Fail to setup EVM client for sanity check", "error", err)
100100

@@ -114,22 +114,22 @@ func NewListener(c *cli.Context) (*listener.Listener, error) {
114114
return nil, err
115115
}
116116

117-
maxNumBlocks := c.Int(maxNumBlocksFlag.Name)
118-
blockExpiration := c.Duration(blockExpirationFlag.Name)
117+
maxNumBlocks := maxNumBlocksFlag.Value
118+
blockExpiration := blockExpirationFlag.Value
119119
l.Infow("Setup new BlockKeeper", "maxNumBlocks", maxNumBlocks, "expiration", blockExpiration)
120120
blockKeeper := block.NewRedisBlockKeeper(l, redisClient, maxNumBlocks, blockExpiration)
121121

122-
topic := c.String(publisherTopicFlag.Name)
122+
topic := publisherTopicFlag.Value
123123
publisher, err := getPublisher(c, redisClient, topic)
124124
if err != nil {
125125
l.Errorw("Fail to get publisher", "error", err)
126126

127127
return nil, err
128128
}
129-
encoder := getMessageEncoder(c)
129+
msgEncoder := getMessageEncoder()
130130

131131
l.Infow("Setup handler", "topic", topic)
132-
handler := listener.NewHandler(l, topic, httpEVMClient, blockKeeper, publisher, encoder,
132+
handler := listener.NewHandler(l, topic, httpEVMClient, blockKeeper, publisher, msgEncoder,
133133
listener.WithEventLogs(nil, nil))
134134

135135
l.Infow("Setup listener")
@@ -142,14 +142,14 @@ func getPublisher(c *cli.Context, redisClient *redis.Client, topic string) (publ
142142
var publisher publisherpkg.Publisher
143143
var err error
144144

145-
publisherType := c.String(publisherTypeFlag.Name)
145+
publisherType := publisherTypeFlag.Value
146146
switch publisherType {
147147
case publisherpkg.PublisherTypeKafka:
148148
config := &kafka.Config{
149-
Addresses: c.StringSlice(kafkaAddrsFlag.Name),
150-
UseAuthentication: c.Bool(kafkaUseAuthenticationFlag.Name),
151-
Username: c.String(kafkaUsernameFlag.Name),
152-
Password: c.String(kafkaPasswordFlag.Name),
149+
Addresses: kafkaAddrsFlag.Get(c),
150+
UseAuthentication: kafkaUseAuthenticationFlag.Value,
151+
Username: kafkaUsernameFlag.Value,
152+
Password: kafkaPasswordFlag.Value,
153153
}
154154
publisher, err = kafka.NewPublisher(config)
155155
if err != nil {
@@ -159,78 +159,18 @@ func getPublisher(c *cli.Context, redisClient *redis.Client, topic string) (publ
159159
return nil, err
160160
}
161161
default:
162-
maxLen := c.Int64(publisherMaxLenFlag.Name)
162+
maxLen := publisherMaxLenFlag.Value
163163
publisher = redis.NewStream(redisClient, maxLen)
164164
}
165165

166166
return publisher, err
167167
}
168168

169-
func getMessageEncoder(c *cli.Context) encoder.Encoder {
170-
encoderType := c.String(encoderTypeFlag.Name)
171-
switch encoderType {
169+
func getMessageEncoder() encoder.Encoder {
170+
switch encoderTypeFlag.Value {
172171
case encoder.EncoderTypeProtobuf:
173172
return encoder.NewProtobufEncoder()
174173
default:
175174
return encoder.NewJSONEncoder()
176175
}
177176
}
178-
179-
const (
180-
chainIDEthereum = 1
181-
chainIDOptimism = 10
182-
chainIDCronos = 25
183-
chainIDBSC = 56
184-
chainIDVelas = 106
185-
chainIDPolygon = 137
186-
chainIDBitTorrent = 199
187-
chainIDFantom = 250
188-
chainIDZKSyncEra = 324
189-
chainIDPolygonZKEVM = 1101
190-
chainIDBase = 8453
191-
chainIDArbitrum = 42161
192-
chainIDOasis = 42262
193-
chainIDAvalanche = 43114
194-
chainIDLinea = 59144
195-
chainIDAurora = 1313161554
196-
)
197-
198-
//nolint:cyclop
199-
func chainIDToName(chainID int64) string {
200-
switch chainID {
201-
case chainIDEthereum:
202-
return "Ethereum"
203-
case chainIDOptimism:
204-
return "Optimism"
205-
case chainIDCronos:
206-
return "Cronos"
207-
case chainIDBSC:
208-
return "BSC"
209-
case chainIDVelas:
210-
return "Velas"
211-
case chainIDPolygon:
212-
return "Polygon"
213-
case chainIDBitTorrent:
214-
return "BitTorrent"
215-
case chainIDFantom:
216-
return "Fantom"
217-
case chainIDArbitrum:
218-
return "Arbitrum"
219-
case chainIDOasis:
220-
return "Oasis"
221-
case chainIDAvalanche:
222-
return "Avalanche"
223-
case chainIDAurora:
224-
return "Aurora"
225-
case chainIDLinea:
226-
return "Linea"
227-
case chainIDPolygonZKEVM:
228-
return "Polygon zkEVM"
229-
case chainIDZKSyncEra:
230-
return "zkSync Era"
231-
case chainIDBase:
232-
return "Base"
233-
default:
234-
return strconv.FormatInt(chainID, 10)
235-
}
236-
}

internal/app/flags.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ var (
2626
Value: "http://localhost:8545",
2727
Usage: "HTTP RPC to connect to blockchain node, default: http://localhost:8545",
2828
}
29+
useCustomClientFlag = &cli.BoolFlag{
30+
Name: "use-custom-client",
31+
EnvVars: []string{"USE_CUSTOM_CLIENT"},
32+
Value: true,
33+
Usage: "Use custom client to connect to blockchain node",
34+
}
2935
rpcRequestTimeoutFlag = &cli.DurationFlag{
3036
Name: "rpc-request-timeout",
3137
EnvVars: []string{"RPC_REQUEST_TIMEOUT"},
@@ -218,6 +224,7 @@ func NewFlags() []cli.Flag {
218224
logLevelFlag,
219225
wsRPCFlag,
220226
httpRPCFlag,
227+
useCustomClientFlag,
221228
rpcRequestTimeoutFlag,
222229
sanityNodeRPCFlag,
223230
sanityCheckIntervalFlag,

0 commit comments

Comments
 (0)