Skip to content

Commit

Permalink
feat: add support to optimism
Browse files Browse the repository at this point in the history
  • Loading branch information
PJColombo committed Nov 25, 2023
1 parent a45fbe3 commit 2dc7773
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/connect-core/src/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export const NETWORKS = [
name: 'rinkeby',
ensAddress: '0x98df287b6c145399aaa709692c8d308357bc085d',
},
{
chainId: 10,
name: 'optimism',
ensAddress: '0x6f2CA655f58d5fb94A08460aC19A552EB19909FD'
},
{
chainId: 100,
name: 'xdai',
Expand Down
4 changes: 4 additions & 0 deletions packages/connect-thegraph/src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ function getOrgSubgraphUrl(network: Network): string | null {
if (network.chainId === 4) {
return 'https://api.thegraph.com/subgraphs/name/aragon/aragon-rinkeby'
}
if (network.chainId === 10) {
return 'https://api.thegraph.com/subgraphs/name/blossomlabs/aragon-optimism'
}
if (network.chainId === 100) {
return 'https://api.thegraph.com/subgraphs/name/1hive/aragon-xdai'
}
Expand All @@ -52,6 +55,7 @@ function getOrgSubgraphUrl(network: Network): string | null {
if (network.chainId === 80001) {
return 'https://api.thegraph.com/subgraphs/name/1hive/aragon-mumbai'
}

return null
}

Expand Down
1 change: 1 addition & 0 deletions packages/connect/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export const DEFAULT_IPFS_URL = 'https://ipfs.io/ipfs/{cid}{path}'
export const MUMBAI_HTTP_ENDPOINT = 'https://rpc-mumbai.maticvigil.com'
export const POLYGON_HTTP_ENDPOINT = 'https://polygon-rpc.com'
export const XDAI_HTTP_ENDPOINT = 'https://rpc.gnosischain.com'
export const OPTIMISM_HTTP_ENDPOINT = 'https://mainnet.optimism.io'
6 changes: 6 additions & 0 deletions packages/connect/src/normalizers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
DEFAULT_IPFS_CACHED_ITEMS,
DEFAULT_IPFS_URL,
MUMBAI_HTTP_ENDPOINT,
OPTIMISM_HTTP_ENDPOINT,
POLYGON_HTTP_ENDPOINT,
XDAI_HTTP_ENDPOINT,
} from './constants'
Expand Down Expand Up @@ -124,6 +125,10 @@ export function normalizeEthersProvider(
}
}

if (network.chainId === 10) {
return new JsonRpcProvider(OPTIMISM_HTTP_ENDPOINT, network)
}

if (network.chainId === 100) {
return new JsonRpcProvider(XDAI_HTTP_ENDPOINT, network)
}
Expand All @@ -136,5 +141,6 @@ export function normalizeEthersProvider(
return new JsonRpcProvider(MUMBAI_HTTP_ENDPOINT, network)
}


return getDefaultProvider(network)
}

0 comments on commit 2dc7773

Please sign in to comment.