-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathpatch2.py
More file actions
41 lines (31 loc) · 1.21 KB
/
Copy pathpatch2.py
File metadata and controls
41 lines (31 loc) · 1.21 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
import os
lib_path = 'contracts/accountability_vault/src/lib.rs'
with open(lib_path, 'w') as f:
f.write('''#![no_std]
use soroban_sdk::{contract, contractimpl, contracttype, Address, Env, Symbol};
#[contracttype]
pub struct Milestone {
pub verified: bool,
pub verified_at: u64,
}
#[contract]
pub struct AccountabilityVault;
#[contractimpl]
impl AccountabilityVault {
pub fn dispute_milestone(env: Env, creator: Address, index: u32, dispute_window: u64) {
creator.require_auth();
// Mocking the stored milestone retrieval for this patch
let mut milestone = Milestone { verified: true, verified_at: env.ledger().timestamp() };
assert!(milestone.verified, "Milestone must be verified to dispute");
let current_time = env.ledger().timestamp();
assert!(
current_time <= milestone.verified_at + dispute_window,
"Dispute window has passed"
);
milestone.verified = false;
let event_name = Symbol::new(&env, "milestone_disputed");
env.events().publish((event_name, creator), index);
}
}
''')
print('Patch 2 applied: Added dispute window validation and corrected event name.')