Skip to content

Commit f190212

Browse files
authored
Added Pharos to list of log index fix (#193)
1 parent a3dda6e commit f190212

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

pkg/client/rpc_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ func ToBlockNumArg(number *big.Int) string {
13531353
func (r *RPCClient) makeLogsValid(logs []types.Log) error {
13541354

13551355
switch r.chainType {
1356-
case chaintype.ChainSei, chaintype.ChainHedera, chaintype.ChainRootstock:
1356+
case chaintype.ChainSei, chaintype.ChainHedera, chaintype.ChainRootstock, chaintype.ChainPharos:
13571357
// Sei, Rootstock and Hedera does not have unique log index position in the block.
13581358
default:
13591359
return nil
@@ -1372,7 +1372,7 @@ func (r *RPCClient) makeLogsValid(logs []types.Log) error {
13721372

13731373
func (r *RPCClient) makeLogValid(log types.Log) (types.Log, error) {
13741374
switch r.chainType {
1375-
case chaintype.ChainSei, chaintype.ChainHedera, chaintype.ChainRootstock:
1375+
case chaintype.ChainSei, chaintype.ChainHedera, chaintype.ChainRootstock, chaintype.ChainPharos:
13761376
// Sei, Rootstock and Hedera does not have unique log index position in the block.
13771377
default:
13781378
return log, nil

pkg/client/rpc_client_internal_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func TestRPCClient_MakeLogsValid(t *testing.T) {
3434
{Name: "Sei", ChainType: chaintype.ChainSei},
3535
{Name: "Hedera", ChainType: chaintype.ChainHedera},
3636
{Name: "Rootstock", ChainType: chaintype.ChainRootstock},
37+
{Name: "Pharos", ChainType: chaintype.ChainPharos},
3738
}
3839

3940
testCases := []struct {

pkg/client/rpc_client_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ func TestRPCClient_SubscribeFilterLogs(t *testing.T) {
394394
{Name: "Sei", ChainType: chaintype.ChainSei},
395395
{Name: "Hedera", ChainType: chaintype.ChainHedera},
396396
{Name: "Rootstock", ChainType: chaintype.ChainRootstock},
397+
{Name: "Pharos", ChainType: chaintype.ChainPharos},
397398
}
398399

399400
testCases := []struct {
@@ -476,6 +477,7 @@ func TestRPCClientFilterLogs(t *testing.T) {
476477
{Name: "Sei", ChainType: chaintype.ChainSei},
477478
{Name: "Hedera", ChainType: chaintype.ChainHedera},
478479
{Name: "Rootstock", ChainType: chaintype.ChainRootstock},
480+
{Name: "Pharos", ChainType: chaintype.ChainPharos},
479481
}
480482

481483
testCases := []struct {

pkg/config/chaintype/chaintype.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const (
2626
ChainZircuit ChainType = "zircuit"
2727
ChainTron ChainType = "tron"
2828
ChainRootstock ChainType = "rootstock"
29+
ChainPharos ChainType = "pharos"
2930
)
3031

3132
// IsL2 returns true if this chain is a Layer 2 chain. Notably:
@@ -42,7 +43,7 @@ func (c ChainType) IsL2() bool {
4243

4344
func (c ChainType) IsValid() bool {
4445
switch c {
45-
case "", ChainArbitrum, ChainAstar, ChainCelo, ChainGnosis, ChainHedera, ChainKroma, ChainMantle, ChainMetis, ChainOptimismBedrock, ChainSei, ChainScroll, ChainWeMix, ChainXLayer, ChainZkEvm, ChainZkSync, ChainZircuit, ChainTron, ChainRootstock:
46+
case "", ChainArbitrum, ChainAstar, ChainCelo, ChainGnosis, ChainHedera, ChainKroma, ChainMantle, ChainMetis, ChainOptimismBedrock, ChainSei, ChainScroll, ChainWeMix, ChainXLayer, ChainZkEvm, ChainZkSync, ChainZircuit, ChainTron, ChainRootstock, ChainPharos:
4647
return true
4748
}
4849
return false
@@ -86,6 +87,8 @@ func FromSlug(slug string) ChainType {
8687
return ChainTron
8788
case "rootstock":
8889
return ChainRootstock
90+
case "pharos":
91+
return ChainPharos
8992
default:
9093
return ChainType(slug)
9194
}
@@ -156,4 +159,5 @@ var ErrInvalid = fmt.Errorf("must be one of %s or omitted", strings.Join([]strin
156159
string(ChainZircuit),
157160
string(ChainTron),
158161
string(ChainRootstock),
162+
string(ChainPharos),
159163
}, ", "))

0 commit comments

Comments
 (0)