Skip to content

Commit

Permalink
Merge pull request #165 from terraswap/fix/333/wallet-connection
Browse files Browse the repository at this point in the history
  • Loading branch information
honeymaro authored Jul 6, 2023
2 parents 350f83c + 6ffcb63 commit 45ddeba
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
16 changes: 7 additions & 9 deletions src/constants/networks.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { NetworkInfo } from "@terra-dev/wallet-types"

export enum NetworkKey {
MAINNET = "classic",
}
type MirrorNetworkInfo = NetworkInfo & NetworkConfig
import { NetworkInfo as OrgNetworkInfo } from "@terra-dev/wallet-types"

export const AVAILABLE_CHAIN_ID = ["columbus-5"]
type NetworkInfo = OrgNetworkInfo & NetworkConfig

const networks: Record<string, MirrorNetworkInfo> = {
classic: {
const networks: Record<string, NetworkInfo> = {
"columbus-5": {
name: "classic",
chainID: "columbus-5",
lcd: "https://terra-classic-lcd.publicnode.com",
Expand All @@ -26,7 +22,9 @@ const networks: Record<string, MirrorNetworkInfo> = {
serviceV1:
process.env.REACT_APP_MAINNET_SERVICE_V1_URL ||
"https://api-classic.terraswap.io/v1",
dashboard: process.env.REACT_APP_MAINNET_DASHBOARD_URL,
dashboard:
process.env.REACT_APP_MAINNET_DASHBOARD_URL ||
"https://api-classic.terraswap.io/v2/dashboard",
router: "terra1g3zc8lwwmkrm0cz9wkgl849pdqaw6cq8lh7872",
},
}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import networks from "constants/networks"
const useNetwork = () => {
const { network: extNetwork } = useWallet()

const network = networks[extNetwork.name]
const network = networks[extNetwork.chainID]

const finder = (address: string, path: string = "account") =>
`${FINDER}/${extNetwork.chainID}/${path}/${address}`
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/WalletConnectProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ export default WalletConnectProvider
/* hooks */
export const useLCD = () => {
const { network } = useWallet()
const networkInfo = networks[network.name]
const networkInfo = networks[network.chainID]
return networkInfo?.lcd
}

export const useLCDClient = () => {
const { network } = useWallet()
const networkInfo = networks[network.name]
const networkInfo = networks[network.chainID]
const terra = new LCDClient({
URL: networkInfo?.lcd,
chainID: network.chainID,
Expand Down
8 changes: 5 additions & 3 deletions src/types/network.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ interface Network extends NetworkConfig {
refresh: () => void
}

type NetworkConfig = ExtNetworkConfig & LocalNetworkConfig

interface NetworkConfig {
interface LocalNetworkConfig {
/** Chain ID */
id: string
/** Contract Addresses JSON URL */
Expand All @@ -24,7 +22,9 @@ interface NetworkConfig {
fee: { gasPrice: string; amount: string; gas: string }
factory: string
service: string
serviceV1: string
dashboard: string
router: string
}

interface ExtNetworkConfig {
Expand All @@ -33,3 +33,5 @@ interface ExtNetworkConfig {
lcd: string
fcd: string
}

type NetworkConfig = ExtNetworkConfig & LocalNetworkConfig

0 comments on commit 45ddeba

Please sign in to comment.