Skip to content

Commit

Permalink
if localnet, be less strict on the expected chainID
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Feb 4, 2025
1 parent 2425295 commit 10e1281
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/solana/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"math/big"
"math/rand"
"slices"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -150,7 +151,9 @@ func (v *verifiedCachedClient) verifyChainID(ctx context.Context) (bool, error)

// check chainID matches expected chainID
expectedChainID := strings.ToLower(v.expectedChainID)
if v.chainID != expectedChainID {
// if this is localnet, allow any chain ID as long as it's not spoofing an official network
ignore := v.chainID == "localnet" && !slices.Contains([]string{"mainnet", "testnet", "devnet"}, expectedChainID)
if !ignore && v.chainID != expectedChainID {
v.chainIDVerified = false
return v.chainIDVerified, fmt.Errorf("client returned mismatched chain id (expected: %s, got: %s): %s", expectedChainID, v.chainID, v.nodeURL)
}
Expand Down

0 comments on commit 10e1281

Please sign in to comment.