Update frontend to use v2 version of resolvemarket
This commit is contained in:
parent
2254ad896a
commit
91c727f515
|
@ -4,7 +4,7 @@ import { useState } from 'react'
|
|||
|
||||
import { Contract, FreeResponse } from 'common/contract'
|
||||
import { Col } from '../layout/col'
|
||||
import { resolveMarket } from 'web/lib/firebase/fn-call'
|
||||
import { APIError, resolveMarket } from 'web/lib/firebase/api-call'
|
||||
import { Row } from '../layout/row'
|
||||
import { ChooseCancelSelector } from '../yes-no-selector'
|
||||
import { ResolveConfirmationButton } from '../confirmation-button'
|
||||
|
@ -48,13 +48,18 @@ export function AnswerResolvePanel(props: {
|
|||
contractId: contract.id,
|
||||
})
|
||||
|
||||
const result = await resolveMarket(resolutionProps).then((r) => r.data)
|
||||
|
||||
console.log('resolved', resolutionProps, 'result:', result)
|
||||
|
||||
if (result?.status !== 'success') {
|
||||
setError(result?.message || 'Error resolving market')
|
||||
try {
|
||||
const result = await resolveMarket(resolutionProps)
|
||||
console.log('resolved', resolutionProps, 'result:', result)
|
||||
} catch (e) {
|
||||
if (e instanceof APIError) {
|
||||
setError(e.toString())
|
||||
} else {
|
||||
console.error(e)
|
||||
setError('Error resolving market')
|
||||
}
|
||||
}
|
||||
|
||||
setResolveOption(undefined)
|
||||
setIsSubmitting(false)
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import { User } from 'web/lib/firebase/users'
|
|||
import { NumberCancelSelector } from './yes-no-selector'
|
||||
import { Spacer } from './layout/spacer'
|
||||
import { ResolveConfirmationButton } from './confirmation-button'
|
||||
import { resolveMarket } from 'web/lib/firebase/fn-call'
|
||||
import { APIError, resolveMarket } from 'web/lib/firebase/api-call'
|
||||
import { NumericContract } from 'common/contract'
|
||||
import { BucketInput } from './bucket-input'
|
||||
|
||||
|
@ -37,17 +37,22 @@ export function NumericResolutionPanel(props: {
|
|||
|
||||
setIsSubmitting(true)
|
||||
|
||||
const result = await resolveMarket({
|
||||
outcome: finalOutcome,
|
||||
value,
|
||||
contractId: contract.id,
|
||||
}).then((r) => r.data)
|
||||
|
||||
console.log('resolved', outcome, 'result:', result)
|
||||
|
||||
if (result?.status !== 'success') {
|
||||
setError(result?.message || 'Error resolving market')
|
||||
try {
|
||||
const result = await resolveMarket({
|
||||
outcome: finalOutcome,
|
||||
value,
|
||||
contractId: contract.id,
|
||||
})
|
||||
console.log('resolved', outcome, 'result:', result)
|
||||
} catch (e) {
|
||||
if (e instanceof APIError) {
|
||||
setError(e.toString())
|
||||
} else {
|
||||
console.error(e)
|
||||
setError('Error resolving market')
|
||||
}
|
||||
}
|
||||
|
||||
setIsSubmitting(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import { User } from 'web/lib/firebase/users'
|
|||
import { YesNoCancelSelector } from './yes-no-selector'
|
||||
import { Spacer } from './layout/spacer'
|
||||
import { ResolveConfirmationButton } from './confirmation-button'
|
||||
import { resolveMarket } from 'web/lib/firebase/fn-call'
|
||||
import { APIError, resolveMarket } from 'web/lib/firebase/api-call'
|
||||
import { ProbabilitySelector } from './probability-selector'
|
||||
import { DPM_CREATOR_FEE } from 'common/fees'
|
||||
import { getProbability } from 'common/calculate'
|
||||
|
@ -42,17 +42,22 @@ export function ResolutionPanel(props: {
|
|||
|
||||
setIsSubmitting(true)
|
||||
|
||||
const result = await resolveMarket({
|
||||
outcome,
|
||||
contractId: contract.id,
|
||||
probabilityInt: prob,
|
||||
}).then((r) => r.data)
|
||||
|
||||
console.log('resolved', outcome, 'result:', result)
|
||||
|
||||
if (result?.status !== 'success') {
|
||||
setError(result?.message || 'Error resolving market')
|
||||
try {
|
||||
const result = await resolveMarket({
|
||||
outcome,
|
||||
contractId: contract.id,
|
||||
probabilityInt: prob,
|
||||
})
|
||||
console.log('resolved', outcome, 'result:', result)
|
||||
} catch (e) {
|
||||
if (e instanceof APIError) {
|
||||
setError(e.toString())
|
||||
} else {
|
||||
console.error(e)
|
||||
setError('Error resolving market')
|
||||
}
|
||||
}
|
||||
|
||||
setIsSubmitting(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,10 @@ export function createMarket(params: any) {
|
|||
return call(getFunctionUrl('createmarket'), 'POST', params)
|
||||
}
|
||||
|
||||
export function resolveMarket(params: any) {
|
||||
return call(getFunctionUrl('resolvemarket'), 'POST', params)
|
||||
}
|
||||
|
||||
export function placeBet(params: any) {
|
||||
return call(getFunctionUrl('placebet'), 'POST', params)
|
||||
}
|
||||
|
|
|
@ -29,17 +29,6 @@ export const createAnswer = cloudFunction<
|
|||
}
|
||||
>('createAnswer')
|
||||
|
||||
export const resolveMarket = cloudFunction<
|
||||
{
|
||||
outcome: string
|
||||
value?: number
|
||||
contractId: string
|
||||
probabilityInt?: number
|
||||
resolutions?: { [outcome: string]: number }
|
||||
},
|
||||
{ status: 'error' | 'success'; message?: string }
|
||||
>('resolveMarket')
|
||||
|
||||
export const createUser: () => Promise<User | null> = () => {
|
||||
const local = safeLocalStorage()
|
||||
let deviceToken = local?.getItem('device-token')
|
||||
|
|
Loading…
Reference in New Issue
Block a user