-
Notifications
You must be signed in to change notification settings - Fork 53
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
refactor + knip + prettier #2669
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
dist/ | ||
dist/ | ||
node_modules/ | ||
vocs.config.ts.timestamp-*.mjs |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,7 @@ | ||||||||||||||||||||||||||||||
import { Chain, getConfigFromNetwork } from "@config"; | ||||||||||||||||||||||||||||||
import { env } from "../../env"; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
export const ETERNUM_CONFIG = () => { | ||||||||||||||||||||||||||||||
const config = getConfigFromNetwork(env.VITE_PUBLIC_CHAIN! as Chain); | ||||||||||||||||||||||||||||||
return config; | ||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||
Comment on lines
+4
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add error handling and type safety for environment variable. The non-null assertion ( export const ETERNUM_CONFIG = () => {
- const config = getConfigFromNetwork(env.VITE_PUBLIC_CHAIN! as Chain);
+ if (!env.VITE_PUBLIC_CHAIN) {
+ throw new Error('VITE_PUBLIC_CHAIN environment variable is required');
+ }
+ if (!Object.values(Chain).includes(env.VITE_PUBLIC_CHAIN as Chain)) {
+ throw new Error(`Invalid chain value: ${env.VITE_PUBLIC_CHAIN}`);
+ }
+ const config = getConfigFromNetwork(env.VITE_PUBLIC_CHAIN as Chain);
return config;
}; 📝 Committable suggestion
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const env = { | ||
VITE_PUBLIC_CHAIN: process.env.VITE_PUBLIC_CHAIN || "mainnet", | ||
} as const; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", | ||
"allowJs": true, | ||
"esModuleInterop": true, | ||
"jsx": "preserve", | ||
"paths": { | ||
"@/*": ["./docs/*"], | ||
"@config/*": ["../../../config/utils/utils/*"], | ||
"@config": ["../../../config/utils/utils"] | ||
}, | ||
"baseUrl": ".", | ||
"skipLibCheck": true | ||
}, | ||
"include": ["**/*.ts", "**/*.tsx", "**/*.md", "**/*.mdx"], | ||
"exclude": ["node_modules"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -714,5 +714,4 @@ export const policies: ContractPolicies = { | |
}, | ||
], | ||
}, | ||
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { Chain, getSeasonAddresses } from "@config"; | ||
import { Chain, getSeasonAddresses } from "@contracts"; | ||
import { env } from "../../env"; | ||
|
||
export const getResourceAddresses = async () => { | ||
const addresses = (await getSeasonAddresses(env.VITE_PUBLIC_CHAIN as Chain)).resources; | ||
export const getResourceAddresses = () => { | ||
const addresses = getSeasonAddresses(env.VITE_PUBLIC_CHAIN as Chain).resources; | ||
return addresses; | ||
}; | ||
|
||
export const getSeasonPassAddress = async () => { | ||
return (await getSeasonAddresses(env.VITE_PUBLIC_CHAIN as Chain)).seasonPass; | ||
export const getSeasonPassAddress = () => { | ||
return getSeasonAddresses(env.VITE_PUBLIC_CHAIN as Chain).seasonPass; | ||
}; | ||
|
||
export const getLordsAddress = async () => { | ||
return (await getSeasonAddresses(env.VITE_PUBLIC_CHAIN as Chain)).lords; | ||
}; | ||
|
||
export const getRealmsAddress = async () => { | ||
return (await getSeasonAddresses(env.VITE_PUBLIC_CHAIN as Chain)).realms; | ||
export const getLordsAddress = () => { | ||
return getSeasonAddresses(env.VITE_PUBLIC_CHAIN as Chain).lords; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve type safety and error handling in resource processing.
The code uses unsafe type casting and lacks proper type definitions: