Skip to content

Commit

Permalink
optimism support
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-gray committed Mar 6, 2023
1 parent 833d3ed commit 2393ff4
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/components/ShowTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
CHAIN_ID_ARBITRUM,
CHAIN_ID_INJECTIVE,
CHAIN_ID_BASE,
CHAIN_ID_OPTIMISM,
} from "@certusone/wormhole-sdk";
import { Button, makeStyles, Typography } from "@material-ui/core";
import { Transaction } from "../store/transferSlice";
Expand Down Expand Up @@ -126,6 +127,10 @@ export default function ShowTx({
? `https://${CLUSTER === "testnet" ? "goerli." : ""}basescan.org/tx/${
tx?.id
}`
: chainId === CHAIN_ID_OPTIMISM
? `https://${
CLUSTER === "testnet" ? "goerli-" : ""
}optimism.etherscan.io/tx/${tx?.id}`
: chainId === CHAIN_ID_XPLA
? `https://explorer.xpla.io/${
CLUSTER === "testnet" ? "testnet/" : ""
Expand Down
5 changes: 5 additions & 0 deletions src/components/SmartAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
terra,
CHAIN_ID_NEAR,
CHAIN_ID_BASE,
CHAIN_ID_OPTIMISM,
} from "@certusone/wormhole-sdk";
import { Button, makeStyles, Tooltip, Typography } from "@material-ui/core";
import { FileCopy, OpenInNew } from "@material-ui/icons";
Expand Down Expand Up @@ -160,6 +161,10 @@ export default function SmartAddress({
? `https://${CLUSTER === "testnet" ? "goerli." : ""}basescan.org/${
isAsset ? "token" : "address"
}/${useableAddress}`
: chainId === CHAIN_ID_OPTIMISM
? `https://${CLUSTER === "testnet" ? "goerli-" : ""}optimism.etherscan.io/${
isAsset ? "token" : "address"
}/${useableAddress}`
: chainId === CHAIN_ID_KARURA
? `https://${
CLUSTER === "testnet"
Expand Down
5 changes: 5 additions & 0 deletions src/components/TransactionProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
CHAIN_ID_KLAYTN,
CHAIN_ID_MOONBEAM,
CHAIN_ID_OASIS,
CHAIN_ID_OPTIMISM,
CHAIN_ID_POLYGON,
CHAIN_ID_SOLANA,
isEVMChain,
Expand Down Expand Up @@ -100,6 +101,8 @@ export default function TransactionProgress({
? 64 // something to show progress
: chainId === CHAIN_ID_BASE
? 124 // something to show progress
: chainId === CHAIN_ID_OPTIMISM
? 124 // something to show progress
: isEVMChain(chainId)
? 15
: 1;
Expand All @@ -121,6 +124,8 @@ export default function TransactionProgress({
? `Waiting for Ethereum finality on Arbitrum block ${tx?.block}` //TODO: more advanced finality checking for Arbitrum
: chainId === CHAIN_ID_BASE
? `Waiting for Ethereum finality on Base block ${tx?.block}` //TODO: more advanced finality checking for Base
: chainId === CHAIN_ID_OPTIMISM
? `Waiting for Ethereum finality on Optimism block ${tx?.block}` //TODO: more advanced finality checking for Optimism
: blockDiff < expectedBlocks
? `Waiting for ${blockDiff} / ${expectedBlocks} confirmations on ${CHAINS_BY_ID[chainId].name}...`
: `Waiting for Wormhole Network consensus...`}
Expand Down
5 changes: 5 additions & 0 deletions src/icons/optimism.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion src/utils/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
CHAIN_ID_NEAR,
CHAIN_ID_NEON,
CHAIN_ID_OASIS,
CHAIN_ID_OPTIMISM,
CHAIN_ID_POLYGON,
CHAIN_ID_SOLANA,
CHAIN_ID_TERRA,
Expand Down Expand Up @@ -48,6 +49,7 @@ import klaytnIcon from "../icons/klaytn.svg";
import moonbeamIcon from "../icons/moonbeam.svg";
import neonIcon from "../icons/neon.svg";
import oasisIcon from "../icons/oasis-network-rose-logo.svg";
import optimismIcon from "../icons/optimism.svg";
import polygonIcon from "../icons/polygon.svg";
import solanaIcon from "../icons/solana.svg";
import terraIcon from "../icons/terra.svg";
Expand Down Expand Up @@ -162,6 +164,11 @@ export const CHAINS: ChainInfo[] =
name: "Oasis",
logo: oasisIcon,
},
{
id: CHAIN_ID_OPTIMISM,
name: "Optimism (Goerli)",
logo: optimismIcon,
},
{
id: CHAIN_ID_POLYGON,
name: "Polygon",
Expand Down Expand Up @@ -247,7 +254,8 @@ export const CHAINS_WITH_NFT_SUPPORT = CHAINS.filter(
id === CHAIN_ID_NEON ||
id === CHAIN_ID_ARBITRUM ||
id === CHAIN_ID_MOONBEAM ||
id === CHAIN_ID_BASE
id === CHAIN_ID_BASE ||
id === CHAIN_ID_OPTIMISM
);
export type ChainsById = { [key in ChainId]: ChainInfo };
export const CHAINS_BY_ID: ChainsById = CHAINS.reduce((obj, chain) => {
Expand Down Expand Up @@ -299,6 +307,8 @@ export const getDefaultNativeCurrencySymbol = (chainId: ChainId) =>
? "GLMR"
: chainId === CHAIN_ID_BASE
? "ETH"
: chainId === CHAIN_ID_OPTIMISM
? "ETH"
: "";

export const getDefaultNativeCurrencyAddressEvm = (chainId: ChainId) => {
Expand Down Expand Up @@ -379,6 +389,7 @@ export const NEON_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 245022926 : 1381;
export const ARBITRUM_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 421613 : 1381;
export const MOONBEAM_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 1287 : 1381;
export const BASE_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 84531 : 1381;
export const OPTIMISM_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 420 : 1381;
export const getEvmChainId = (chainId: ChainId) =>
chainId === CHAIN_ID_ETH
? ETH_NETWORK_CHAIN_ID
Expand Down Expand Up @@ -410,6 +421,8 @@ export const getEvmChainId = (chainId: ChainId) =>
? MOONBEAM_NETWORK_CHAIN_ID
: chainId === CHAIN_ID_BASE
? BASE_NETWORK_CHAIN_ID
: chainId === CHAIN_ID_OPTIMISM
? OPTIMISM_NETWORK_CHAIN_ID
: undefined;
export const SOLANA_HOST = process.env.REACT_APP_SOLANA_API_URL
? process.env.REACT_APP_SOLANA_API_URL
Expand Down Expand Up @@ -544,6 +557,8 @@ export const COVALENT_MOONBEAM =
CLUSTER === "devnet" ? null : MOONBEAM_NETWORK_CHAIN_ID; // Covalent only supports mainnet
export const COVALENT_BASE =
CLUSTER === "devnet" ? null : BASE_NETWORK_CHAIN_ID;
export const COVALENT_OPTIMISM =
CLUSTER === "devnet" ? null : OPTIMISM_NETWORK_CHAIN_ID;

export const COVALENT_GET_TOKENS_URL = (
chainId: ChainId,
Expand Down Expand Up @@ -574,6 +589,8 @@ export const COVALENT_GET_TOKENS_URL = (
? COVALENT_MOONBEAM
: chainId === CHAIN_ID_BASE
? COVALENT_BASE
: chainId === CHAIN_ID_OPTIMISM
? COVALENT_OPTIMISM
: "";
// https://www.covalenthq.com/docs/api/#get-/v1/{chain_id}/address/{address}/balances_v2/
return chainNum
Expand Down
7 changes: 7 additions & 0 deletions src/utils/metaMaskChainParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ export const METAMASK_CHAIN_PARAMETERS: {
rpcUrls: ["https://goerli.base.org"],
blockExplorerUrls: ["https://goerli.basescan.org"],
},
420: {
chainId: "0x1056",
chainName: "Optimism Goerli",
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
rpcUrls: ["https://goerli.optimism.io"],
blockExplorerUrls: ["https://goerli-optimism.etherscan.io"],
},
};

export interface EvmRpcMap {
Expand Down

0 comments on commit 2393ff4

Please sign in to comment.