Skip to content

Commit 50c373d

Browse files
authored
Merge pull request #5 from psychemist/feat/implement-funding-operations
Feat: implement funding operations
2 parents 1c471fb + c6a0306 commit 50c373d

File tree

53 files changed

+26968
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+26968
-47
lines changed

contracts/boundless/src/datatypes.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ pub enum DataKey {
2424
Backers(String),
2525
Votes(String),
2626
Milestones(String),
27+
WhitelistedTokens(String),
28+
RefundedTokens(String),
2729
}
2830

2931
#[contracterror]
@@ -32,10 +34,15 @@ pub enum DataKey {
3234
pub enum BoundlessError {
3335
/// Contract has already been initialized
3436
AlreadyInitialized = 1,
37+
/// Invalid user authorization for action
3538
Unauthorized = 2,
39+
/// Project with the given ID already exists
3640
AlreadyExists = 3,
41+
/// Project with the given ID does not exist
3742
NotFound = 4,
43+
/// Invalid funding target amount
3844
InvalidFundingTarget = 5,
45+
/// Invalid milestone count
3946
InvalidMilestone = 6,
4047
/// Project is closed
4148
ProjectClosed = 7,
@@ -63,6 +70,12 @@ pub enum BoundlessError {
6370
InvalidOperation = 18,
6471
/// Internal error
6572
InternalError = 19,
73+
/// Token contract has already been whitelisted
74+
AlreadyWhitelisted = 20,
75+
/// Token contract has not been whitelisted
76+
InvalidTokenContract = 21,
77+
/// No backers found for the project
78+
NoBackerContributions = 22,
6679
}
6780

6881
/// Enum representing the current status of a project
@@ -182,6 +195,8 @@ pub struct BackerContribution {
182195
pub backer: Address,
183196
/// Amount contributed
184197
pub amount: u64,
198+
/// Token contract address
199+
pub token: Address,
185200
/// Timestamp of contribution
186201
pub timestamp: u64,
187202
}
@@ -201,23 +216,41 @@ pub struct Vote {
201216
#[derive(Clone)]
202217
#[contracttype]
203218
pub struct Project {
219+
/// Unique identifier for the project
204220
pub project_id: String,
221+
/// Project creator's address
205222
pub creator: Address,
223+
/// Project metadata external URI
206224
pub metadata_uri: String,
225+
/// Funding target amount
207226
pub funding_target: u64,
227+
/// Total number of milestones
208228
pub milestone_count: u32,
229+
/// Current milestone number (0-based index)
209230
pub current_milestone: u32,
231+
/// Total amount funded so far
210232
pub total_funded: u64,
211-
pub backers: Vec<(Address, u64)>,
233+
/// List of backers and their contributions
234+
pub backers: Vec<(Address, u64, Address)>,
235+
/// List of votes cast on project
212236
pub votes: Vec<(Address, i32)>,
237+
/// Flag indicating if project has been validated
213238
pub validated: bool,
239+
/// Flag indicating if project was successful
214240
pub is_successful: bool,
241+
/// Flag indicating if project has been closed
215242
pub is_closed: bool,
243+
/// Timestamp when the project was created
216244
pub created_at: u64,
245+
/// List of milestone approvals (milestone number and approval status)
217246
pub milestone_approvals: Vec<(u32, bool)>,
247+
/// List of milestone releases (milestone number and release timestamp)
218248
pub milestone_releases: Vec<(u32, u64)>,
249+
/// Flag indicating if all refunds have been processed
219250
pub refund_processed: bool,
251+
/// Timestamp when project funding period ends
220252
pub funding_deadline: u64,
253+
/// Timestamp when project voting period ends
221254
pub voting_deadline: u64,
222255
/// Current status of the project
223256
pub status: ProjectStatus,

contracts/boundless/src/interface.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
use soroban_sdk::{contract, Address, BytesN, Env, String, Vec};
1+
use soroban_sdk::{Address, BytesN, Env, String, Vec};
22

33
use crate::datatypes::{BoundlessError, Milestone, MilestoneStatus, Project, ProjectStatus};
44

5-
#[contract]
6-
pub struct BoundlessContract;
7-
85
pub trait ContractManagement {
96
fn initialize(env: Env, admin: Address) -> Result<(), BoundlessError>;
107
fn upgrade(env: Env, new_wasm_hash: BytesN<32>) -> Result<(), BoundlessError>;
@@ -103,4 +100,10 @@ pub trait FundingOperations {
103100
project_id: String,
104101
backer: Address,
105102
) -> Result<u64, BoundlessError>;
103+
fn whitelist_token_contract(
104+
env: Env,
105+
admin: Address,
106+
project_id: String,
107+
token_contract: Address,
108+
) -> Result<(), BoundlessError>;
106109
}

contracts/boundless/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22

33
use soroban_sdk::contract;
44

5-
pub use logic::*;
6-
75
mod datatypes;
86
mod interface;
97
mod logic;
10-
mod tests;
8+
9+
pub use logic::*;
1110

1211
#[contract]
1312
pub struct BoundlessContract;
1413

15-
// mod tests;
14+
mod tests;

0 commit comments

Comments
 (0)