2022-04-29 23:35:56 +00:00
|
|
|
// A txn (pronounced "texan") respresents a payment between two ids on Manifold
|
|
|
|
// Shortened from "transaction" to distinguish from Firebase transactions (and save chars)
|
2022-07-05 17:29:26 +00:00
|
|
|
type AnyTxnType = Donation | Tip | Manalink | Referral | Bonus
|
2022-06-22 08:13:25 +00:00
|
|
|
type SourceType = 'USER' | 'CONTRACT' | 'CHARITY' | 'BANK'
|
|
|
|
|
|
|
|
export type Txn<T extends AnyTxnType = AnyTxnType> = {
|
2022-04-29 23:35:56 +00:00
|
|
|
id: string
|
|
|
|
createdTime: number
|
|
|
|
|
|
|
|
fromId: string
|
|
|
|
fromType: SourceType
|
|
|
|
|
|
|
|
toId: string
|
|
|
|
toType: SourceType
|
|
|
|
|
|
|
|
amount: number
|
|
|
|
token: 'M$' // | 'USD' | MarketOutcome
|
|
|
|
|
2022-08-19 17:10:32 +00:00
|
|
|
category:
|
|
|
|
| 'CHARITY'
|
|
|
|
| 'MANALINK'
|
|
|
|
| 'TIP'
|
|
|
|
| 'REFERRAL'
|
|
|
|
| 'UNIQUE_BETTOR_BONUS'
|
|
|
|
| 'BETTING_STREAK_BONUS'
|
2022-07-05 17:29:26 +00:00
|
|
|
|
2022-06-18 03:28:16 +00:00
|
|
|
// Any extra data
|
|
|
|
data?: { [key: string]: any }
|
2022-06-22 08:13:25 +00:00
|
|
|
|
2022-04-29 23:35:56 +00:00
|
|
|
// Human-readable description
|
|
|
|
description?: string
|
2022-06-22 08:13:25 +00:00
|
|
|
} & T
|
2022-04-29 23:35:56 +00:00
|
|
|
|
2022-06-22 08:13:25 +00:00
|
|
|
type Donation = {
|
2022-06-18 03:28:16 +00:00
|
|
|
fromType: 'USER'
|
|
|
|
toType: 'CHARITY'
|
|
|
|
category: 'CHARITY'
|
|
|
|
}
|
|
|
|
|
2022-06-22 08:13:25 +00:00
|
|
|
type Tip = {
|
2022-06-18 03:28:16 +00:00
|
|
|
fromType: 'USER'
|
|
|
|
toType: 'USER'
|
|
|
|
category: 'TIP'
|
|
|
|
data: {
|
|
|
|
commentId: string
|
2022-07-07 23:23:13 +00:00
|
|
|
contractId?: string
|
|
|
|
groupId?: string
|
2022-06-18 03:28:16 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-22 08:13:25 +00:00
|
|
|
|
2022-06-23 08:07:52 +00:00
|
|
|
type Manalink = {
|
|
|
|
fromType: 'USER'
|
|
|
|
toType: 'USER'
|
|
|
|
category: 'MANALINK'
|
|
|
|
}
|
|
|
|
|
2022-07-01 13:47:19 +00:00
|
|
|
type Referral = {
|
|
|
|
fromType: 'BANK'
|
|
|
|
toType: 'USER'
|
|
|
|
category: 'REFERRAL'
|
|
|
|
}
|
|
|
|
|
2022-07-05 17:29:26 +00:00
|
|
|
type Bonus = {
|
|
|
|
fromType: 'BANK'
|
|
|
|
toType: 'USER'
|
2022-08-19 17:10:32 +00:00
|
|
|
category: 'UNIQUE_BETTOR_BONUS' | 'BETTING_STREAK_BONUS'
|
2022-07-05 17:29:26 +00:00
|
|
|
}
|
|
|
|
|
2022-06-22 08:13:25 +00:00
|
|
|
export type DonationTxn = Txn & Donation
|
|
|
|
export type TipTxn = Txn & Tip
|
2022-06-23 08:07:52 +00:00
|
|
|
export type ManalinkTxn = Txn & Manalink
|
2022-07-01 13:47:19 +00:00
|
|
|
export type ReferralTxn = Txn & Referral
|