Skip to content

Commit

Permalink
add base network support
Browse files Browse the repository at this point in the history
  • Loading branch information
samepant committed Jan 30, 2024
1 parent c7aadb0 commit 11cb6e2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/app/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ REACT_APP_POLYGONSCAN_KEY=
REACT_APP_BSCSCAN_KEY=
REACT_APP_OPTIMISTIC_ETHERSCAN_KEY=
REACT_APP_ARBISCAN_KEY=
REACT_APP_SNOWTRACE_KEY=
REACT_APP_SNOWTRACE_KEY=
REACT_APP_BASESCAN_KEY=
4 changes: 4 additions & 0 deletions packages/app/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ export function getTellorOracle(chainId: number): string {
return "0xD9157453E2668B2fc45b7A803D3FEF3642430cC0"
case NETWORK.SEPOLIA:
return "" // TODO
case NETWORK.BASE:
return "" // TODO
}
return ""
}
Expand All @@ -118,6 +120,8 @@ export function getDefaultOracle(chainId: number): string {
return "0xD88cd78631Ea0D068cedB0d1357a6eabe59D7502"
case NETWORK.SEPOLIA:
return "" // TODO
case NETWORK.BASE:
return "" // TODO
}
return ""
}
Expand Down
14 changes: 14 additions & 0 deletions packages/app/src/utils/explorers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ if (!isDev && !REACT_APP_SNOWTRACE_KEY) {
throw new Error("REACT_APP_SNOWTRACE_KEY is not set")
}

const REACT_APP_BASESCAN_KEY = process.env.REACT_APP_BASESCAN_KEY
if (!isDev && !REACT_APP_BASESCAN_KEY) {
throw new Error("REACT_APP_BASESCAN_KEY is not set")
}

interface ExplorerData {
networkExplorerName: string
networkExplorerUrl: string
Expand Down Expand Up @@ -128,6 +133,15 @@ export const EXPLORERS_CONFIG: Record<NETWORK, ExplorerData> = {
verifyContractUrl: "https://sepolia.etherscan.io/verifyContract",
explorerApiKey: REACT_APP_ETHERSCAN_KEY,
},
[NETWORK.BASE]: {
networkExplorerName: "Basescan",
networkExplorerUrl: "https://basescan.org",
networkExplorerApiUrl: "https://api.basescan.org/api",
safeTransactionApi: "https://safe-transaction-base.safe.global",
safeUrl: "https://app.safe.global/base:",
verifyContractUrl: "https://basescan.org/verifyContract",
explorerApiKey: REACT_APP_BASESCAN_KEY,
},
}

export const getNetworkExplorerInfo = (chainId: number) => {
Expand Down
8 changes: 8 additions & 0 deletions packages/app/src/utils/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum NETWORK {
ARBITRUM = 42161,
AVALANCHE = 43114,
SEPOLIA = 11155111,
BASE = 8453,
}

export interface Coin {
Expand Down Expand Up @@ -85,6 +86,12 @@ export const NETWORKS: Record<NETWORK, Network> = {
shortName: "sep",
nativeAsset: NATIVE_ASSET.ETH,
},
[NETWORK.BASE]: {
chainId: NETWORK.BASE,
name: "base",
shortName: "base",
nativeAsset: NATIVE_ASSET.ETH,
},
}

export const NETWORK_NATIVE_ASSET: Record<NETWORK, Coin> = {
Expand All @@ -97,4 +104,5 @@ export const NETWORK_NATIVE_ASSET: Record<NETWORK, Coin> = {
[NETWORK.ARBITRUM]: NATIVE_ASSET.ETH,
[NETWORK.AVALANCHE]: NATIVE_ASSET.AVAX,
[NETWORK.SEPOLIA]: NATIVE_ASSET.ETH,
[NETWORK.BASE]: NATIVE_ASSET.ETH,
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ const networkToOzDefenderNetworkName = (network: NETWORK) => {
return "avalanche"
case NETWORK.SEPOLIA:
return "sepolia"
case NETWORK.BASE:
return "base"
default:
throw new Error("Unsupported network")
}
Expand Down

0 comments on commit 11cb6e2

Please sign in to comment.