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 { Contract, FreeResponse } from 'common/contract'
|
||||||
import { Col } from '../layout/col'
|
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 { 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'
|
||||||
|
@ -48,13 +48,18 @@ export function AnswerResolvePanel(props: {
|
||||||
contractId: contract.id,
|
contractId: contract.id,
|
||||||
})
|
})
|
||||||
|
|
||||||
const result = await resolveMarket(resolutionProps).then((r) => r.data)
|
try {
|
||||||
|
const result = await resolveMarket(resolutionProps)
|
||||||
console.log('resolved', resolutionProps, 'result:', result)
|
console.log('resolved', resolutionProps, 'result:', result)
|
||||||
|
} catch (e) {
|
||||||
if (result?.status !== 'success') {
|
if (e instanceof APIError) {
|
||||||
setError(result?.message || 'Error resolving market')
|
setError(e.toString())
|
||||||
|
} else {
|
||||||
|
console.error(e)
|
||||||
|
setError('Error resolving market')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setResolveOption(undefined)
|
setResolveOption(undefined)
|
||||||
setIsSubmitting(false)
|
setIsSubmitting(false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { User } from 'web/lib/firebase/users'
|
||||||
import { NumberCancelSelector } from './yes-no-selector'
|
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 { resolveMarket } from 'web/lib/firebase/fn-call'
|
import { APIError, resolveMarket } from 'web/lib/firebase/api-call'
|
||||||
import { NumericContract } from 'common/contract'
|
import { NumericContract } from 'common/contract'
|
||||||
import { BucketInput } from './bucket-input'
|
import { BucketInput } from './bucket-input'
|
||||||
|
|
||||||
|
@ -37,17 +37,22 @@ export function NumericResolutionPanel(props: {
|
||||||
|
|
||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
|
|
||||||
const result = await resolveMarket({
|
try {
|
||||||
outcome: finalOutcome,
|
const result = await resolveMarket({
|
||||||
value,
|
outcome: finalOutcome,
|
||||||
contractId: contract.id,
|
value,
|
||||||
}).then((r) => r.data)
|
contractId: contract.id,
|
||||||
|
})
|
||||||
console.log('resolved', outcome, 'result:', result)
|
console.log('resolved', outcome, 'result:', result)
|
||||||
|
} catch (e) {
|
||||||
if (result?.status !== 'success') {
|
if (e instanceof APIError) {
|
||||||
setError(result?.message || 'Error resolving market')
|
setError(e.toString())
|
||||||
|
} else {
|
||||||
|
console.error(e)
|
||||||
|
setError('Error resolving market')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsSubmitting(false)
|
setIsSubmitting(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 { resolveMarket } from 'web/lib/firebase/fn-call'
|
import { APIError, resolveMarket } from 'web/lib/firebase/api-call'
|
||||||
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'
|
||||||
|
@ -42,17 +42,22 @@ export function ResolutionPanel(props: {
|
||||||
|
|
||||||
setIsSubmitting(true)
|
setIsSubmitting(true)
|
||||||
|
|
||||||
const result = await resolveMarket({
|
try {
|
||||||
outcome,
|
const result = await resolveMarket({
|
||||||
contractId: contract.id,
|
outcome,
|
||||||
probabilityInt: prob,
|
contractId: contract.id,
|
||||||
}).then((r) => r.data)
|
probabilityInt: prob,
|
||||||
|
})
|
||||||
console.log('resolved', outcome, 'result:', result)
|
console.log('resolved', outcome, 'result:', result)
|
||||||
|
} catch (e) {
|
||||||
if (result?.status !== 'success') {
|
if (e instanceof APIError) {
|
||||||
setError(result?.message || 'Error resolving market')
|
setError(e.toString())
|
||||||
|
} else {
|
||||||
|
console.error(e)
|
||||||
|
setError('Error resolving market')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsSubmitting(false)
|
setIsSubmitting(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,10 @@ export function createMarket(params: any) {
|
||||||
return call(getFunctionUrl('createmarket'), 'POST', params)
|
return call(getFunctionUrl('createmarket'), 'POST', params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resolveMarket(params: any) {
|
||||||
|
return call(getFunctionUrl('resolvemarket'), 'POST', params)
|
||||||
|
}
|
||||||
|
|
||||||
export function placeBet(params: any) {
|
export function placeBet(params: any) {
|
||||||
return call(getFunctionUrl('placebet'), 'POST', params)
|
return call(getFunctionUrl('placebet'), 'POST', params)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,17 +29,6 @@ export const createAnswer = cloudFunction<
|
||||||
}
|
}
|
||||||
>('createAnswer')
|
>('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> = () => {
|
export const createUser: () => Promise<User | null> = () => {
|
||||||
const local = safeLocalStorage()
|
const local = safeLocalStorage()
|
||||||
let deviceToken = local?.getItem('device-token')
|
let deviceToken = local?.getItem('device-token')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user