Use environment variable for SourceCred ledger branch

This prevents people from accidentally mesing up the master ledger in local / staging environments.
This commit is contained in:
Hammad Jutt
2021-06-09 12:11:08 -06:00
parent 1063e245c8
commit 3cfaa8f083
5 changed files with 16 additions and 4 deletions

View File

@@ -12,7 +12,7 @@ interface IConfig {
infuraId: string;
pSEEDAddress: string;
brightIdAppUrl: string;
discordBotToken: string;
sourceCredLedgerBranch: string;
}
function parseEnv<T extends string | number>(
@@ -73,5 +73,8 @@ export const CONFIG: IConfig = {
process.env.NEXT_BRIGHTID_APP_URL,
'https://app.brightid.org',
),
discordBotToken: parseEnv(process.env.DISCORD_BOT_TOKEN, ''),
sourceCredLedgerBranch: parseEnv(
process.env.SOURCECRED_LEDGER_BRANCH,
'staging', // Just so we dont mess up the master ledger in case people are testing locally
),
};

View File

@@ -6,7 +6,7 @@ import { CONFIG } from '../config';
const storage = new sourcecred.ledger.storage.GithubStorage({
apiToken: CONFIG.githubApiToken,
repo: 'MetaFam/XP',
branch: 'master',
branch: CONFIG.sourceCredLedgerBranch,
});
export const ledgerManager: LedgerManager = new sourcecred.ledger.manager.LedgerManager(

View File

@@ -9,6 +9,7 @@ interface IConfig {
githubApiToken: string;
discordBotToken: string;
discordBotClientSecret: string;
sourceCredLedgerBranch: string;
}
function parseEnv<T extends string | number>(
@@ -42,4 +43,8 @@ export const CONFIG: IConfig = {
githubApiToken: parseEnv(process.env.GITHUB_API_TOKEN, ''),
discordBotToken: parseEnv(process.env.DISCORD_BOT_TOKEN, ''),
discordBotClientSecret: parseEnv(process.env.DISCORD_BOT_CLIENT_SECRET, ''),
sourceCredLedgerBranch: parseEnv(
process.env.SOURCECRED_LEDGER_BRANCH,
'staging', // Just so we dont mess up the master ledger in case people are testing locally
),
};

View File

@@ -5,7 +5,7 @@ import { CONFIG } from './config';
const storage = new sourcecred.ledger.storage.GithubStorage({
apiToken: CONFIG.githubApiToken,
repo: 'MetaFam/XP',
branch: 'master',
branch: CONFIG.sourceCredLedgerBranch,
});
export const manager: LedgerManager = new sourcecred.ledger.manager.LedgerManager(