Skip to content

Commit

Permalink
Add Alchemy endpoint for Arbitrum Sepolia (#3665)
Browse files Browse the repository at this point in the history
### What

As Alchemy started to support Arbitrum Sepolia we can switch the wallet
to use Alchemy endpoint by default.

Issues:
- ethers providers doesn't know about Arbitrum Sepolia network,
workaround was added (same as for eth sepolia network)
- seems like there is a problem with using `external` flag for
`alchemy_getAssetTransfers` on Arb Sepolia, it is responding with server
error that these are not supported on a given chain [despite docs
claiming
otherwise](https://docs.alchemy.com/reference/alchemy-getassettransfers)
- `alchemy_getTokenBalances` is failing often with server error
(timeout) - seems like it is a problem on Alchemy side

These are not totally blocking because most of the time requests are
working fine and we have backup providers as well but I would rather
talk to Alchemy support about these problems first, before merging this
PR.

### Testing steps

- [ ] reinstall extension/reload background script
- [ ] open the background console
- [ ] add some accounts, use Arbitrum sepolia network
- [ ] make sure requests are going through the Alchemy's Arbitrum
Sepolia endpoint

Latest build:
[extension-builds-3665](https://github.com/tahowallet/extension/suites/18347933259/artifacts/1061913309)
(as of Mon, 20 Nov 2023 16:33:19 GMT).
  • Loading branch information
ioay committed Nov 22, 2023
2 parents 080b4d0 + 66715c9 commit 8d6acb3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 9 additions & 4 deletions background/constants/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,15 @@ export const NETWORKS_SUPPORTING_SWAPS = new Set(
)

export const ALCHEMY_SUPPORTED_CHAIN_IDS = new Set(
// TODO: Add `ARBITRUM_SEPOLIA` once Alchemy creates a dedicated RPC.
[ETHEREUM, POLYGON, ARBITRUM_ONE, OPTIMISM, GOERLI, SEPOLIA].map(
(network) => network.chainID,
),
[
ETHEREUM,
POLYGON,
ARBITRUM_ONE,
OPTIMISM,
GOERLI,
SEPOLIA,
ARBITRUM_SEPOLIA,
].map((network) => network.chainID),
)

export const FLASHBOTS_SUPPORTED_CHAIN_IDS = new Set([ETHEREUM.chainID])
Expand Down
7 changes: 5 additions & 2 deletions background/services/chain/taho-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ import { ConnectionInfo } from "@ethersproject/web"
export default class TahoAlchemyProvider extends AlchemyProvider {
static override getUrl(network: Network, apiKey: string): ConnectionInfo {
let host = null
switch (network.name) {
case "sepolia":
switch (network.chainId) {
case 11155111: // Ethereum Sepolia
host = "eth-sepolia.g.alchemy.com/v2/"
break
case 421614: // Arbitrum Sepolia
host = "arb-sepolia.g.alchemy.com/v2/"
break
default:
return AlchemyProvider.getUrl(network, apiKey)
}
Expand Down

0 comments on commit 8d6acb3

Please sign in to comment.