-
Notifications
You must be signed in to change notification settings - Fork 0
/
diagram.plantuml
62 lines (55 loc) · 1.74 KB
/
diagram.plantuml
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
@startuml project-funding
Title: Project Funding via Smart Contract
Participant "Admin" as A
Participant "SmartContract" as SC
Participant "Investor" as I
A -> SC: createProject(projectId, fundingGoal)
activate SC
SC -> SC: Project(id, fundingGoal, currentAmount, owner, isClosed)
SC --> A: Event: ProjectCreated
deactivate SC
I -> SC: contribute(projectId)
activate SC
SC -> SC: check(!isClosed)
SC -> SC: check(contribution <= fundingGoal - currentAmount)
alt contribution <= fundingGoal - currentAmount
SC -> SC: currentAmount += contribution
SC --> I: Event: ContributionMade
alt currentAmount == fundingGoal
SC -> SC: closeProject(projectId)
SC --> I: Event: FullyFunded
end
else
SC --> I: Error: "Contribution exceeds funding goal"
end
deactivate SC
I -> SC: getProjectTotalAmount(projectId)
activate SC
SC --> I: return currentAmount
deactivate SC
A -> SC: setFundingGoal(projectId, newFundingGoal)
activate SC
SC -> SC: check(newFundingGoal >= currentAmount)
alt newFundingGoal >= currentAmount
SC -> SC: fundingGoal = newFundingGoal
SC --> A: Event: FundingGoalUpdated
else
SC --> A: Error: "New funding goal cannot be less than the amount already raised"
end
deactivate SC
A -> SC: closeProject(projectId)
activate SC
SC -> SC: check(!isClosed)
SC -> SC: isClosed = true
SC --> A: Event: Closed
deactivate SC
A -> SC: withdrawFunds(projectId)
activate SC
SC -> SC: check(currentAmount >= fundingGoal)
SC -> SC: check(currentAmount <= SC.balance)
SC -> SC: isClosed = true
SC -> SC: owner.transfer(currentAmount)
SC -> SC: currentAmount = 0
SC --> A: Event: FundsWithdrawn
deactivate SC
@enduml