Migrate per-env code into common/
This commit is contained in:
parent
95e24e9b87
commit
4b216b682e
|
@ -11,3 +11,46 @@ export function isAdmin(email: string) {
|
|||
]
|
||||
return ADMINS.includes(email)
|
||||
}
|
||||
|
||||
const ENV = process.env.NEXT_PUBLIC_FIREBASE_ENV ?? 'PROD'
|
||||
|
||||
export const DOMAINS = {
|
||||
PROD: 'manifold.markets',
|
||||
DEV: 'manifold.markets',
|
||||
THEOREMONE: 'theoremone.manifold.markets',
|
||||
}
|
||||
|
||||
export const FIREBASE_CONFIGS = {
|
||||
PROD: {
|
||||
apiKey: 'AIzaSyDp3J57vLeAZCzxLD-vcPaGIkAmBoGOSYw',
|
||||
authDomain: 'mantic-markets.firebaseapp.com',
|
||||
projectId: 'mantic-markets',
|
||||
storageBucket: 'mantic-markets.appspot.com',
|
||||
messagingSenderId: '128925704902',
|
||||
appId: '1:128925704902:web:f61f86944d8ffa2a642dc7',
|
||||
measurementId: 'G-SSFK1Q138D',
|
||||
},
|
||||
DEV: {
|
||||
apiKey: 'AIzaSyBoq3rzUa8Ekyo3ZaTnlycQYPRCA26VpOw',
|
||||
authDomain: 'dev-mantic-markets.firebaseapp.com',
|
||||
projectId: 'dev-mantic-markets',
|
||||
storageBucket: 'dev-mantic-markets.appspot.com',
|
||||
messagingSenderId: '134303100058',
|
||||
appId: '1:134303100058:web:27f9ea8b83347251f80323',
|
||||
measurementId: 'G-YJC9E37P37',
|
||||
},
|
||||
THEOREMONE: {
|
||||
apiKey: 'AIzaSyBSXL6Ys7InNHnCKSy-_E_luhh4Fkj4Z6M',
|
||||
authDomain: 'theoremone-manifold.firebaseapp.com',
|
||||
projectId: 'theoremone-manifold',
|
||||
storageBucket: 'theoremone-manifold.appspot.com',
|
||||
messagingSenderId: '698012149198',
|
||||
appId: '1:698012149198:web:b342af75662831aa84b79f',
|
||||
measurementId: 'G-Y3EZ1WNT6E',
|
||||
},
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
export const DOMAIN = DOMAINS[ENV]
|
||||
// @ts-ignore
|
||||
export const PROJECT_ID = FIREBASE_CONFIGS[ENV].projectId
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import _ = require('lodash')
|
||||
import { DOMAIN } from '../../common/access'
|
||||
import { Answer } from '../../common/answer'
|
||||
import { Bet } from '../../common/bet'
|
||||
import { getProbability } from '../../common/calculate'
|
||||
|
@ -73,7 +74,7 @@ export const sendMarketResolutionEmail = async (
|
|||
outcome,
|
||||
investment: `${Math.round(investment)}`,
|
||||
payout: `${Math.round(payout)}`,
|
||||
url: `https://manifold.markets/${creator.username}/${contract.slug}`,
|
||||
url: `https://${DOMAIN}/${creator.username}/${contract.slug}`,
|
||||
}
|
||||
|
||||
// Modify template here:
|
||||
|
@ -107,7 +108,7 @@ Or come chat with us on Discord: https://discord.gg/eHQBNBqXuh
|
|||
|
||||
Best,
|
||||
Austin from Manifold
|
||||
https://manifold.markets/`
|
||||
https://${DOMAIN}/`
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -128,7 +129,7 @@ export const sendMarketCloseEmail = async (
|
|||
|
||||
const { question, pool: pools, slug } = contract
|
||||
const pool = formatMoney(_.sum(_.values(pools)))
|
||||
const url = `https://manifold.markets/${username}/${slug}`
|
||||
const url = `https://${DOMAIN}/${username}/${slug}`
|
||||
|
||||
await sendTemplateEmail(
|
||||
privateUser.email,
|
||||
|
@ -162,7 +163,7 @@ export const sendNewCommentEmail = async (
|
|||
return
|
||||
|
||||
const { question, creatorUsername, slug } = contract
|
||||
const marketUrl = `https://manifold.markets/${creatorUsername}/${slug}`
|
||||
const marketUrl = `https://${DOMAIN}/${creatorUsername}/${slug}`
|
||||
|
||||
const unsubscribeUrl = `https://us-central1-${
|
||||
isProd ? 'mantic-markets' : 'dev-mantic-markets'
|
||||
|
@ -238,7 +239,7 @@ export const sendNewAnswerEmail = async (
|
|||
const { question, creatorUsername, slug } = contract
|
||||
const { name, avatarUrl, text } = answer
|
||||
|
||||
const marketUrl = `https://manifold.markets/${creatorUsername}/${slug}`
|
||||
const marketUrl = `https://${DOMAIN}/${creatorUsername}/${slug}`
|
||||
const unsubscribeUrl = `https://us-central1-${
|
||||
isProd ? 'mantic-markets' : 'dev-mantic-markets'
|
||||
}.cloudfunctions.net/unsubscribe?id=${userId}&type=market-answer`
|
||||
|
|
|
@ -1,39 +1,12 @@
|
|||
import { getFirestore } from '@firebase/firestore'
|
||||
import { initializeApp, getApps, getApp } from 'firebase/app'
|
||||
import { FIREBASE_CONFIGS } from '../../../common/access'
|
||||
|
||||
// Used to decide which Stripe instance to point to
|
||||
export const isProd = process.env.NEXT_PUBLIC_FIREBASE_ENV !== 'DEV'
|
||||
|
||||
const FIREBASE_CONFIGS = {
|
||||
PROD: {
|
||||
apiKey: 'AIzaSyDp3J57vLeAZCzxLD-vcPaGIkAmBoGOSYw',
|
||||
authDomain: 'mantic-markets.firebaseapp.com',
|
||||
projectId: 'mantic-markets',
|
||||
storageBucket: 'mantic-markets.appspot.com',
|
||||
messagingSenderId: '128925704902',
|
||||
appId: '1:128925704902:web:f61f86944d8ffa2a642dc7',
|
||||
measurementId: 'G-SSFK1Q138D',
|
||||
},
|
||||
DEV: {
|
||||
apiKey: 'AIzaSyBoq3rzUa8Ekyo3ZaTnlycQYPRCA26VpOw',
|
||||
authDomain: 'dev-mantic-markets.firebaseapp.com',
|
||||
projectId: 'dev-mantic-markets',
|
||||
storageBucket: 'dev-mantic-markets.appspot.com',
|
||||
messagingSenderId: '134303100058',
|
||||
appId: '1:134303100058:web:27f9ea8b83347251f80323',
|
||||
measurementId: 'G-YJC9E37P37',
|
||||
},
|
||||
THEOREMONE: {
|
||||
apiKey: 'AIzaSyBSXL6Ys7InNHnCKSy-_E_luhh4Fkj4Z6M',
|
||||
authDomain: 'theoremone-manifold.firebaseapp.com',
|
||||
projectId: 'theoremone-manifold',
|
||||
storageBucket: 'theoremone-manifold.appspot.com',
|
||||
messagingSenderId: '698012149198',
|
||||
appId: '1:698012149198:web:b342af75662831aa84b79f',
|
||||
measurementId: 'G-Y3EZ1WNT6E',
|
||||
},
|
||||
}
|
||||
const ENV = process.env.NEXT_PUBLIC_FIREBASE_ENV ?? 'PROD'
|
||||
// TODO: Move this to access.ts
|
||||
export const IS_PRIVATE_MANIFOLD = !['PROD', 'DEV'].includes(ENV)
|
||||
// @ts-ignore
|
||||
const firebaseConfig = FIREBASE_CONFIGS[ENV]
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import { isProd } from '../firebase/init'
|
||||
import { PROJECT_ID } from '../../../common/access'
|
||||
|
||||
export const checkoutURL = (
|
||||
userId: string,
|
||||
manticDollarQuantity: number,
|
||||
referer = ''
|
||||
) => {
|
||||
const endpoint = isProd
|
||||
? 'https://us-central1-mantic-markets.cloudfunctions.net/createCheckoutSession'
|
||||
: 'https://us-central1-dev-mantic-markets.cloudfunctions.net/createCheckoutSession'
|
||||
const endpoint = `https://us-central1-${PROJECT_ID}.cloudfunctions.net/createCheckoutSession`
|
||||
|
||||
return `${endpoint}?userId=${userId}&manticDollarQuantity=${manticDollarQuantity}&referer=${encodeURIComponent(
|
||||
referer
|
||||
|
|
Loading…
Reference in New Issue
Block a user