forked from Cylo-Traders/Agrocylo-PIP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib.rs
More file actions
119 lines (98 loc) · 3.1 KB
/
Copy pathlib.rs
File metadata and controls
119 lines (98 loc) · 3.1 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
#![no_std]
mod activity;
mod admin;
mod campaign;
mod events;
mod farmer;
mod storage;
mod types;
pub use types::*;
use soroban_sdk::{contract, contractimpl, Address, Env, String, Symbol, Vec};
#[contract]
pub struct RegistryContract;
#[contractimpl]
impl RegistryContract {
pub fn initialize(env: Env, admin: Address) {
admin::initialize(&env, &admin);
}
pub fn update_admin(env: Env, new_admin: Address) {
admin::update_admin(&env, &new_admin);
}
pub fn get_admin(env: Env) -> Address {
admin::get_admin(&env)
}
pub fn approve_contract(env: Env, contract: Address) {
admin::approve_contract(&env, &contract);
}
pub fn revoke_contract(env: Env, contract: Address) {
admin::revoke_contract(&env, &contract);
}
pub fn is_contract_approved(env: Env, contract: Address) -> bool {
admin::is_contract_approved(&env, &contract)
}
pub fn register_farmer(env: Env, farmer: Address, name: String, location: String) {
farmer::register_farmer(&env, farmer, name, location);
}
pub fn get_farmer(env: Env, farmer: Address) -> Option<FarmerProfile> {
farmer::get_farmer(&env, &farmer)
}
pub fn register_campaign(
env: Env,
campaign_id: u64,
farmer: Address,
title: String,
description: String,
) {
campaign::register_campaign(&env, campaign_id, farmer, title, description);
}
pub fn get_campaign(env: Env, campaign_id: u64) -> Option<CampaignInfo> {
campaign::get_campaign(&env, campaign_id)
}
pub fn record_activity(
env: Env,
campaign_id: u64,
actor: Address,
action_type: ActivityAction,
) {
activity::record_activity(&env, campaign_id, &actor, action_type);
}
pub fn get_campaign_activities(env: Env, campaign_id: u64) -> Vec<ActivityRecord> {
activity::get_campaign_activities(&env, campaign_id)
}
/// Links a campaign to its ProductionEscrowContract instance and crop/region
/// metadata, and begins tracking its lifecycle status. Distinct from
/// `register_campaign`, which stores the farmer-authored title/description.
pub fn link_campaign_escrow(
env: Env,
campaign_id: u64,
farmer: Address,
escrow_contract: Address,
crop_metadata: Symbol,
region_metadata: Symbol,
) {
campaign::link_campaign_escrow(
&env,
campaign_id,
&farmer,
&escrow_contract,
crop_metadata,
region_metadata,
);
}
pub fn update_campaign_status(
env: Env,
campaign_id: u64,
caller: Address,
new_status: CampaignStatus,
) {
campaign::update_campaign_status(&env, campaign_id, &caller, new_status);
}
pub fn get_campaign_record(env: Env, campaign_id: u64) -> CampaignRecord {
campaign::get_campaign_record(&env, campaign_id)
}
pub fn get_campaigns_by_farmer(env: Env, farmer: Address) -> Vec<u64> {
campaign::get_campaigns_by_farmer(&env, &farmer)
}
}
#[cfg(test)]
mod test;