2021-12-24 21:06:01 +00:00
|
|
|
import { getFunctions, httpsCallable } from 'firebase/functions'
|
2022-01-18 07:18:38 +00:00
|
|
|
import { User } from '../../../common/user'
|
2021-12-24 21:06:01 +00:00
|
|
|
|
|
|
|
const functions = getFunctions()
|
|
|
|
|
|
|
|
export const cloudFunction = (name: string) => httpsCallable(functions, name)
|
|
|
|
|
2022-01-05 18:23:58 +00:00
|
|
|
export const createContract = cloudFunction('createContract')
|
|
|
|
|
|
|
|
export const placeBet = cloudFunction('placeBet')
|
|
|
|
|
|
|
|
export const resolveMarket = cloudFunction('resolveMarket')
|
|
|
|
|
|
|
|
export const sellBet = cloudFunction('sellBet')
|
2022-01-18 07:18:38 +00:00
|
|
|
|
|
|
|
export const createUser: () => Promise<User | null> = () =>
|
|
|
|
cloudFunction('createUser')({})
|
|
|
|
.then((r) => (r.data as any)?.user || null)
|
|
|
|
.catch(() => null)
|