forked from CalloraOrg/Callora-Contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_settlement.py
More file actions
37 lines (29 loc) · 958 Bytes
/
Copy pathfix_settlement.py
File metadata and controls
37 lines (29 loc) · 958 Bytes
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
import re
with open('contracts/settlement/src/lib.rs', 'r') as f:
content = f.read()
# Fix init
content = content.replace(
'pub fn init(env: Env, vault: Address) {',
'pub fn init(env: Env, admin: Address, vault: Address) {\n env.storage().instance().set(&StorageKey::Admin, &admin);'
)
# Add migrate functions to the end of contractimpl
migrate_funcs = """
pub fn migrate_v1_to_v2(env: Env, caller: Address) {
migrate::migrate_v1_to_v2(&env, &caller);
}
pub fn migrate_v1_to_v2_page(
env: Env,
caller: Address,
offset: u32,
limit: u32,
) -> (u32, bool) {
migrate::migrate_v1_to_v2_page(&env, &caller, offset, limit)
}
pub fn migration_storage_version(env: Env) -> u32 {
migrate::migration_storage_version(&env)
}
}
"""
content = re.sub(r'}\s*$', migrate_funcs, content)
with open('contracts/settlement/src/lib.rs', 'w') as f:
f.write(content)