diff --git a/apps/hyperdrive-trading/.env.sample b/apps/hyperdrive-trading/.env.sample index 7e6ef6d13..3fa23239c 100644 --- a/apps/hyperdrive-trading/.env.sample +++ b/apps/hyperdrive-trading/.env.sample @@ -16,6 +16,8 @@ VITE_CAPSULE_ENV= # # Sepolia, or VITE_SEPOLIA_RPC_URL= +VITE_BASE_SEPOLIA_RPC_URL= +VITE_B3_SEPOLIA_RPC_URL= # # Mainnet VITE_MAINNET_RPC_URL= diff --git a/apps/hyperdrive-trading/src/blockexplorer/makeAddressUrl.ts b/apps/hyperdrive-trading/src/blockexplorer/makeAddressUrl.ts index eb2fdd784..62249605b 100644 --- a/apps/hyperdrive-trading/src/blockexplorer/makeAddressUrl.ts +++ b/apps/hyperdrive-trading/src/blockexplorer/makeAddressUrl.ts @@ -1,6 +1,7 @@ import assertNever from "assert-never"; import { SupportedChainId } from "src/chains/supportedChains"; -import { foundry, mainnet, sepolia } from "viem/chains"; +import { b3Sepolia } from "src/network/b3Sepolia"; +import { baseSepolia, foundry, mainnet, sepolia } from "viem/chains"; export function makeAddressUrl( address: string, @@ -11,6 +12,10 @@ export function makeAddressUrl( return `https://etherscan.io/address/${address}`; case sepolia.id: return `https://sepolia.etherscan.io/address/${address}`; + case baseSepolia.id: + return `https://sepolia.basescan.org/address/${address}`; + case b3Sepolia.id: + return `https://sepolia.explorer.b3.fun/address/${address}`; case foundry.id: return `#`; case 42069: // Cloudchain diff --git a/apps/hyperdrive-trading/src/blockexplorer/makeTransactionUrl.ts b/apps/hyperdrive-trading/src/blockexplorer/makeTransactionUrl.ts index a77deeaa4..d9321816f 100644 --- a/apps/hyperdrive-trading/src/blockexplorer/makeTransactionUrl.ts +++ b/apps/hyperdrive-trading/src/blockexplorer/makeTransactionUrl.ts @@ -1,6 +1,7 @@ import assertNever from "assert-never"; import { SupportedChainId } from "src/chains/supportedChains"; -import { foundry, mainnet, sepolia } from "viem/chains"; +import { b3Sepolia } from "src/network/b3Sepolia"; +import { baseSepolia, foundry, mainnet, sepolia } from "viem/chains"; export function makeTransactionURL( transactionHash: string | undefined, @@ -11,6 +12,10 @@ export function makeTransactionURL( return `https://etherscan.io/tx/${transactionHash}`; case sepolia.id: return `https://sepolia.etherscan.io/tx/${transactionHash}`; + case baseSepolia.id: + return `https://sepolia.basescan.org/tx/${transactionHash}`; + case b3Sepolia.id: + return `https://sepolia.explorer.b3.fun/tx/${transactionHash}`; case foundry.id: return `#`; case 42069: // cloud chain diff --git a/apps/hyperdrive-trading/src/chains/supportedChains.ts b/apps/hyperdrive-trading/src/chains/supportedChains.ts index 53a2aa834..0a7cef132 100644 --- a/apps/hyperdrive-trading/src/chains/supportedChains.ts +++ b/apps/hyperdrive-trading/src/chains/supportedChains.ts @@ -1,10 +1,13 @@ -import { foundry, mainnet, sepolia } from "viem/chains"; +import { b3Sepolia } from "src/network/b3Sepolia"; +import { baseSepolia, foundry, mainnet, sepolia } from "viem/chains"; export const supportedChainIds = [ 42069, // cloud chain foundry.id, mainnet.id, sepolia.id, + baseSepolia.id, + b3Sepolia.id, ] as const; export type SupportedChainId = (typeof supportedChainIds)[number]; diff --git a/apps/hyperdrive-trading/src/network/b3Sepolia.ts b/apps/hyperdrive-trading/src/network/b3Sepolia.ts new file mode 100644 index 000000000..569443891 --- /dev/null +++ b/apps/hyperdrive-trading/src/network/b3Sepolia.ts @@ -0,0 +1,28 @@ +import { defineChain } from "viem"; +import { chainConfig } from "viem/op-stack"; + +const sourceId = 11155111; +export const b3Sepolia = defineChain({ + ...chainConfig, + id: 1993, + network: "b3-sepolia", + name: "B3 Sepolia", + nativeCurrency: { name: "Sepolia Ether", symbol: "ETH", decimals: 18 }, + rpcUrls: { + default: { + http: ["https://b3sepolia-rpc.publicnode.com"], + }, + }, + blockExplorers: { + default: { + name: "Sepolia B3 Explorer", + url: "https://sepolia.explorer.b3.fun/", + apiUrl: "https://sepolia-explorer.b3.fun/api/v2/", + }, + }, + contracts: { + ...chainConfig.contracts, + }, + testnet: true, + sourceId, +}); diff --git a/apps/hyperdrive-trading/src/network/wagmiClient.ts b/apps/hyperdrive-trading/src/network/wagmiClient.ts index 119ae7ed3..341dcdd3d 100644 --- a/apps/hyperdrive-trading/src/network/wagmiClient.ts +++ b/apps/hyperdrive-trading/src/network/wagmiClient.ts @@ -9,18 +9,20 @@ import { import { http } from "@wagmi/core"; import { Chain } from "@wagmi/core/chains"; import { cloudChain } from "src/chains/cloudChain"; +import { b3Sepolia } from "src/network/b3Sepolia"; import { CreateWalletFn } from "src/wallets/CreateWalletFn"; import { capsuleWallet } from "src/wallets/capsule"; import { Transport } from "viem"; -import { foundry, mainnet, sepolia } from "wagmi/chains"; +import { baseSepolia, foundry, mainnet, sepolia } from "wagmi/chains"; const { VITE_LOCALHOST_NODE_RPC_URL, VITE_CUSTOM_CHAIN_NODE_RPC_URL, - VITE_CUSTOM_CHAIN_ADDRESSES_URL, VITE_CUSTOM_CHAIN_CHAIN_ID, VITE_WALLET_CONNECT_PROJECT_ID, VITE_SEPOLIA_RPC_URL, + VITE_BASE_SEPOLIA_RPC_URL, + VITE_B3_SEPOLIA_RPC_URL, VITE_MAINNET_RPC_URL, } = import.meta.env; @@ -63,6 +65,18 @@ if (VITE_SEPOLIA_RPC_URL) { } } +// Base Sepolia +if (VITE_BASE_SEPOLIA_RPC_URL) { + chains.push(baseSepolia); + transports[baseSepolia.id] = http(VITE_BASE_SEPOLIA_RPC_URL); +} + +// B3 Sepolia +if (VITE_B3_SEPOLIA_RPC_URL) { + chains.push(b3Sepolia); + transports[b3Sepolia.id] = http(VITE_B3_SEPOLIA_RPC_URL); +} + if (VITE_MAINNET_RPC_URL) { chains.push(mainnet); transports[mainnet.id] = http(VITE_MAINNET_RPC_URL); diff --git a/apps/hyperdrive-trading/src/ui/appconfig/useAppConfig.ts b/apps/hyperdrive-trading/src/ui/appconfig/useAppConfig.ts index c9fc48d70..03d0feacb 100644 --- a/apps/hyperdrive-trading/src/ui/appconfig/useAppConfig.ts +++ b/apps/hyperdrive-trading/src/ui/appconfig/useAppConfig.ts @@ -5,10 +5,31 @@ import { sepoliaAppConfig, } from "@hyperdrive/appconfig"; import assertNever from "assert-never"; +import { ZERO_ADDRESS } from "src/base/constants"; import { SupportedChainId } from "src/chains/supportedChains"; -import { foundry, mainnet, sepolia } from "viem/chains"; +import { b3Sepolia } from "src/network/b3Sepolia"; +import { baseSepolia, foundry, mainnet, sepolia } from "viem/chains"; import { useChainId } from "wagmi"; +const emptyAppConfig: AppConfig = { + chainId: 0, + tags: [], + registryAddress: ZERO_ADDRESS, + hyperdrives: [], + tokens: [], + protocols: {}, +}; + +const baseSepoliaAppConfig: AppConfig = { + ...emptyAppConfig, + chainId: baseSepolia.id, +}; + +const b3SepoliaAppConfig: AppConfig = { + ...emptyAppConfig, + chainId: b3Sepolia.id, +}; + export function useAppConfig(): AppConfig { const chainId = useChainId() as SupportedChainId; switch (chainId) { @@ -25,6 +46,12 @@ export function useAppConfig(): AppConfig { case sepolia.id: return sepoliaAppConfig; + case baseSepolia.id: + return baseSepoliaAppConfig; + + case b3Sepolia.id: + return b3SepoliaAppConfig; + default: assertNever(chainId); } diff --git a/packages/hyperdrive-appconfig/src/chains/cloudChain.ts b/packages/hyperdrive-appconfig/src/chains/cloudChain.ts index a277c8234..5ce33bbdb 100644 --- a/packages/hyperdrive-appconfig/src/chains/cloudChain.ts +++ b/packages/hyperdrive-appconfig/src/chains/cloudChain.ts @@ -1,15 +1,11 @@ -import { Chain } from "viem"; +import { defineChain } from "viem"; -export const cloudChain: Chain = { +export const cloudChain = defineChain({ id: +(process.env.CLOUDCHAIN_CHAIN_ID as string), name: "☁️ \u00A0 Chain", - nativeCurrency: { - decimals: 18, - name: "Ether", - symbol: "ETH", - }, + nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 }, rpcUrls: { public: { http: [process.env.CLOUDCHAIN_NODE_RPC_URL as string] }, default: { http: [process.env.CLOUDCHAIN_NODE_RPC_URL as string] }, }, -}; +}); diff --git a/turbo.json b/turbo.json index d9b2d3453..d5eaee075 100644 --- a/turbo.json +++ b/turbo.json @@ -2,15 +2,28 @@ "$schema": "https://turborepo.org/schema.json", "tasks": { "build:crates": { - "dependsOn": ["^build"], - "outputs": ["packages/hyperdrive-wasm/**", "packages/fixed-point-wasm/**"] + "dependsOn": [ + "^build" + ], + "outputs": [ + "packages/hyperdrive-wasm/**", + "packages/fixed-point-wasm/**" + ] }, "build": { - "dependsOn": ["build:crates", "^build"], - "outputs": ["dist/**", ".next/**"] + "dependsOn": [ + "build:crates", + "^build" + ], + "outputs": [ + "dist/**", + ".next/**" + ] }, "hyperdrive-trading#build": { - "dependsOn": ["^build"], + "dependsOn": [ + "^build" + ], "env": [ "DEV", "VITE_CUSTOM_CHAIN_NODE_RPC_URL", @@ -19,6 +32,8 @@ "VITE_CUSTOM_CHAIN_ADDRESSES_URL", "VITE_WALLET_CONNECT_PROJECT_ID", "VITE_SEPOLIA_RPC_URL", + "VITE_BASE_SEPOLIA_RPC_URL", + "VITE_B3_SEPOLIA_RPC_URL", "VITE_MAINNET_RPC_URL", "VITE_CAPSULE_API_KEY", "VITE_CAPSULE_ENV", @@ -26,28 +41,49 @@ "VITE_ROLLBAR_ACCESS_TOKEN", "VITE_ROLLBAR_ENV" ], - "outputs": ["dist/**", ".next/**"] + "outputs": [ + "dist/**", + ".next/**" + ] }, "lint": { - "dependsOn": ["^build"], + "dependsOn": [ + "^build" + ], "outputs": [] }, "typecheck": { - "dependsOn": ["^build"], + "dependsOn": [ + "^build" + ], "outputs": [] }, "dev": { "cache": false }, - "format": { "outputs": [] }, - "format:check": { "outputs": [] }, + "format": { + "outputs": [] + }, + "format:check": { + "outputs": [] + }, "test": { - "dependsOn": ["build"], - "inputs": ["test/**/*.ts", "test/**/*.tsx"] + "dependsOn": [ + "build" + ], + "inputs": [ + "test/**/*.ts", + "test/**/*.tsx" + ] }, "test:run": { - "dependsOn": ["build"], - "inputs": ["test/**/*.ts", "test/**/*.tsx"] + "dependsOn": [ + "build" + ], + "inputs": [ + "test/**/*.ts", + "test/**/*.tsx" + ] } } -} +} \ No newline at end of file