forked from MergeFi/backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbounty.entity.ts
More file actions
106 lines (83 loc) · 2.72 KB
/
Copy pathbounty.entity.ts
File metadata and controls
106 lines (83 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
ManyToOne,
OneToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm';
import { Issue } from './issue.entity';
import { User } from './user.entity';
import { Team } from './team.entity';
import { Escrow } from './escrow.entity';
import { AssetType, BountyDifficulty, BountyStatus } from '../enums';
@Entity('bounties')
export class Bounty {
@PrimaryGeneratedColumn('uuid')
id: string;
@OneToOne(() => Issue, (issue) => issue.bounty, { onDelete: 'CASCADE' })
@JoinColumn()
issue: Issue;
@Column()
issueId: string;
@ManyToOne(() => User, { onDelete: 'SET NULL', nullable: true })
@JoinColumn()
sponsor: User | null;
@Column({ type: 'varchar', nullable: true })
sponsorId: string | null;
@ManyToOne(() => User, { onDelete: 'SET NULL', nullable: true })
@JoinColumn()
claimedBy: User | null;
@Column({ type: 'varchar', nullable: true })
claimedById: string | null;
/** Set when the bounty payout is split across a team instead of one contributor. */
@ManyToOne(() => Team, { onDelete: 'SET NULL', nullable: true })
@JoinColumn()
team: Team | null;
@Column({ type: 'varchar', nullable: true })
teamId: string | null;
@Column({ type: 'decimal', precision: 20, scale: 7 })
amount: string;
@Column({ type: 'enum', enum: AssetType, default: AssetType.USDC })
asset: AssetType;
@Column({
type: 'enum',
enum: BountyDifficulty,
default: BountyDifficulty.INTERMEDIATE,
})
difficulty: BountyDifficulty;
@Column({ type: 'enum', enum: BountyStatus, default: BountyStatus.OPEN })
status: BountyStatus;
@Column({ type: 'timestamptz', nullable: true })
deadline: Date | null;
// cascade excludes 'remove'/'soft-remove': removing a Bounty entity via the
// ORM must not also remove its Escrow — the escrow row (and the funds it
// represents) must outlive the bounty record. See #27.
@OneToOne(() => Escrow, (escrow) => escrow.bounty, {
nullable: true,
cascade: ['insert', 'update'],
})
escrow: Escrow | null;
/**
* Denormalized copy of escrow.id, set whenever `escrow` is assigned, so
* services can check funding state without an extra join/relation load.
*/
@Column({ type: 'varchar', nullable: true })
escrowId: string | null;
@Column({ type: 'varchar', nullable: true })
prUrl: string | null;
@Column({ type: 'int', nullable: true })
prNumber: number | null;
@Column({ type: 'timestamptz', nullable: true })
claimedAt: Date | null;
@Column({ type: 'timestamptz', nullable: true })
mergedAt: Date | null;
@Column({ type: 'timestamptz', nullable: true })
paidAt: Date | null;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
}