Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
feat: add public RPC URLs to Chains (#63)
Browse files Browse the repository at this point in the history
* don't expose API on addNetwork

* add public RPC endpoints

* chore: changeset

Co-authored-by: agsola <[email protected]>
Co-authored-by: jxom <[email protected]>
  • Loading branch information
3 people authored Jan 18, 2023
1 parent 6150705 commit dba0258
Show file tree
Hide file tree
Showing 33 changed files with 71 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/nasty-coins-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wagmi/chains": patch
---

Added `public` RPC URLs to Chains for public RPC endpoints.
3 changes: 3 additions & 0 deletions packages/chains/src/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const arbitrum: Chain = {
default: {
http: ['https://arb1.arbitrum.io/rpc'],
},
public: {
http: ['https://arb1.arbitrum.io/rpc'],
},
},
blockExplorers: {
etherscan: { name: 'Arbiscan', url: 'https://arbiscan.io' },
Expand Down
3 changes: 3 additions & 0 deletions packages/chains/src/arbitrumGoerli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const arbitrumGoerli: Chain = {
default: {
http: ['https://goerli-rollup.arbitrum.io/rpc'],
},
public: {
http: ['https://goerli-rollup.arbitrum.io/rpc'],
},
},
blockExplorers: {
etherscan: { name: 'Arbiscan', url: 'https://goerli.arbiscan.io/' },
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/avalanche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const avalanche: Chain = {
},
rpcUrls: {
default: { http: ['https://api.avax.network/ext/bc/C/rpc'] },
public: { http: ['https://api.avax.network/ext/bc/C/rpc'] },
},
blockExplorers: {
etherscan: { name: 'SnowTrace', url: 'https://snowtrace.io' },
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/avalancheFuji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const avalancheFuji: Chain = {
},
rpcUrls: {
default: { http: ['https://api.avax-test.network/ext/bc/C/rpc'] },
public: { http: ['https://api.avax-test.network/ext/bc/C/rpc'] },
},
blockExplorers: {
etherscan: { name: 'SnowTrace', url: 'https://testnet.snowtrace.io' },
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/bsc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const bsc: Chain = {
},
rpcUrls: {
default: { http: ['https://rpc.ankr.com/bsc'] },
public: { http: ['https://rpc.ankr.com/bsc'] },
},
blockExplorers: {
etherscan: { name: 'BscScan', url: 'https://bscscan.com' },
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/bscTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const bscTestnet: Chain = {
},
rpcUrls: {
default: { http: ['https://bsc-testnet.public.blastapi.io'] },
public: { http: ['https://bsc-testnet.public.blastapi.io'] },
},
blockExplorers: {
etherscan: { name: 'BscScan', url: 'https://testnet.bscscan.com' },
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/evmos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const evmos: Chain = {
},
rpcUrls: {
default: { http: ['https://eth.bd.evmos.org:8545'] },
public: { http: ['https://eth.bd.evmos.org:8545'] },
},
blockExplorers: {
default: { name: 'Evmos Block Explorer', url: 'https://escan.live/' },
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/evmosTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const evmosTestnet: Chain = {
},
rpcUrls: {
default: { http: ['https://eth.bd.evmos.dev:8545'] },
public: { http: ['https://eth.bd.evmos.dev:8545'] },
},
blockExplorers: {
default: {
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/fantom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const fantom: Chain = {
},
rpcUrls: {
default: { http: ['https://rpc.ankr.com/fantom'] },
public: { http: ['https://rpc.ankr.com/fantom'] },
},
blockExplorers: {
etherscan: { name: 'FTMScan', url: 'https://ftmscan.com' },
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/fantomTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const fantomTestnet: Chain = {
},
rpcUrls: {
default: { http: ['https://rpc.testnet.fantom.network'] },
public: { http: ['https://rpc.testnet.fantom.network'] },
},
blockExplorers: {
etherscan: { name: 'FTMScan', url: 'https://testnet.ftmscan.com' },
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/foundry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export const foundry: Chain = {
},
rpcUrls: {
default: { http: ['http://127.0.0.1:8545'] },
public: { http: ['http://127.0.0.1:8545'] },
},
}
1 change: 1 addition & 0 deletions packages/chains/src/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const gnosis: Chain = {
},
rpcUrls: {
default: { http: ['https://rpc.gnosischain.com'] },
public: { http: ['https://rpc.gnosischain.com'] },
},
blockExplorers: {
etherscan: {
Expand Down
3 changes: 3 additions & 0 deletions packages/chains/src/goerli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const goerli: Chain = {
default: {
http: ['https://rpc.ankr.com/eth_goerli'],
},
public: {
http: ['https://rpc.ankr.com/eth_goerli'],
},
},
blockExplorers: {
etherscan: {
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/hardhat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export const hardhat: Chain = {
},
rpcUrls: {
default: { http: ['http://127.0.0.1:8545'] },
public: { http: ['http://127.0.0.1:8545'] },
},
}
4 changes: 4 additions & 0 deletions packages/chains/src/iotex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export const iotex: Chain = {
http: ['https://babel-api.mainnet.iotex.io'],
webSocket: ['wss://babel-api.mainnet.iotex.io'],
},
public: {
http: ['https://babel-api.mainnet.iotex.io'],
webSocket: ['wss://babel-api.mainnet.iotex.io'],
},
},
blockExplorers: {
default: { name: 'IoTeXScan', url: 'https://iotexscan.io' },
Expand Down
4 changes: 4 additions & 0 deletions packages/chains/src/iotexTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export const iotexTestnet: Chain = {
http: ['https://babel-api.testnet.iotex.io'],
webSocket: ['wss://babel-api.testnet.iotex.io'],
},
public: {
http: ['https://babel-api.testnet.iotex.io'],
webSocket: ['wss://babel-api.testnet.iotex.io'],
},
},
blockExplorers: {
default: { name: 'IoTeXScan', url: 'https://testnet.iotexscan.io' },
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/localhost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export const localhost: Chain = {
},
rpcUrls: {
default: { http: ['http://127.0.0.1:8545'] },
public: { http: ['http://127.0.0.1:8545'] },
},
}
3 changes: 3 additions & 0 deletions packages/chains/src/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const mainnet: Chain = {
default: {
http: ['https://cloudflare-eth.com'],
},
public: {
http: ['https://cloudflare-eth.com'],
},
},
blockExplorers: {
etherscan: {
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/metis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const metis: Chain = {
},
rpcUrls: {
default: { http: ['https://andromeda.metis.io/?owner=1088'] },
public: { http: ['https://andromeda.metis.io/?owner=1088'] },
},
blockExplorers: {
default: {
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/metisGoerli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const metisGoerli: Chain = {
},
rpcUrls: {
default: { http: ['https://goerli.gateway.metisdevops.link'] },
public: { http: ['https://goerli.gateway.metisdevops.link'] },
},
blockExplorers: {
default: {
Expand Down
3 changes: 3 additions & 0 deletions packages/chains/src/optimism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const optimism: Chain = {
default: {
http: ['https://mainnet.optimism.io'],
},
public: {
http: ['https://mainnet.optimism.io'],
},
},
blockExplorers: {
etherscan: {
Expand Down
3 changes: 3 additions & 0 deletions packages/chains/src/optimismGoerli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const optimismGoerli: Chain = {
default: {
http: ['https://goerli.optimism.io'],
},
public: {
http: ['https://goerli.optimism.io'],
},
},
blockExplorers: {
etherscan: {
Expand Down
3 changes: 3 additions & 0 deletions packages/chains/src/polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const polygon: Chain = {
default: {
http: ['https://polygon-rpc.com'],
},
public: {
http: ['https://polygon-rpc.com'],
},
},
blockExplorers: {
etherscan: {
Expand Down
3 changes: 3 additions & 0 deletions packages/chains/src/polygonMumbai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const polygonMumbai: Chain = {
default: {
http: ['https://matic-mumbai.chainstacklabs.com'],
},
public: {
http: ['https://matic-mumbai.chainstacklabs.com'],
},
},
blockExplorers: {
etherscan: {
Expand Down
3 changes: 3 additions & 0 deletions packages/chains/src/sepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const sepolia: Chain = {
default: {
http: ['https://rpc.sepolia.org'],
},
public: {
http: ['https://rpc.sepolia.org'],
},
},
blockExplorers: {
etherscan: {
Expand Down
3 changes: 3 additions & 0 deletions packages/chains/src/taraxa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export const taraxa: Chain = {
default: {
http: ['https://rpc.mainnet.taraxa.io'],
},
public: {
http: ['https://rpc.mainnet.taraxa.io'],
},
},
blockExplorers: {
default: {
Expand Down
3 changes: 3 additions & 0 deletions packages/chains/src/taraxaTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export const taraxaTestnet: Chain = {
default: {
http: ['https://rpc.testnet.taraxa.io'],
},
public: {
http: ['https://rpc.testnet.taraxa.io'],
},
},
blockExplorers: {
default: {
Expand Down
1 change: 1 addition & 0 deletions packages/chains/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Chain = {
rpcUrls: {
[key: string]: RpcUrls
default: RpcUrls
public: RpcUrls
}
/** Collection of block explorers */
blockExplorers?: {
Expand Down
4 changes: 4 additions & 0 deletions packages/chains/src/zkSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export const zkSync: Chain = {
http: ['https://zksync2-mainnet.zksync.io'],
webSocket: ['wss://zksync2-mainnet.zksync.io/ws'],
},
public: {
http: ['https://zksync2-mainnet.zksync.io'],
webSocket: ['wss://zksync2-mainnet.zksync.io/ws'],
},
},
blockExplorers: {
default: {
Expand Down
4 changes: 4 additions & 0 deletions packages/chains/src/zkSyncTestnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const zkSyncTestnet: Chain = {
http: ['https://zksync2-testnet.zksync.dev'],
webSocket: ['wss://zksync2-testnet.zksync.dev/ws'],
},
public: {
http: ['https://zksync2-testnet.zksync.dev'],
webSocket: ['wss://zksync2-testnet.zksync.dev/ws'],
},
},
blockExplorers: {
default: {
Expand Down
5 changes: 1 addition & 4 deletions packages/connectors/src/coinbaseWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,7 @@ export class CoinbaseWalletConnector extends Connector<
chainId: id,
chainName: chain.name,
nativeCurrency: chain.nativeCurrency,
rpcUrls: [
chain.rpcUrls.public?.http[0] ??
chain.rpcUrls.default.http[0],
],
rpcUrls: [chain.rpcUrls.public?.http[0] ?? ''],
blockExplorerUrls: this.getBlockExplorerUrls(chain),
},
],
Expand Down
6 changes: 1 addition & 5 deletions packages/connectors/src/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,7 @@ export class InjectedConnector extends Connector<
chainId: id,
chainName: chain.name,
nativeCurrency: chain.nativeCurrency,
rpcUrls: [
chain.rpcUrls.public?.http[0] ??
chain.rpcUrls.default.http[0] ??
'',
],
rpcUrls: [chain.rpcUrls.public?.http[0] ?? ''],
blockExplorerUrls: this.getBlockExplorerUrls(chain),
},
],
Expand Down

0 comments on commit dba0258

Please sign in to comment.