8000 fix missing chain id by ductm54 · Pull Request #60 · tranvictor/jarvis · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

fix missing chain id #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion networks/arbitrum.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewArbitrumMainnet() *arbitrumMainnet {
"infura": "https://arb1.arbitrum.io/rpc",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.arbiscan.io/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0x80C7DD17B01855a6D2347444a0FCC36136a314de"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/avalanche.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewAvalanche() *avalanche {
"avalanche": "https://api.avax.network/ext/bc/C/rpc",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.snowtrace.io/api",
BlockExplorerAPIURL: "https://api.routescan.io/v2/network/mainnet/evm/43114/etherscan/",
MultiCallContractAddress: common.HexToAddress("0xa00FB557AA68d2e98A830642DBbFA534E8512E5f"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewBaseMainnet() *baseMainnet {
"public-base": "https://mainnet.base.org",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.basescan.org/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xcA11bde05977b3631167028862bE2a173976CA11"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/bsc.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func NewBSCMainnet() *bscMainnet {
"ninicoin": "https://bsc-dataseed1.ninicoin.io",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.bscscan.com/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0x41263cba59eb80dc200f3e2544eda4ed6a90e76c"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/bsc_testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewBSCTestnet() *bscTestnet {
"binance6": "https://data-seed-prebsc-2-s3.binance.org:8545",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.bscscan.com/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xae11C5B5f29A6a25e955F0CB8ddCc416f522AF5C"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/bttc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewBttcMainnet() *bttcMainnet {
"bt.io": "https://rpc.bt.io",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.bttcscan.com/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xBF69a56D35B8d6f5A8e0e96B245a72F735751e54"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/ethereum_mainnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewEthereumMainnet() *ethereumMainnet {
"mainnet-kyber": "https://ethereum.kyberengineering.io",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.etherscan.io/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xeefba1e63905ef1d7acba5a8513c70307c1ce441"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/ethereum_pow.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewEthereumPOW() *ethereumPOW {
"ethpow-team": "https://mainnet.ethereumpow.org",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.etherscan.io/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xeefba1e63905ef1d7acba5a8513c70307c1ce441"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/fantom.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewFantom() *fantom {
"fantom": "https://rpc.ftm.tools/",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.ftmscan.com/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xcf591ce5574258aC4550D96c545e4F3fd49A74ec"),
}),
}
Expand Down
12 changes: 7 additions & 5 deletions networks/generic_etherscan_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/tranvictor/jarvis/util/explorers"
)

const defaultAPIKey = "UBB257TI824FC7HUSPT66KZUMGBPRN3IWV"

type GenericEtherscanNetworkConfig struct {
Name string `json:"name"`
AlternativeNames []string `json:"alternative_names"`
Expand All @@ -32,14 +34,14 @@ type GenericEtherscanNetwork struct {
}

func NewGenericEtherscanNetwork(config GenericEtherscanNetworkConfig) *GenericEtherscanNetwork {
apiKey := strings.Trim(os.Getenv(config.BlockExplorerAPIKeyVariableName), " ")
if apiKey == "" {
apiKey = defaultAPIKey
}
result := &GenericEtherscanNetwork{
EtherscanLikeExplorer: explorers.NewEtherscanV2(),
EtherscanLikeExplorer: explorers.NewEtherscanLikeExplorer(config.BlockExplorerAPIURL, apiKey, config.ChainID),
Config: config,
}
apiKey := strings.Trim(os.Getenv(result.GetBlockExplorerAPIKeyVariableName()), " ")
if apiKey != "" {
result.EtherscanLikeExplorer.APIKey = apiKey
}
return result
}

Expand Down
2 changes: 1 addition & 1 deletion networks/kovan.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewKovan() *kovan {
"kovan-infura": "https://kovan.infura.io/v3/247128ae36b6444d944d4c3793c8e3f5",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.etherscan.io/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/linea.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewlineaMainnet() *lineaMainnet {
"infura-linea": "https://linea-mainnet.infura.io/v3/1556a477007b49cda01f9f3df4d97edd",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.etherscan.io/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xcA11bde05977b3631167028862bE2a173976CA11"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/matic.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewMatic() *matic {
"kyber": "https://polygon.kyberengineering.io",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.polygonscan.com/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0x11ce4B23bD875D7F5C6a31084f55fDe1e9A87507"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/mumbai.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewMumbai() *mumbai {
"infura-mumbai": "https://polygon-mumbai.infura.io/v3/247128ae36b6444d944d4c3793c8e3f5",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.polygonscan.com/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0x08411ADd0b5AA8ee47563b146743C13b3556c9Cc"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/optimism.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewOptimismMainnet() *optimismMainnet {
"mainnet-optimism": "https://mainnet.optimism.io",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.optimistic.etherscan.io/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xD9bfE9979e9CA4b2fe84bA5d4Cf963bBcB376974"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/polygon_zkevm.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewPolygonZkevmMainnet() *polygonZkevmMainnet {
"public-polygonZkevm": "https://zkevm-rpc.com",
},
BlockExplorerAPIKeyVariableName: "POLYGON_ZKEVMSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.polygonzkevmscan.com/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xcA11bde05977b3631167028862bE2a173976CA11"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/rinkeby.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func NewRinkeby() *rinkeby {
"rinkeby-infura": "https://rinkeby.infura.io/v3/247128ae36b6444d944d4c3793c8e3f5",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.etherscan.io/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/ropsten.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewRopsten() *ropsten {
"ropsten-infura": "https://ropsten.infura.io/v3/247128ae36b6444d944d4c3793c8e3f5",
},
BlockExplorerAPIKeyVariableName: "ETHERSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.etherscan.io/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0x53c43764255c17bd724f74c4ef150724ac50a3ed"),
}),
}
Expand Down
2 changes: 1 addition & 1 deletion networks/scroll.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func NewScrollMainnet() *scrollMainnet {
"public-scroll": "https://rpc.scroll.io",
},
BlockExplorerAPIKeyVariableName: "SCROLLSCAN_API_KEY",
BlockExplorerAPIURL: "https://api.scrollscan.com/api",
BlockExplorerAPIURL: "https://api.etherscan.io/v2",
MultiCallContractAddress: common.HexToAddress("0xcA11bde05977b3631167028862bE2a173976CA11"),
}),
}
Expand Down
14 changes: 0 additions & 14 deletions txanalyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,3 @@ func (self *TxAnalyzer) AnalyzeOffline(
func NewGenericAnalyzer(r *reader.EthReader, network Network) *TxAnalyzer {
return &TxAnalyzer{r, network}
}

func NewAnalyzer() *TxAnalyzer {
return &TxAnalyzer{
reader.NewEthReader(),
EthereumMainnet,
}
}

func NewRopstenAnalyzer() *TxAnalyzer {
return &TxAnalyzer{
reader.NewRopstenReader(),
Ropsten,
}
}
9 changes: 5 additions & 4 deletions util/explorers/etherscan_alike_explorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ type EtherscanLikeExplorer struct {
APIKey string
}

func NewEtherscanLikeExplorer(domain string, apiKey string) *EtherscanLikeExplorer {
func NewEtherscanLikeExplorer(domain string, apiKey string, chainID uint64) *EtherscanLikeExplorer {
return &EtherscanLikeExplorer{
gpmu: sync.Mutex{},
Domain: domain,
APIKey: apiKey,
gpmu: sync.Mutex{},
Domain: domain,
APIKey: apiKey,
ChainID: chainID,
}
}

Expand Down
54 changes: 0 additions & 54 deletions util/explorers/explorers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,3 @@ type BlockExplorer interface {
RecommendedGasPrice() (float64, error)
GetABIString(address string) (string, error)
}

func NewEtherscanV2() *EtherscanLikeExplorer {
return NewEtherscanLikeExplorer(
"https://api.etherscan.io/v2",
"UBB257TI824FC7HUSPT66KZUMGBPRN3IWV",
)
}

func NewMainnetEtherscan() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewRopstenEtherscan() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewRinkebyEtherscan() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewKovanEtherscan() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewBscscan() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewTestnetBscscan() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewPolygonscan() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewFtmscan() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewMumbaiPolygonscan() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewTomoBlockExplorer() *EtherscanLikeExplorer {
return NewEtherscanV2()
}

func NewSnowtrace() *EtherscanLikeExplorer {
return NewEtherscanLikeExplorer(
"https://api.routescan.io/v2/network/mai B637 nnet/evm/43114/etherscan/",
"NWT5MMCQMAPYH47DGD8K7QIJGP2DHZRMW3",
)
}
12 changes: 0 additions & 12 deletions util/monitor/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,6 @@ func NewGenericTxMonitor(r *reader.EthReader) *TxMonitor {
return &TxMonitor{r}
}

func NewRopstenTxMonitor() *TxMonitor {
return &TxMonitor{
reader: reader.NewRopstenReader(),
}
}

func NewTxMonitor() *TxMonitor {
return &TxMonitor{
reader: reader.NewEthReader(),
}
}

func (self TxMonitor) periodicCheck(tx string, info chan common.TxInfo) {
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
Expand Down
Loading
0