Refactor some backend-related stuff (#639)

* web/lib/firebase/api-call -> common/api, web/lib/firebase/api

* Reuse `APIError` type in server code

* Reuse `getFunctionUrl` in server code
This commit is contained in:
Marshall Polaris 2022-07-10 15:03:15 -07:00 committed by GitHub
parent 6462d4a2ed
commit 4700ceb14c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 72 additions and 79 deletions

22
common/api.ts Normal file
View File

@ -0,0 +1,22 @@
import { ENV_CONFIG } from 'common/envs/constants'
export class APIError extends Error {
code: number
details?: unknown
constructor(code: number, message: string, details?: unknown) {
super(message)
this.code = code
this.name = 'APIError'
this.details = details
}
}
export function getFunctionUrl(name: string) {
if (process.env.NEXT_PUBLIC_FIREBASE_EMULATE) {
const { projectId, region } = ENV_CONFIG.firebaseConfig
return `http://localhost:5001/${projectId}/${region}/${name}`
} else {
const { cloudRunId, cloudRunRegion } = ENV_CONFIG
return `https://${name}-${cloudRunId}-${cloudRunRegion}.a.run.app`
}
}

View File

@ -3,13 +3,14 @@ import { logger } from 'firebase-functions/v2'
import { HttpsOptions, onRequest, Request } from 'firebase-functions/v2/https' import { HttpsOptions, onRequest, Request } from 'firebase-functions/v2/https'
import { log } from './utils' import { log } from './utils'
import { z } from 'zod' import { z } from 'zod'
import { APIError } from '../../common/api'
import { PrivateUser } from '../../common/user' import { PrivateUser } from '../../common/user'
import { import {
CORS_ORIGIN_MANIFOLD, CORS_ORIGIN_MANIFOLD,
CORS_ORIGIN_LOCALHOST, CORS_ORIGIN_LOCALHOST,
CORS_ORIGIN_VERCEL, CORS_ORIGIN_VERCEL,
} from '../../common/envs/constants' } from '../../common/envs/constants'
export { APIError } from '../../common/api'
type Output = Record<string, unknown> type Output = Record<string, unknown>
type AuthedUser = { type AuthedUser = {
@ -21,17 +22,6 @@ type JwtCredentials = { kind: 'jwt'; data: admin.auth.DecodedIdToken }
type KeyCredentials = { kind: 'key'; data: string } type KeyCredentials = { kind: 'key'; data: string }
type Credentials = JwtCredentials | KeyCredentials type Credentials = JwtCredentials | KeyCredentials
export class APIError {
code: number
msg: string
details: unknown
constructor(code: number, msg: string, details?: unknown) {
this.code = code
this.msg = msg
this.details = details
}
}
const auth = admin.auth() const auth = admin.auth()
const firestore = admin.firestore() const firestore = admin.firestore()
const privateUsers = firestore.collection( const privateUsers = firestore.collection(
@ -136,7 +126,7 @@ export const newEndpoint = (endpointOpts: EndpointOptions, fn: Handler) => {
res.status(200).json(await fn(req, authedUser)) res.status(200).json(await fn(req, authedUser))
} catch (e) { } catch (e) {
if (e instanceof APIError) { if (e instanceof APIError) {
const output: { [k: string]: unknown } = { message: e.msg } const output: { [k: string]: unknown } = { message: e.message }
if (e.details != null) { if (e.details != null) {
output.details = e.details output.details = e.details
} }

View File

@ -613,7 +613,7 @@
>our Discord</a >our Discord</a
>! Or, >! Or,
<a <a
href="https://unsubscribe-nggbo3neva-uc.a.run.app?id={{userId}}&type=market-resolve" href="{{unsubscribeUrl}}"
style=" style="
font-family: 'Helvetica Neue', Helvetica, Arial, font-family: 'Helvetica Neue', Helvetica, Arial,
sans-serif; sans-serif;

View File

@ -635,7 +635,7 @@
>our Discord</a >our Discord</a
>! Or, >! Or,
<a <a
href="https://unsubscribe-nggbo3neva-uc.a.run.app?id={{userId}}&type=market-resolved" href="{{unsubscribeUrl}}"
style=" style="
font-family: 'Helvetica Neue', Helvetica, Arial, font-family: 'Helvetica Neue', Helvetica, Arial,
sans-serif; sans-serif;

View File

@ -1,4 +1,4 @@
import { DOMAIN, ENV_CONFIG } from '../../common/envs/constants' import { DOMAIN } from '../../common/envs/constants'
import { Answer } from '../../common/answer' import { Answer } from '../../common/answer'
import { Bet } from '../../common/bet' import { Bet } from '../../common/bet'
import { getProbability } from '../../common/calculate' import { getProbability } from '../../common/calculate'
@ -16,6 +16,9 @@ import { formatNumericProbability } from '../../common/pseudo-numeric'
import { sendTemplateEmail } from './send-email' import { sendTemplateEmail } from './send-email'
import { getPrivateUser, getUser } from './utils' import { getPrivateUser, getUser } from './utils'
import { getFunctionUrl } from '../../common/api'
const UNSUBSCRIBE_ENDPOINT = getFunctionUrl('unsubscribe')
export const sendMarketResolutionEmail = async ( export const sendMarketResolutionEmail = async (
userId: string, userId: string,
@ -53,6 +56,9 @@ export const sendMarketResolutionEmail = async (
? ` (plus ${formatMoney(creatorPayout)} in commissions)` ? ` (plus ${formatMoney(creatorPayout)} in commissions)`
: '' : ''
const emailType = 'market-resolved'
const unsubscribeUrl = `${UNSUBSCRIBE_ENDPOINT}?id=${userId}&type=${emailType}`
const templateData: market_resolved_template = { const templateData: market_resolved_template = {
userId: user.id, userId: user.id,
name: user.name, name: user.name,
@ -62,6 +68,7 @@ export const sendMarketResolutionEmail = async (
investment: `${Math.floor(investment)}`, investment: `${Math.floor(investment)}`,
payout: `${Math.floor(payout)}${creatorPayoutText}`, payout: `${Math.floor(payout)}${creatorPayoutText}`,
url: `https://${DOMAIN}/${creator.username}/${contract.slug}`, url: `https://${DOMAIN}/${creator.username}/${contract.slug}`,
unsubscribeUrl,
} }
// Modify template here: // Modify template here:
@ -85,6 +92,7 @@ type market_resolved_template = {
investment: string investment: string
payout: string payout: string
url: string url: string
unsubscribeUrl: string
} }
const toDisplayResolution = ( const toDisplayResolution = (
@ -141,8 +149,7 @@ export const sendWelcomeEmail = async (
const firstName = name.split(' ')[0] const firstName = name.split(' ')[0]
const emailType = 'generic' const emailType = 'generic'
const { cloudRunId, cloudRunRegion } = ENV_CONFIG const unsubscribeLink = `${UNSUBSCRIBE_ENDPOINT}?id=${userId}&type=${emailType}`
const unsubscribeLink = `https://unsubscribe-${cloudRunId}-${cloudRunRegion}.a.run.app?id=${userId}&type=${emailType}`
await sendTemplateEmail( await sendTemplateEmail(
privateUser.email, privateUser.email,
@ -174,8 +181,7 @@ export const sendOneWeekBonusEmail = async (
const firstName = name.split(' ')[0] const firstName = name.split(' ')[0]
const emailType = 'generic' const emailType = 'generic'
const { cloudRunId, cloudRunRegion } = ENV_CONFIG const unsubscribeLink = `${UNSUBSCRIBE_ENDPOINT}?id=${userId}&type=${emailType}`
const unsubscribeLink = `https://unsubscribe-${cloudRunId}-${cloudRunRegion}.a.run.app?id=${userId}&type=${emailType}`
await sendTemplateEmail( await sendTemplateEmail(
privateUser.email, privateUser.email,
@ -207,8 +213,7 @@ export const sendThankYouEmail = async (
const firstName = name.split(' ')[0] const firstName = name.split(' ')[0]
const emailType = 'generic' const emailType = 'generic'
const { cloudRunId, cloudRunRegion } = ENV_CONFIG const unsubscribeLink = `${UNSUBSCRIBE_ENDPOINT}?id=${userId}&type=${emailType}`
const unsubscribeLink = `https://unsubscribe-${cloudRunId}-${cloudRunRegion}.a.run.app?id=${userId}&type=${emailType}`
await sendTemplateEmail( await sendTemplateEmail(
privateUser.email, privateUser.email,
@ -242,6 +247,8 @@ export const sendMarketCloseEmail = async (
const { question, slug, volume, mechanism, collectedFees } = contract const { question, slug, volume, mechanism, collectedFees } = contract
const url = `https://${DOMAIN}/${username}/${slug}` const url = `https://${DOMAIN}/${username}/${slug}`
const emailType = 'market-resolve'
const unsubscribeUrl = `${UNSUBSCRIBE_ENDPOINT}?id=${userId}&type=${emailType}`
await sendTemplateEmail( await sendTemplateEmail(
privateUser.email, privateUser.email,
@ -250,6 +257,7 @@ export const sendMarketCloseEmail = async (
{ {
question, question,
url, url,
unsubscribeUrl,
userId, userId,
name: firstName, name: firstName,
volume: formatMoney(volume), volume: formatMoney(volume),
@ -281,8 +289,7 @@ export const sendNewCommentEmail = async (
const { question, creatorUsername, slug } = contract const { question, creatorUsername, slug } = contract
const marketUrl = `https://${DOMAIN}/${creatorUsername}/${slug}#${comment.id}` const marketUrl = `https://${DOMAIN}/${creatorUsername}/${slug}#${comment.id}`
const emailType = 'market-comment' const emailType = 'market-comment'
const { cloudRunId, cloudRunRegion } = ENV_CONFIG const unsubscribeUrl = `${UNSUBSCRIBE_ENDPOINT}?id=${userId}&type=${emailType}`
const unsubscribeUrl = `https://unsubscribe-${cloudRunId}-${cloudRunRegion}.a.run.app?id=${userId}&type=${emailType}`
const { name: commentorName, avatarUrl: commentorAvatarUrl } = commentCreator const { name: commentorName, avatarUrl: commentorAvatarUrl } = commentCreator
const { text } = comment const { text } = comment
@ -364,8 +371,7 @@ export const sendNewAnswerEmail = async (
const marketUrl = `https://${DOMAIN}/${creatorUsername}/${slug}` const marketUrl = `https://${DOMAIN}/${creatorUsername}/${slug}`
const emailType = 'market-answer' const emailType = 'market-answer'
const { cloudRunId, cloudRunRegion } = ENV_CONFIG const unsubscribeUrl = `${UNSUBSCRIBE_ENDPOINT}?id=${userId}&type=${emailType}`
const unsubscribeUrl = `https://unsubscribe-${cloudRunId}-${cloudRunRegion}.a.run.app?id=${userId}&type=${emailType}`
const subject = `New answer on ${question}` const subject = `New answer on ${question}`
const from = `${name} <info@manifold.markets>` const from = `${name} <info@manifold.markets>`

View File

@ -6,7 +6,7 @@ import { Answer } from 'common/answer'
import { FreeResponseContract } from 'common/contract' import { FreeResponseContract } from 'common/contract'
import { BuyAmountInput } from '../amount-input' import { BuyAmountInput } from '../amount-input'
import { Col } from '../layout/col' import { Col } from '../layout/col'
import { APIError, placeBet } from 'web/lib/firebase/api-call' import { APIError, placeBet } from 'web/lib/firebase/api'
import { Row } from '../layout/row' import { Row } from '../layout/row'
import { Spacer } from '../layout/spacer' import { Spacer } from '../layout/spacer'
import { import {

View File

@ -4,7 +4,7 @@ import { useState } from 'react'
import { Contract, FreeResponse } from 'common/contract' import { Contract, FreeResponse } from 'common/contract'
import { Col } from '../layout/col' import { Col } from '../layout/col'
import { APIError, resolveMarket } from 'web/lib/firebase/api-call' import { APIError, resolveMarket } from 'web/lib/firebase/api'
import { Row } from '../layout/row' import { Row } from '../layout/row'
import { ChooseCancelSelector } from '../yes-no-selector' import { ChooseCancelSelector } from '../yes-no-selector'
import { ResolveConfirmationButton } from '../confirmation-button' import { ResolveConfirmationButton } from '../confirmation-button'

View File

@ -6,7 +6,7 @@ import { findBestMatch } from 'string-similarity'
import { FreeResponseContract } from 'common/contract' import { FreeResponseContract } from 'common/contract'
import { BuyAmountInput } from '../amount-input' import { BuyAmountInput } from '../amount-input'
import { Col } from '../layout/col' import { Col } from '../layout/col'
import { APIError, createAnswer } from 'web/lib/firebase/api-call' import { APIError, createAnswer } from 'web/lib/firebase/api'
import { Row } from '../layout/row' import { Row } from '../layout/row'
import { import {
formatMoney, formatMoney,

View File

@ -19,8 +19,8 @@ import { getBinaryCpmmBetInfo } from 'common/new-bet'
import { Title } from './title' import { Title } from './title'
import { User } from 'web/lib/firebase/users' import { User } from 'web/lib/firebase/users'
import { Bet, LimitBet } from 'common/bet' import { Bet, LimitBet } from 'common/bet'
import { APIError, placeBet } from 'web/lib/firebase/api-call' import { APIError, placeBet } from 'web/lib/firebase/api'
import { sellShares } from 'web/lib/firebase/api-call' import { sellShares } from 'web/lib/firebase/api'
import { AmountInput, BuyAmountInput } from './amount-input' import { AmountInput, BuyAmountInput } from './amount-input'
import { InfoTooltip } from './info-tooltip' import { InfoTooltip } from './info-tooltip'
import { BinaryOutcomeLabel } from './outcome-label' import { BinaryOutcomeLabel } from './outcome-label'

View File

@ -23,7 +23,7 @@ import {
} from 'web/lib/firebase/contracts' } from 'web/lib/firebase/contracts'
import { Row } from './layout/row' import { Row } from './layout/row'
import { UserLink } from './user-page' import { UserLink } from './user-page'
import { sellBet } from 'web/lib/firebase/api-call' import { sellBet } from 'web/lib/firebase/api'
import { ConfirmationButton } from './confirmation-button' import { ConfirmationButton } from './confirmation-button'
import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label' import { OutcomeLabel, YesLabel, NoLabel } from './outcome-label'
import { filterDefined } from 'common/util/array' import { filterDefined } from 'common/util/array'

View File

@ -22,14 +22,14 @@ import {
import { useState } from 'react' import { useState } from 'react'
import toast from 'react-hot-toast' import toast from 'react-hot-toast'
import { useUserContractBets } from 'web/hooks/use-user-bets' import { useUserContractBets } from 'web/hooks/use-user-bets'
import { placeBet } from 'web/lib/firebase/api-call' import { placeBet } from 'web/lib/firebase/api'
import { getBinaryProb, getBinaryProbPercent } from 'web/lib/firebase/contracts' import { getBinaryProb, getBinaryProbPercent } from 'web/lib/firebase/contracts'
import TriangleDownFillIcon from 'web/lib/icons/triangle-down-fill-icon' import TriangleDownFillIcon from 'web/lib/icons/triangle-down-fill-icon'
import TriangleFillIcon from 'web/lib/icons/triangle-fill-icon' import TriangleFillIcon from 'web/lib/icons/triangle-fill-icon'
import { Col } from '../layout/col' import { Col } from '../layout/col'
import { OUTCOME_TO_COLOR } from '../outcome-label' import { OUTCOME_TO_COLOR } from '../outcome-label'
import { useSaveBinaryShares } from '../use-save-binary-shares' import { useSaveBinaryShares } from '../use-save-binary-shares'
import { sellShares } from 'web/lib/firebase/api-call' import { sellShares } from 'web/lib/firebase/api'
import { calculateCpmmSale, getCpmmProbability } from 'common/calculate-cpmm' import { calculateCpmmSale, getCpmmProbability } from 'common/calculate-cpmm'
import { track } from 'web/lib/service/analytics' import { track } from 'web/lib/service/analytics'
import { formatNumericProbability } from 'common/pseudo-numeric' import { formatNumericProbability } from 'common/pseudo-numeric'

View File

@ -9,7 +9,7 @@ import { Title } from '../title'
import { FilterSelectUsers } from 'web/components/filter-select-users' import { FilterSelectUsers } from 'web/components/filter-select-users'
import { User } from 'common/user' import { User } from 'common/user'
import { MAX_GROUP_NAME_LENGTH } from 'common/group' import { MAX_GROUP_NAME_LENGTH } from 'common/group'
import { createGroup } from 'web/lib/firebase/api-call' import { createGroup } from 'web/lib/firebase/api'
export function CreateGroupButton(props: { export function CreateGroupButton(props: {
user: User user: User

View File

@ -5,7 +5,7 @@ import { getFormattedMappedValue } from 'common/pseudo-numeric'
import { formatMoney, formatPercent } from 'common/util/format' import { formatMoney, formatPercent } from 'common/util/format'
import { sortBy } from 'lodash' import { sortBy } from 'lodash'
import { useState } from 'react' import { useState } from 'react'
import { cancelBet } from 'web/lib/firebase/api-call' import { cancelBet } from 'web/lib/firebase/api'
import { Col } from './layout/col' import { Col } from './layout/col'
import { LoadingIndicator } from './loading-indicator' import { LoadingIndicator } from './loading-indicator'
import { BinaryOutcomeLabel, PseudoNumericOutcomeLabel } from './outcome-label' import { BinaryOutcomeLabel, PseudoNumericOutcomeLabel } from './outcome-label'

View File

@ -4,7 +4,7 @@ import { useEffect, useState } from 'react'
import { CPMMContract } from 'common/contract' import { CPMMContract } from 'common/contract'
import { formatMoney } from 'common/util/format' import { formatMoney } from 'common/util/format'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { addLiquidity, withdrawLiquidity } from 'web/lib/firebase/api-call' import { addLiquidity, withdrawLiquidity } from 'web/lib/firebase/api'
import { AmountInput } from './amount-input' import { AmountInput } from './amount-input'
import { Row } from './layout/row' import { Row } from './layout/row'
import { useUserLiquidity } from 'web/hooks/use-liquidity' import { useUserLiquidity } from 'web/hooks/use-liquidity'

View File

@ -6,7 +6,7 @@ import { usePrivateUser, useUser } from 'web/hooks/use-user'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import { useUnseenPreferredNotificationGroups } from 'web/hooks/use-notifications' import { useUnseenPreferredNotificationGroups } from 'web/hooks/use-notifications'
import { NOTIFICATIONS_PER_PAGE } from 'web/pages/notifications' import { NOTIFICATIONS_PER_PAGE } from 'web/pages/notifications'
import { requestBonuses } from 'web/lib/firebase/api-call' import { requestBonuses } from 'web/lib/firebase/api'
import { PrivateUser } from 'common/user' import { PrivateUser } from 'common/user'
export default function NotificationsIcon(props: { className?: string }) { export default function NotificationsIcon(props: { className?: string }) {

View File

@ -10,9 +10,9 @@ import {
import { NumericContract } from 'common/contract' import { NumericContract } from 'common/contract'
import { formatPercent, formatMoney } from 'common/util/format' import { formatPercent, formatMoney } from 'common/util/format'
import { useUser } from '../hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { APIError, placeBet } from '../lib/firebase/api-call' import { APIError, placeBet } from 'web/lib/firebase/api'
import { User } from '../lib/firebase/users' import { User } from 'web/lib/firebase/users'
import { BuyAmountInput } from './amount-input' import { BuyAmountInput } from './amount-input'
import { BucketInput } from './bucket-input' import { BucketInput } from './bucket-input'
import { Col } from './layout/col' import { Col } from './layout/col'

View File

@ -7,7 +7,7 @@ import { NumberCancelSelector } from './yes-no-selector'
import { Spacer } from './layout/spacer' import { Spacer } from './layout/spacer'
import { ResolveConfirmationButton } from './confirmation-button' import { ResolveConfirmationButton } from './confirmation-button'
import { NumericContract, PseudoNumericContract } from 'common/contract' import { NumericContract, PseudoNumericContract } from 'common/contract'
import { APIError, resolveMarket } from 'web/lib/firebase/api-call' import { APIError, resolveMarket } from 'web/lib/firebase/api'
import { BucketInput } from './bucket-input' import { BucketInput } from './bucket-input'
import { getPseudoProbability } from 'common/pseudo-numeric' import { getPseudoProbability } from 'common/pseudo-numeric'

View File

@ -6,7 +6,7 @@ import { User } from 'web/lib/firebase/users'
import { YesNoCancelSelector } from './yes-no-selector' import { YesNoCancelSelector } from './yes-no-selector'
import { Spacer } from './layout/spacer' import { Spacer } from './layout/spacer'
import { ResolveConfirmationButton } from './confirmation-button' import { ResolveConfirmationButton } from './confirmation-button'
import { APIError, resolveMarket } from 'web/lib/firebase/api-call' import { APIError, resolveMarket } from 'web/lib/firebase/api'
import { ProbabilitySelector } from './probability-selector' import { ProbabilitySelector } from './probability-selector'
import { DPM_CREATOR_FEE } from 'common/fees' import { DPM_CREATOR_FEE } from 'common/fees'
import { getProbability } from 'common/calculate' import { getProbability } from 'common/calculate'

View File

@ -11,7 +11,7 @@ import { debounce, sum } from 'lodash'
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from 'react'
import { CommentTips } from 'web/hooks/use-tip-txns' import { CommentTips } from 'web/hooks/use-tip-txns'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { transact } from 'web/lib/firebase/api-call' import { transact } from 'web/lib/firebase/api'
import { track } from 'web/lib/service/analytics' import { track } from 'web/lib/service/analytics'
import { Row } from './layout/row' import { Row } from './layout/row'
import { Tooltip } from './tooltip' import { Tooltip } from './tooltip'

View File

@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next' import { NextApiRequest, NextApiResponse } from 'next'
import { promisify } from 'util' import { promisify } from 'util'
import { pipeline } from 'stream' import { pipeline } from 'stream'
import { getFunctionUrl } from 'web/lib/firebase/api-call' import { getFunctionUrl } from 'common/api'
import fetch, { Headers, Response } from 'node-fetch' import fetch, { Headers, Response } from 'node-fetch'
function getProxiedRequestHeaders(req: NextApiRequest, whitelist: string[]) { function getProxiedRequestHeaders(req: NextApiRequest, whitelist: string[]) {

View File

@ -1,16 +1,6 @@
import { auth } from './users' import { auth } from './users'
import { ENV_CONFIG } from 'common/envs/constants' import { APIError, getFunctionUrl } from 'common/api'
export { APIError } from 'common/api'
export class APIError extends Error {
code: number
details?: string
constructor(code: number, message: string, details?: string) {
super(message)
this.code = code
this.name = 'APIError'
this.details = details
}
}
export async function call(url: string, method: string, params: any) { export async function call(url: string, method: string, params: any) {
const user = auth.currentUser const user = auth.currentUser
@ -35,21 +25,6 @@ export async function call(url: string, method: string, params: any) {
}) })
} }
// Our users access the API through the Vercel proxy routes at /api/v0/blah,
// but right now at least until we get performance under control let's have the
// app just hit the cloud functions directly -- there's no difference and it's
// one less hop
export function getFunctionUrl(name: string) {
if (process.env.NEXT_PUBLIC_FIREBASE_EMULATE) {
const { projectId, region } = ENV_CONFIG.firebaseConfig
return `http://localhost:5001/${projectId}/${region}/${name}`
} else {
const { cloudRunId, cloudRunRegion } = ENV_CONFIG
return `https://${name}-${cloudRunId}-${cloudRunRegion}.a.run.app`
}
}
export function createAnswer(params: any) { export function createAnswer(params: any) {
return call(getFunctionUrl('createanswer'), 'POST', params) return call(getFunctionUrl('createanswer'), 'POST', params)
} }

View File

@ -23,7 +23,7 @@ import {
import { zip } from 'lodash' import { zip } from 'lodash'
import { app, db } from './init' import { app, db } from './init'
import { PortfolioMetrics, PrivateUser, User } from 'common/user' import { PortfolioMetrics, PrivateUser, User } from 'common/user'
import { createUser } from './api-call' import { createUser } from './api'
import { import {
coll, coll,
getValue, getValue,

View File

@ -1,4 +1,4 @@
import { getFunctionUrl } from 'web/lib/firebase/api-call' import { getFunctionUrl } from 'common/api'
export const checkoutURL = ( export const checkoutURL = (
userId: string, userId: string,

View File

@ -10,7 +10,7 @@ import { Spacer } from 'web/components/layout/spacer'
import { User } from 'common/user' import { User } from 'common/user'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { Linkify } from 'web/components/linkify' import { Linkify } from 'web/components/linkify'
import { transact } from 'web/lib/firebase/api-call' import { transact } from 'web/lib/firebase/api'
import { charities, Charity } from 'common/charity' import { charities, Charity } from 'common/charity'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import Custom404 from '../404' import Custom404 from '../404'

View File

@ -6,7 +6,7 @@ import Textarea from 'react-expanding-textarea'
import { Spacer } from 'web/components/layout/spacer' import { Spacer } from 'web/components/layout/spacer'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { Contract, contractPath } from 'web/lib/firebase/contracts' import { Contract, contractPath } from 'web/lib/firebase/contracts'
import { createMarket } from 'web/lib/firebase/api-call' import { createMarket } from 'web/lib/firebase/api'
import { FIXED_ANTE } from 'common/antes' import { FIXED_ANTE } from 'common/antes'
import { InfoTooltip } from 'web/components/info-tooltip' import { InfoTooltip } from 'web/components/info-tooltip'
import { Page } from 'web/components/page' import { Page } from 'web/components/page'

View File

@ -2,7 +2,7 @@ import { useRouter } from 'next/router'
import { useState } from 'react' import { useState } from 'react'
import { SEO } from 'web/components/SEO' import { SEO } from 'web/components/SEO'
import { Title } from 'web/components/title' import { Title } from 'web/components/title'
import { claimManalink } from 'web/lib/firebase/api-call' import { claimManalink } from 'web/lib/firebase/api'
import { useManalink } from 'web/lib/firebase/manalinks' import { useManalink } from 'web/lib/firebase/manalinks'
import { ManalinkCard } from 'web/components/manalink-card' import { ManalinkCard } from 'web/components/manalink-card'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'

View File

@ -16,7 +16,7 @@ import { Linkify } from 'web/components/linkify'
import { Page } from 'web/components/page' import { Page } from 'web/components/page'
import { Title } from 'web/components/title' import { Title } from 'web/components/title'
import { useUser } from 'web/hooks/use-user' import { useUser } from 'web/hooks/use-user'
import { createMarket } from 'web/lib/firebase/api-call' import { createMarket } from 'web/lib/firebase/api'
import { contractPath } from 'web/lib/firebase/contracts' import { contractPath } from 'web/lib/firebase/contracts'
type Prediction = { type Prediction = {

View File

@ -9,7 +9,7 @@ import { Title } from 'web/components/title'
import { usePrivateUser, useUser } from 'web/hooks/use-user' import { usePrivateUser, useUser } from 'web/hooks/use-user'
import { formatMoney } from 'common/util/format' import { formatMoney } from 'common/util/format'
import { cleanDisplayName, cleanUsername } from 'common/util/clean-username' import { cleanDisplayName, cleanUsername } from 'common/util/clean-username'
import { changeUserInfo } from 'web/lib/firebase/api-call' import { changeUserInfo } from 'web/lib/firebase/api'
import { uploadImage } from 'web/lib/firebase/storage' import { uploadImage } from 'web/lib/firebase/storage'
import { Col } from 'web/components/layout/col' import { Col } from 'web/components/layout/col'
import { Row } from 'web/components/layout/row' import { Row } from 'web/components/layout/row'