-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
export interface DiscordConfig { | ||
botToken: string; | ||
channelId: string; | ||
} | ||
|
||
export interface AlchemyConfig { | ||
apiKey: string; | ||
} | ||
|
||
export interface IConfig { | ||
discord: DiscordConfig; | ||
alchemy: AlchemyConfig; | ||
} | ||
|
||
const getEnv = (key: string, defaultValue?: string): string => { | ||
const value = process.env[key]; | ||
if (!value) { | ||
if (!defaultValue) { | ||
throw new Error( | ||
`No environment variable for ${key} - doesn't have a default fallback value`, | ||
); | ||
} | ||
return defaultValue; | ||
} | ||
return value; | ||
}; | ||
|
||
export const config: IConfig = { | ||
discord: { | ||
botToken: getEnv('DISCORD_BOT_TOKEN', ''), | ||
channelId: getEnv('DISCORD_CHANNEL_ID', ''), | ||
}, | ||
alchemy: { | ||
apiKey: getEnv('ALCHEMY_API_KEY', ''), | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export function shortenAddress(address: string) { | ||
if (!address) return ""; | ||
return address.slice(0, 6) + "..." + address.slice(-4); | ||
if (!address) return ''; | ||
return address.slice(0, 6) + '...' + address.slice(-4); | ||
} |