Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: blast sepolia support #1396

Merged
merged 8 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ declare global {
AVALANCHE_MAINNET_RPC: string;
AVALANCHE_FUJI_RPC: string;
BLAST_MAINNET_RPC: string;
BLAST_SEPOLIA_RPC: string;
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/core/references/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from 'viem/chains';
import { Address, type Chain, sepolia } from 'wagmi';

import { ChainId, ChainNameDisplay, chainBlast } from '~/core/types/chains';
import { ChainId, ChainNameDisplay, chainBlast, chainBlastSepolia } from '~/core/types/chains';

import { AddressOrEth } from '../types/assets';

Expand Down Expand Up @@ -162,6 +162,7 @@ export const NATIVE_ASSETS_PER_CHAIN: Record<ChainId, AddressOrEth> = {
[ChainId.avalanche]: AVAX_AVALANCHE_ADDRESS as Address,
[ChainId.avalancheFuji]: AddressZero as Address,
[ChainId.blast]: AddressZero as Address,
[ChainId.blastSepolia]: AddressZero as Address,
};

export const NATIVE_ASSETS_MAP_PER_CHAIN: Record<ChainId, AddressOrEth> = {
Expand All @@ -187,6 +188,7 @@ export const NATIVE_ASSETS_MAP_PER_CHAIN: Record<ChainId, AddressOrEth> = {
[ChainId.avalanche]: ETH_ADDRESS,
[ChainId.avalancheFuji]: ETH_ADDRESS,
[ChainId.blast]: ETH_ADDRESS,
[ChainId.blastSepolia]: ETH_ADDRESS,
};

export const OVM_GAS_PRICE_ORACLE =
Expand Down Expand Up @@ -233,6 +235,7 @@ export const SUPPORTED_CHAINS: Chain[] = [
avalanche,
avalancheFuji,
chainBlast,
chainBlastSepolia
].map((chain) => ({ ...chain, name: ChainNameDisplay[chain.id] }));

export const SUPPORTED_CHAIN_IDS = SUPPORTED_CHAINS.map((chain) => chain.id);
Expand All @@ -248,6 +251,7 @@ export const SUPPORTED_TESTNET_CHAINS: Chain[] = [
baseSepolia,
zoraSepolia,
avalancheFuji,
chainBlastSepolia
];

export const SUPPORTED_TESTNET_CHAIN_IDS: number[] =
Expand Down Expand Up @@ -293,6 +297,8 @@ export const getDefaultRPC = (chainId: ChainId) => {
return { http: process.env.AVALANCHE_FUJI_RPC };
case ChainId.blast:
return { http: process.env.BLAST_MAINNET_RPC };
case ChainId.blastSepolia:
return { http: process.env.BLAST_SEPOLIA_RPC };
default:
return null;
}
Expand Down
37 changes: 30 additions & 7 deletions src/core/types/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { Chain } from 'wagmi';

const HARDHAT_CHAIN_ID = 1337;
const BLAST_CHAIN_ID = 81457;
const BLAST_SEPOLIA_CHAIN_ID = 168587773;

const HARDHAT_OP_CHAIN_ID = 1338;

export const chainHardhat: Chain = {
Expand All @@ -21,6 +23,22 @@ export const chainHardhat: Chain = {
testnet: true,
};

export const chainHardhatOptimism: Chain = {
id: HARDHAT_OP_CHAIN_ID,
name: 'Hardhat OP',
network: 'hardhat-optimism',
nativeCurrency: {
decimals: 18,
name: 'Hardhat OP',
symbol: 'ETH',
},
rpcUrls: {
public: { http: ['http://127.0.0.1:8545'] },
default: { http: ['http://127.0.0.1:8545'] },
},
testnet: true,
};

export const chainBlast: Chain = {
id: BLAST_CHAIN_ID,
name: 'Blast',
Expand All @@ -41,18 +59,18 @@ export const chainBlast: Chain = {
},
};

export const chainHardhatOptimism: Chain = {
id: HARDHAT_OP_CHAIN_ID,
name: 'Hardhat OP',
network: 'hardhat-optimism',
export const chainBlastSepolia: Chain = {
id: BLAST_SEPOLIA_CHAIN_ID,
name: 'Blast Sepolia',
network: 'blast-sepolia',
nativeCurrency: {
decimals: 18,
name: 'Hardhat OP',
name: 'Ether',
symbol: 'ETH',
},
rpcUrls: {
public: { http: ['http://127.0.0.1:8545'] },
default: { http: ['http://127.0.0.1:8545'] },
public: { http: ['https://sepolia.blast.io'] },
default: { http: ['https://sepolia.blast.io'] },
},
testnet: true,
};
Expand All @@ -65,6 +83,7 @@ export enum ChainName {
avalancheFuji = 'avalanche-fuji',
base = 'base',
blast = 'blast',
blastSepolia = 'blast-sepolia',
bsc = 'bsc',
celo = 'celo',
gnosis = 'gnosis',
Expand Down Expand Up @@ -96,6 +115,7 @@ export enum ChainId {
avalancheFuji = chain.avalancheFuji.id,
base = chain.base.id,
blast = BLAST_CHAIN_ID,
blastSepolia = BLAST_SEPOLIA_CHAIN_ID,
bsc = chain.bsc.id,
celo = chain.celo.id,
gnosis = chain.gnosis.id,
Expand Down Expand Up @@ -155,6 +175,7 @@ export const chainNameToIdMapping: {
[ChainName.baseSepolia]: ChainId.baseSepolia,
[ChainName.zoraSepolia]: ChainId.zoraSepolia,
[ChainName.blast]: ChainId.blast,
[ChainName.blastSepolia]: ChainId.blastSepolia,
};

export const chainIdToNameMapping: {
Expand All @@ -167,6 +188,7 @@ export const chainIdToNameMapping: {
[ChainId.avalancheFuji]: ChainName.avalancheFuji,
[ChainId.base]: ChainName.base,
[ChainId.blast]: ChainName.blast,
[ChainId.blastSepolia]: ChainName.blastSepolia,
[ChainId.bsc]: ChainName.bsc,
[ChainId.celo]: ChainName.celo,
[ChainId.gnosis]: ChainName.gnosis,
Expand Down Expand Up @@ -198,6 +220,7 @@ export const ChainNameDisplay = {
[ChainId.avalancheFuji]: 'Avalanche Fuji',
[ChainId.base]: 'Base',
[ChainId.blast]: 'Blast',
[ChainId.blastSepolia]: 'Blast Sepolia',
[ChainId.bsc]: 'BSC',
[ChainId.celo]: chain.celo.name,
[ChainId.linea]: 'Linea',
Expand Down
2 changes: 2 additions & 0 deletions src/core/types/nfts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export enum SimpleHashChain {
BaseSepolia = 'base-sepolia',
OptimismSepolia = 'optimism-sepolia',
ZoraSepolia = 'zora-sepolia',
Blast = 'blast',
BlastSepolia = 'blast-sepolia',
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/core/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export const getSimpleHashSupportedChainNames = () => {
ChainName.arbitrumNova,
ChainName.avalanche,
ChainName.base,
ChainName.blast,
ChainName.bsc,
ChainName.celo,
ChainName.gnosis,
Expand All @@ -188,6 +189,7 @@ export const getSimpleHashSupportedTestnetChainNames = () => {
ChainName.polygonMumbai,
ChainName.arbitrumSepolia,
ChainName.baseSepolia,
ChainName.blastSepolia,
ChainName.optimismSepolia,
ChainName.zoraSepolia,
] as (ChainName | 'ethereum-sepolia' | 'ethereum')[];
Expand Down
1 change: 1 addition & 0 deletions src/core/utils/faucets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const TestnetFaucet = {
[ChainId.baseSepolia]: 'https://app.optimism.io/faucet',
[ChainId.zoraSepolia]: 'https://app.optimism.io/faucet',
[ChainId.avalancheFuji]: 'https://faucet.quicknode.com/avalanche/fuji',
[ChainId.blastSepolia]: 'https://faucet.quicknode.com/blast/sepolia',
[moonbaseAlpha.id]: 'https://faucet.paradigm.xyz',
[scrollSepolia.id]: 'https://faucet.quicknode.com/scroll/sepolia',
[polygonZkEvm.id]: 'https://faucet.polygon.technology',
Expand Down
4 changes: 4 additions & 0 deletions src/core/utils/nfts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ export function getNetworkFromSimpleHashChain(
return ChainName.optimismSepolia;
case SimpleHashChain.ZoraSepolia:
return ChainName.zoraSepolia;
case SimpleHashChain.Blast:
return ChainName.blast;
case SimpleHashChain.BlastSepolia:
return ChainName.blastSepolia;
default:
/*
* Throws here because according to TS types, we should NEVER hit this
Expand Down
9 changes: 5 additions & 4 deletions src/core/utils/userChains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from 'viem/chains';
import { Chain, goerli, mainnet, sepolia } from 'wagmi';

import { ChainId, ChainNameDisplay, chainBlast } from '../types/chains';
import { ChainId, ChainNameDisplay, chainBlast, chainBlastSepolia } from '../types/chains';

import {
getSupportedChainsWithHardhat,
Expand All @@ -44,7 +44,7 @@ export const chainIdMap: Record<
[ChainId.bsc]: [bsc.id, bscTestnet.id],
[ChainId.zora]: [zora.id, zoraSepolia.id],
[ChainId.avalanche]: [avalanche.id, avalancheFuji.id],
[ChainId.blast]: [chainBlast.id],
[ChainId.blast]: [chainBlast.id, chainBlastSepolia.id],
};

export const chainLabelMap: Record<
Expand All @@ -54,7 +54,8 @@ export const chainLabelMap: Record<
| ChainId.base
| ChainId.bsc
| ChainId.zora
| ChainId.avalanche,
| ChainId.avalanche
| ChainId.blast,
string[]
> = {
[ChainId.mainnet]: [
Expand All @@ -69,7 +70,7 @@ export const chainLabelMap: Record<
[ChainId.bsc]: [ChainNameDisplay[bscTestnet.id]],
[ChainId.zora]: [ChainNameDisplay[zoraSepolia.id]],
[ChainId.avalanche]: [ChainNameDisplay[avalancheFuji.id]],
[ChainId.blast]: [ChainNameDisplay[chainBlast.id]],
[ChainId.blast]: [ChainNameDisplay[chainBlastSepolia.id]],
};

export const sortNetworks = (order: ChainId[], chains: Chain[]) => {
Expand Down
1 change: 1 addition & 0 deletions src/entries/iframe/notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const ASSET_SOURCE = {
[ChainId.zoraSepolia]: 'assets/badges/[email protected]',
[ChainId.avalancheFuji]: 'assets/badges/[email protected]',
[ChainId.blast]: 'assets/badges/[email protected]',
[ChainId.blastSepolia]: 'assets/badges/[email protected]',
};

export enum IN_DAPP_NOTIFICATION_STATUS {
Expand Down
1 change: 1 addition & 0 deletions src/entries/popup/components/ChainBadge/ChainBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const networkBadges = {
[ChainId.zoraSepolia]: ZoraBadge,
[ChainId.avalancheFuji]: AvalancheBadge,
[ChainId.blast]: BlastBadge,
[ChainId.blastSepolia]: BlastBadge,
};

const ChainBadge = ({
Expand Down
Loading