From e9a1bdb44145d89a85e28ff27ee2ad75330b2489 Mon Sep 17 00:00:00 2001 From: Daniel Sinclair Date: Thu, 28 Mar 2024 18:04:27 -0400 Subject: [PATCH] feat: blast sepolia support (#1396) --- .env.d.ts | 1 + src/core/references/index.ts | 8 +++- src/core/types/chains.ts | 37 +++++++++++++++---- src/core/types/nfts.ts | 2 + src/core/utils/chains.ts | 2 + src/core/utils/faucets.ts | 1 + src/core/utils/nfts.ts | 4 ++ src/core/utils/userChains.ts | 9 +++-- src/entries/iframe/notification.tsx | 1 + .../components/ChainBadge/ChainBadge.tsx | 1 + 10 files changed, 54 insertions(+), 12 deletions(-) diff --git a/.env.d.ts b/.env.d.ts index 196a719de5..c679a1ab16 100644 --- a/.env.d.ts +++ b/.env.d.ts @@ -44,6 +44,7 @@ declare global { AVALANCHE_MAINNET_RPC: string; AVALANCHE_FUJI_RPC: string; BLAST_MAINNET_RPC: string; + BLAST_SEPOLIA_RPC: string; } } } diff --git a/src/core/references/index.ts b/src/core/references/index.ts index b9bab3b98b..f822bb2ff2 100644 --- a/src/core/references/index.ts +++ b/src/core/references/index.ts @@ -19,7 +19,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'; @@ -160,6 +160,7 @@ export const NATIVE_ASSETS_PER_CHAIN: Record = { [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 = { @@ -184,6 +185,7 @@ export const NATIVE_ASSETS_MAP_PER_CHAIN: Record = { [ChainId.avalanche]: ETH_ADDRESS, [ChainId.avalancheFuji]: ETH_ADDRESS, [ChainId.blast]: ETH_ADDRESS, + [ChainId.blastSepolia]: ETH_ADDRESS, }; export const OVM_GAS_PRICE_ORACLE = @@ -229,6 +231,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); @@ -243,6 +246,7 @@ export const SUPPORTED_TESTNET_CHAINS: Chain[] = [ baseSepolia, zoraSepolia, avalancheFuji, + chainBlastSepolia ]; export const SUPPORTED_TESTNET_CHAIN_IDS: number[] = @@ -286,6 +290,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; } diff --git a/src/core/types/chains.ts b/src/core/types/chains.ts index 2daad0ad5b..d086b0a265 100644 --- a/src/core/types/chains.ts +++ b/src/core/types/chains.ts @@ -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 = { @@ -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', @@ -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, }; @@ -65,6 +83,7 @@ export enum ChainName { avalancheFuji = 'avalanche-fuji', base = 'base', blast = 'blast', + blastSepolia = 'blast-sepolia', bsc = 'bsc', celo = 'celo', gnosis = 'gnosis', @@ -95,6 +114,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, @@ -152,6 +172,7 @@ export const chainNameToIdMapping: { [ChainName.baseSepolia]: ChainId.baseSepolia, [ChainName.zoraSepolia]: ChainId.zoraSepolia, [ChainName.blast]: ChainId.blast, + [ChainName.blastSepolia]: ChainId.blastSepolia, }; export const chainIdToNameMapping: { @@ -164,6 +185,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, @@ -194,6 +216,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', diff --git a/src/core/types/nfts.ts b/src/core/types/nfts.ts index c0d69d3066..c6e3e69708 100644 --- a/src/core/types/nfts.ts +++ b/src/core/types/nfts.ts @@ -28,6 +28,8 @@ export enum SimpleHashChain { BaseSepolia = 'base-sepolia', OptimismSepolia = 'optimism-sepolia', ZoraSepolia = 'zora-sepolia', + Blast = 'blast', + BlastSepolia = 'blast-sepolia', } /** diff --git a/src/core/utils/chains.ts b/src/core/utils/chains.ts index 39c19670b1..235a2aff1e 100644 --- a/src/core/utils/chains.ts +++ b/src/core/utils/chains.ts @@ -169,6 +169,7 @@ export const getSimpleHashSupportedChainNames = () => { ChainName.arbitrumNova, ChainName.avalanche, ChainName.base, + ChainName.blast, ChainName.bsc, ChainName.celo, ChainName.gnosis, @@ -188,6 +189,7 @@ export const getSimpleHashSupportedTestnetChainNames = () => { ChainName.polygonMumbai, ChainName.arbitrumSepolia, ChainName.baseSepolia, + ChainName.blastSepolia, ChainName.optimismSepolia, ChainName.zoraSepolia, ] as (ChainName | 'ethereum-sepolia' | 'ethereum')[]; diff --git a/src/core/utils/faucets.ts b/src/core/utils/faucets.ts index 836f8a4c28..499dbf3a77 100644 --- a/src/core/utils/faucets.ts +++ b/src/core/utils/faucets.ts @@ -12,6 +12,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', diff --git a/src/core/utils/nfts.ts b/src/core/utils/nfts.ts index 483b2d5f98..a6430f29e4 100644 --- a/src/core/utils/nfts.ts +++ b/src/core/utils/nfts.ts @@ -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 diff --git a/src/core/utils/userChains.ts b/src/core/utils/userChains.ts index 2e287d518b..a68fca147e 100644 --- a/src/core/utils/userChains.ts +++ b/src/core/utils/userChains.ts @@ -17,7 +17,7 @@ import { } from 'viem/chains'; import { Chain, mainnet, sepolia } from 'wagmi'; -import { ChainId, ChainNameDisplay, chainBlast } from '../types/chains'; +import { ChainId, ChainNameDisplay, chainBlast, chainBlastSepolia } from '../types/chains'; import { getSupportedChainsWithHardhat, @@ -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< @@ -54,7 +54,8 @@ export const chainLabelMap: Record< | ChainId.base | ChainId.bsc | ChainId.zora - | ChainId.avalanche, + | ChainId.avalanche + | ChainId.blast, string[] > = { [ChainId.mainnet]: [ @@ -68,7 +69,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[]) => { diff --git a/src/entries/iframe/notification.tsx b/src/entries/iframe/notification.tsx index b7975484df..b1056f4eac 100644 --- a/src/entries/iframe/notification.tsx +++ b/src/entries/iframe/notification.tsx @@ -43,6 +43,7 @@ const ASSET_SOURCE = { [ChainId.zoraSepolia]: 'assets/badges/zoraBadge@3x.png', [ChainId.avalancheFuji]: 'assets/badges/avalancheBadge@3x.png', [ChainId.blast]: 'assets/badges/blastBadge@3x.png', + [ChainId.blastSepolia]: 'assets/badges/blastBadge@3x.png', }; export enum IN_DAPP_NOTIFICATION_STATUS { diff --git a/src/entries/popup/components/ChainBadge/ChainBadge.tsx b/src/entries/popup/components/ChainBadge/ChainBadge.tsx index 3080ddc799..fdf89a4d22 100644 --- a/src/entries/popup/components/ChainBadge/ChainBadge.tsx +++ b/src/entries/popup/components/ChainBadge/ChainBadge.tsx @@ -58,6 +58,7 @@ const networkBadges = { [ChainId.zoraSepolia]: ZoraBadge, [ChainId.avalancheFuji]: AvalancheBadge, [ChainId.blast]: BlastBadge, + [ChainId.blastSepolia]: BlastBadge, }; const ChainBadge = ({