diff --git a/functions/src/resolve-market.ts b/functions/src/resolve-market.ts
index f2a65ee3..44293898 100644
--- a/functions/src/resolve-market.ts
+++ b/functions/src/resolve-market.ts
@@ -76,14 +76,18 @@ export const resolvemarket = newEndpoint(opts, async (req, auth) => {
throw new APIError(404, 'No contract exists with the provided ID')
const contract = contractSnap.data() as Contract
const { creatorId, closeTime } = contract
- const user = await admin.auth().getUser(auth.uid)
+ const firebaseUser = await admin.auth().getUser(auth.uid)
const { value, resolutions, probabilityInt, outcome } = getResolutionParams(
contract,
req.body
)
- if (creatorId !== auth.uid && !isManifoldId(auth.uid) && !isAdmin(user.email))
+ if (
+ creatorId !== auth.uid &&
+ !isManifoldId(auth.uid) &&
+ !isAdmin(firebaseUser.email)
+ )
throw new APIError(403, 'User is not creator of contract')
if (contract.resolution) throw new APIError(400, 'Contract already resolved')
diff --git a/web/components/answers/answers-panel.tsx b/web/components/answers/answers-panel.tsx
index cc77b51d..41b7f0f9 100644
--- a/web/components/answers/answers-panel.tsx
+++ b/web/components/answers/answers-panel.tsx
@@ -25,6 +25,7 @@ import { BuyButton } from 'web/components/yes-no-selector'
import { UserLink } from 'web/components/user-link'
import { Button } from 'web/components/button'
import { useAdmin } from 'web/hooks/use-admin'
+import { needsAdminToResolve } from 'web/pages/[username]/[contractSlug]'
export function AnswersPanel(props: {
contract: FreeResponseContract | MultipleChoiceContract
@@ -156,19 +157,20 @@ export function AnswersPanel(props: {
)}
- {(user?.id === creatorId || isAdmin) && !resolution && (
- <>
-
-
- >
- )}
+ {(user?.id === creatorId || (isAdmin && needsAdminToResolve(contract))) &&
+ !resolution && (
+ <>
+
+
+ >
+ )}
)
}
diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx
index 51254fe6..2c011c90 100644
--- a/web/pages/[username]/[contractSlug].tsx
+++ b/web/pages/[username]/[contractSlug].tsx
@@ -46,6 +46,7 @@ import { ContractsGrid } from 'web/components/contract/contracts-grid'
import { Title } from 'web/components/title'
import { usePrefetch } from 'web/hooks/use-prefetch'
import { useAdmin } from 'web/hooks/use-admin'
+import dayjs from 'dayjs'
export const getStaticProps = fromPropz(getStaticPropz)
export async function getStaticPropz(props: {
@@ -111,6 +112,11 @@ export default function ContractPage(props: {
)
}
+// requires an admin to resolve a week after market closes
+export function needsAdminToResolve(contract: Contract) {
+ return !contract.isResolved && dayjs().diff(contract.closeTime, 'day') > 7
+}
+
export function ContractPageSidebar(props: {
user: User | null | undefined
contract: Contract
@@ -123,7 +129,10 @@ export function ContractPageSidebar(props: {
const isNumeric = outcomeType === 'NUMERIC'
const allowTrade = tradingAllowed(contract)
const isAdmin = useAdmin()
- const allowResolve = !isResolved && (isCreator || isAdmin) && !!user
+ const allowResolve =
+ !isResolved &&
+ (isCreator || (needsAdminToResolve(contract) && isAdmin)) &&
+ !!user
const hasSidePanel =
(isBinary || isNumeric || isPseudoNumeric) && (allowTrade || allowResolve)