Skip to content
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
- Added support to show on the BitBox when a transaction's recipient is an address of a different account on the device.
- Persist third party widget sessions

# v4.47.3
- Upgrade Etherscan API to V2

# v4.47.2
- Linux: fix compatiblity with some versions of Mesa that are incompatible with the bundled wayland libraries

Expand Down
6 changes: 3 additions & 3 deletions backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -520,19 +520,19 @@ func (backend *Backend) Coin(code coinpkg.Code) (coinpkg.Coin, error) {
coin = btc.NewCoin(coinpkg.CodeLTC, "Litecoin", "LTC", coinpkg.BtcUnitDefault, &ltc.MainNetParams, dbFolder, servers,
"https://blockchair.com/litecoin/transaction/", backend.socksProxy)
case code == coinpkg.CodeETH:
etherScan := etherscan.NewEtherScan("https://api.etherscan.io/api", backend.etherScanHTTPClient)
etherScan := etherscan.NewEtherScan("1", backend.etherScanHTTPClient)
coin = eth.NewCoin(etherScan, code, "Ethereum", "ETH", "ETH", params.MainnetChainConfig,
"https://etherscan.io/tx/",
etherScan,
nil)
case code == coinpkg.CodeSEPETH:
etherScan := etherscan.NewEtherScan("https://api-sepolia.etherscan.io/api", backend.etherScanHTTPClient)
etherScan := etherscan.NewEtherScan("11155111", backend.etherScanHTTPClient)
coin = eth.NewCoin(etherScan, code, "Ethereum Sepolia", "SEPETH", "SEPETH", params.SepoliaChainConfig,
"https://sepolia.etherscan.io/tx/",
etherScan,
nil)
case erc20Token != nil:
etherScan := etherscan.NewEtherScan("https://api.etherscan.io/api", backend.etherScanHTTPClient)
etherScan := etherscan.NewEtherScan("1", backend.etherScanHTTPClient)
coin = eth.NewCoin(etherScan, erc20Token.code, erc20Token.name, erc20Token.unit, "ETH", params.MainnetChainConfig,
"https://etherscan.io/tx/",
etherScan,
Expand Down
7 changes: 5 additions & 2 deletions backend/coins/eth/etherscan/etherscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,16 @@ type EtherScan struct {
url string
httpClient *http.Client
limiter *rate.Limiter
chainId string
}

// NewEtherScan creates a new instance of EtherScan.
func NewEtherScan(url string, httpClient *http.Client) *EtherScan {
func NewEtherScan(chainId string, httpClient *http.Client) *EtherScan {
return &EtherScan{
url: url,
url: "https://api.etherscan.io/v2/api",
httpClient: httpClient,
limiter: rate.NewLimiter(rate.Limit(callsPerSec), 1),
chainId: chainId,
}
}

Expand All @@ -69,6 +71,7 @@ func (etherScan *EtherScan) call(ctx context.Context, params url.Values, result
return errp.WithStack(err)
}
params.Set("apikey", apiKey)
params.Set("chainId", etherScan.chainId)
response, err := etherScan.httpClient.Get(etherScan.url + "?" + params.Encode())
if err != nil {
return errp.WithStack(err)
Expand Down