Skip to content

Commit

Permalink
Update new import the Chain
Browse files Browse the repository at this point in the history
  • Loading branch information
Nadai2010 committed Nov 21, 2024
1 parent 0693218 commit be5e6d7
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions packages/nextjs/utils/scaffold-stark/networks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import * as chains from "@starknet-react/chains";
import { devnet, sepolia, mainnet, Chain } from "@starknet-react/chains";
export const chains = {
devnet,
sepolia,
mainnet,
};
import scaffoldConfig from "~~/scaffold.config";

type ChainAttributes = {
Expand All @@ -7,7 +12,7 @@ type ChainAttributes = {
nativeCurrencyTokenAddress?: string;
};

export type ChainWithAttributes = chains.Chain & Partial<ChainAttributes>;
export type ChainWithAttributes = Chain & Partial<ChainAttributes>;

export const NETWORKS_EXTRA_DATA: Record<string, ChainAttributes> = {
[chains.devnet.network]: {
Expand All @@ -28,7 +33,7 @@ export function getBlockExplorerTxLink(network: string, txnHash: string) {

const targetChainArr = chainNames.filter((chainName) => {
const wagmiChain = chains[chainName as keyof typeof chains];
return (wagmiChain as { network: string }).network === network;
return wagmiChain.network === network;
});

if (targetChainArr.length === 0) {
Expand All @@ -50,10 +55,7 @@ export function getBlockExplorerTxLink(network: string, txnHash: string) {
* Gives the block explorer URL for a given address.
* Defaults to Etherscan if no (wagmi) block explorer is configured for the network.
*/
export function getBlockExplorerAddressLink(
network: chains.Chain,
address: string,
) {
export function getBlockExplorerAddressLink(network: Chain, address: string) {
const blockExplorerBaseURL = network.explorers?.starkscan[0];
if (network.network === chains.devnet.network) {
return `/blockexplorer/address/${address}`;
Expand All @@ -70,10 +72,7 @@ export function getBlockExplorerAddressLink(
* Gives the block explorer URL for a given classhash.
* Defaults to Etherscan if no (wagmi) block explorer is configured for the network.
*/
export function getBlockExplorerClasshashLink(
network: chains.Chain,
address: string,
) {
export function getBlockExplorerClasshashLink(network: Chain, address: string) {
const blockExplorerBaseURL = network.explorers?.starkscan[0];
if (network.network === chains.devnet.network) {
return `/blockexplorer/class/${address}`;
Expand All @@ -86,7 +85,7 @@ export function getBlockExplorerClasshashLink(
return `${blockExplorerBaseURL}/class/${address}`;
}

export function getBlockExplorerLink(network: chains.Chain) {
export function getBlockExplorerLink(network: Chain) {
switch (network) {
case chains.mainnet:
return "https://starkscan.co/";
Expand Down

0 comments on commit be5e6d7

Please sign in to comment.