-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathevents.rs
More file actions
120 lines (111 loc) · 3.04 KB
/
Copy pathevents.rs
File metadata and controls
120 lines (111 loc) · 3.04 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use crate::types::{ApiCredential, ApiCredentialRotation, Task};
use crate::types::Task;
use soroban_sdk::{symbol_short, Address, Env, String, Symbol};
/// Emit TaskCreated event
pub fn emit_task_created(env: &Env, task: &Task) {
env.events().publish(
(symbol_short!("task"), symbol_short!("created")),
(
task.id,
task.poster.clone(),
task.title.clone(),
task.reward,
task.deadline,
),
);
}
/// Emit WorkSubmitted event
pub fn emit_work_submitted(
env: &Env,
task_id: u64,
submission_id: u64,
contributor: &Address,
work_url: &String,
) {
env.events().publish(
(symbol_short!("work"), symbol_short!("submit")),
(
task_id,
submission_id,
contributor.clone(),
work_url.clone(),
),
);
}
/// Emit SubmissionApproved event
pub fn emit_submission_approved(
env: &Env,
task_id: u64,
submission_id: u64,
contributor: &Address,
reward: i128,
) {
env.events().publish(
(symbol_short!("sub"), symbol_short!("approved")),
(task_id, submission_id, contributor.clone(), reward),
);
}
/// Emit SubmissionRejected event
pub fn emit_submission_rejected(
env: &Env,
task_id: u64,
submission_id: u64,
contributor: &Address,
) {
env.events().publish(
(symbol_short!("sub"), symbol_short!("rejected")),
(task_id, submission_id, contributor.clone()),
);
}
/// Emit TaskCancelled event
pub fn emit_task_cancelled(env: &Env, task_id: u64, poster: &Address) {
env.events().publish(
(symbol_short!("task"), symbol_short!("cancel")),
(task_id, poster.clone()),
);
}
/// Emit DisputeRaised event
pub fn emit_dispute_raised(
env: &Env,
task_id: u64,
submission_id: u64,
raiser: &Address,
reason: &String,
) {
env.events().publish(
(symbol_short!("dispute"), symbol_short!("raised")),
(task_id, submission_id, raiser.clone(), reason.clone()),
);
}
/// Emit ApiKeyRegistered event
pub fn emit_api_key_registered(env: &Env, credential: &ApiCredential) {
env.events().publish(
(symbol_short!("api"), symbol_short!("register")),
(
credential.organization.clone(),
credential.id,
credential.label.clone(),
credential.fingerprint.clone(),
),
);
}
/// Emit ApiKeyRotated event
pub fn emit_api_key_rotated(env: &Env, rotation: &ApiCredentialRotation) {
env.events().publish(
(symbol_short!("api"), symbol_short!("rotate")),
(
rotation.organization.clone(),
rotation.old_credential_id,
rotation.new_credential_id,
rotation.actor.clone(),
rotation.reason.clone(),
),
);
}
/// Emit ApiKeyRevoked event
pub fn emit_api_key_revoked(env: &Env, organization: &Address, credential_id: u64) {
env.events().publish(
(symbol_short!("api"), symbol_short!("revoke")),
(organization.clone(), credential_id),
);
}