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

fix: support non terra station wallets #165

Merged
merged 1 commit into from
Jul 6, 2023
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
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