Skip to content

Commit 28ab698

Browse files
Merge pull request #90 from KevinMB0220/docs/contract-reference-issue-84
Docs/contract reference issue 84
2 parents 08f5ce0 + 9899eea commit 28ab698

4 files changed

Lines changed: 392 additions & 140 deletions

File tree

‎CONTRIBUTORS_GUIDELINE.md‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ cargo test
2929

3030
---
3131

32-
## 3. Create a New Branch
32+
## 4. Create a New Branch
3333

34-
- Create a new branch according to the guidelines in the following document: [Git Guidelines](https://github.com/Tico4Chain-Coders/Trustless-Work/blob/main/GIT_GUIDELINE.md).
34+
- Create a new branch according to the guidelines in the following document: [Git Guidelines](GIT_GUIDELINE.md).
3535
- Make sure to base the branch name on the type of change you're making (e.g., `feat/name-related-issue`, `fix/name-related-issue`).
3636

3737
```bash
@@ -40,9 +40,9 @@ git checkout -b your-branch-name
4040

4141
---
4242

43-
## 4. Make Atomic Commits
43+
## 5. Make Atomic Commits
4444

45-
- Create atomic commits following the guidelines outlined here: [Git Guidelines](https://github.com/Tico4Chain-Coders/Trustless-Work/blob/main/GIT_GUIDELINE.md).
45+
- Create atomic commits following the guidelines outlined here: [Git Guidelines](GIT_GUIDELINE.md).
4646
- Each commit should represent a small, focused change. Avoid including multiple unrelated changes in a single commit.
4747

4848
```bash
@@ -52,7 +52,7 @@ git commit -m "type: description"
5252

5353
---
5454

55-
## 5. Push Your Changes
55+
## 6. Push Your Changes
5656

5757
- Push the changes to your forked repository:
5858

@@ -62,8 +62,14 @@ git push origin your-branch-name
6262

6363
---
6464

65-
## 6. Generate a Pull Request (PR)
65+
## 7. Generate a Pull Request (PR)
6666

6767
- Create a Pull Request (PR) to the **develop** branch of the original repository.
6868
- Follow the PR template below to submit your PR.
6969
- **Important:** If you don’t use the provided PR template properly, your PR will be ignored.
70+
71+
---
72+
73+
## 8. On-Chain Contract Reference
74+
75+
Before making changes to the smart contract logic, please review the [On-Chain Contract Reference](docs/CONTRACT_REFERENCE.md) to understand the public entrypoints, storage model, roles, error codes, and events.

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center"> <img src="https://github.com/user-attachments/assets/5b182044-dceb-41f5-acf0-da22dea7c98a" alt="CLR-S (2)"> </p>
22

3-
# Trustless Work | [API Documentation](https://docs.trustlesswork.com/trustless-work)
3+
# Trustless Work | [API Documentation](https://docs.trustlesswork.com/trustless-work) | [On-Chain Contract Reference](docs/CONTRACT_REFERENCE.md)
44
It enables trustless payments via smart contracts, securing funds in escrow until milestones are approved by clients. Stablecoins like USDC are used to ensure stability and ease of use.
55

66
# Maintainers | [Telegram](https://t.me/+kmr8tGegxLU0NTA5)
@@ -48,6 +48,7 @@ It enables trustless payments via smart contracts, securing funds in escrow unti
4848

4949
## Contents
5050

51+
- [On-Chain Contract Reference](docs/CONTRACT_REFERENCE.md)
5152
- [Installing Rust](#installing-rust)
5253
- [Install the Stellar CLI](#install-stellar-cli)
5354
- [Configuring the CLI for Testnet](#configuring-the-cli-for-testnet)

‎contracts/escrow/src/error.rs‎

Lines changed: 146 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use core::fmt;
12
use soroban_sdk::contracterror;
23

34
#[derive(Debug, Copy, Clone, PartialEq)]
@@ -51,136 +52,148 @@ pub enum ContractError {
5152
MilestoneToUpdateDoesNotExist = 46,
5253
}
5354

54-
// impl fmt::Display for ContractError {
55-
// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
56-
// match self {
57-
// ContractError::AmountCannotBeZero => {
58-
// write!(f, "Amount cannot be equal to or less than zero")
59-
// }
60-
// ContractError::EscrowAlreadyInitialized => write!(f, "Escrow already initialized"),
61-
// ContractError::EscrowNotFound => write!(f, "Escrow not found"),
62-
// ContractError::OnlyReleaseSignerCanReleaseEarnings => {
63-
// write!(f, "Only the release signer can release the escrow earnings")
64-
// }
65-
// ContractError::EscrowNotCompleted => {
66-
// write!(f, "The escrow must be completed to release earnings")
67-
// }
68-
// ContractError::EscrowBalanceNotEnoughToSendEarnings => write!(
69-
// f,
70-
// "The escrow balance must be equal to the amount of earnings defined for the escrow"
71-
// ),
72-
// ContractError::OnlyPlatformAddressExecuteThisFunction => write!(
73-
// f,
74-
// "Only the platform address should be able to execute this function"
75-
// ),
76-
// ContractError::OnlyServiceProviderChangeMilstoneStatus => {
77-
// write!(f, "Only the service provider can change milestone status")
78-
// }
79-
// ContractError::NoMilestoneDefined => write!(f, "Escrow initialized without milestone"),
80-
// ContractError::InvalidMileStoneIndex => write!(f, "Invalid milestone index"),
81-
// ContractError::OnlyApproverChangeMilstoneFlag => {
82-
// write!(f, "Only the approver can change milestone flag")
83-
// }
84-
// ContractError::OnlyDisputeResolverCanExecuteThisFunction => {
85-
// write!(f, "Only the dispute resolver can execute this function")
86-
// }
87-
// ContractError::EscrowAlreadyInDispute => write!(f, "Escrow already in dispute"),
88-
// ContractError::EscrowNotInDispute => write!(f, "Escrow not in dispute"),
89-
// ContractError::InsufficientFundsForResolution => {
90-
// write!(f, "Insufficient funds for resolution")
91-
// }
92-
// ContractError::EscrowOpenedForDisputeResolution => {
93-
// write!(f, "Escrow has been opened for dispute resolution")
94-
// }
95-
// ContractError::InsufficientApproverFundsForCommissions => {
96-
// write!(f, "Insufficient approver funds for commissions")
97-
// }
98-
// ContractError::InsufficientServiceProviderFundsForCommissions => {
99-
// write!(f, "Insufficient Service Provider funds for commissions")
100-
// }
101-
// ContractError::MilestoneApprovedCantChangeEscrowProperties => {
102-
// write!(
103-
// f,
104-
// "You can't change the escrow properties after the milestone is approved"
105-
// )
106-
// }
107-
// ContractError::EscrowHasFunds => write!(f, "Escrow has funds"),
108-
// ContractError::Overflow => write!(f, "This operation can cause an Overflow"),
109-
// ContractError::Underflow => write!(f, "This operation can cause an Underflow"),
110-
// ContractError::DivisionError => write!(f, "This operation can cause Division error"),
111-
// ContractError::EscrowAlreadyResolved => write!(f, "This escrow is already resolved"),
112-
// ContractError::TooManyEscrowsRequested => {
113-
// write!(f, "You have requested too many escrows")
114-
// }
115-
// ContractError::UnauthorizedToChangeDisputeFlag => {
116-
// write!(f, "You are not authorized to change the dispute flag")
117-
// }
118-
// ContractError::TooManyMilestones => {
119-
// write!(f, "Cannot define more than 50 milestones in an escrow")
120-
// }
121-
// ContractError::ReceiverAndApproverFundsNotEqual => {
122-
// write!(
123-
// f,
124-
// "The approver's and receiver's funds must equal the current escrow balance."
125-
// )
126-
// }
127-
// ContractError::AmountsToBeTransferredShouldBePositive => {
128-
// write!(
129-
// f,
130-
// "None of the amounts to be transferred should be less or equal than 0."
131-
// )
132-
// }
133-
// ContractError::DistributionsMustEqualEscrowBalance => {
134-
// write!(f, "The sum of distributions must equal the current escrow balance when resolving an escrow dispute.")
135-
// }
136-
// ContractError::MilestoneHasAlreadyBeenApproved => {
137-
// write!(
138-
// f,
139-
// "You cannot approve a milestone that has already been approved previously"
140-
// )
141-
// }
142-
// ContractError::EmptyMilestoneStatus => {
143-
// write!(f, "The milestone status cannot be empty")
144-
// }
145-
// ContractError::PlatformFeeTooHigh => {
146-
// write!(f, "The platform fee cannot exceed 99%")
147-
// }
148-
// ContractError::FlagsMustBeFalse => {
149-
// write!(f, "All flags (approved, disputed, released) must be false in order to execute this function.")
150-
// }
151-
// ContractError::EscrowPropertiesMismatch => {
152-
// write!(
153-
// f,
154-
// "The provided escrow properties do not match the stored escrow."
155-
// )
156-
// }
157-
// ContractError::ApproverOrReceiverFundsLessThanZero => {
158-
// write!(
159-
// f,
160-
// "The funds of the approver or receiver must not be less or equal than 0."
161-
// )
162-
// }
163-
// ContractError::EscrowAlreadyReleased => {
164-
// write!(f, "The escrow funds have been released.")
165-
// }
166-
// ContractError::IncompatibleEscrowWasmHash => {
167-
// write!(
168-
// f,
169-
// "The provided contract address is not an instance of this escrow contract."
170-
// )
171-
// }
172-
// ContractError::PlatformAddressCannotBeChanged => {
173-
// write!(f, "The platform address of the escrow cannot be changed.")
174-
// }
175-
// ContractError::DisputeResolverCannotDisputeTheEscrow => {
176-
// write!(f, "The dispute resolver cannot dispute the escrow.")
177-
// }
178-
// ContractError::TotalAmountCannotBeZero => {
179-
// write!(f, "The total amount to be distributed cannot be equal to zero.")
180-
// }
181-
// ContractError::InsufficientFundsForEscrowFunding => {
182-
// write!(f, "The signer has insufficient funds to fund the escrow.")
183-
// }
184-
// }
185-
// }
186-
// }
55+
impl fmt::Display for ContractError {
56+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
57+
match self {
58+
ContractError::AmountCannotBeZero => {
59+
write!(f, "Amount cannot be equal to or less than zero")
60+
}
61+
ContractError::EscrowAlreadyInitialized => write!(f, "Escrow already initialized"),
62+
ContractError::EscrowNotFound => write!(f, "Escrow not found"),
63+
ContractError::OnlyReleaseSignerCanReleaseEarnings => {
64+
write!(f, "Only the release signer can release the escrow earnings")
65+
}
66+
ContractError::EscrowNotCompleted => {
67+
write!(f, "The escrow must be completed to release earnings")
68+
}
69+
ContractError::EscrowBalanceNotEnoughToSendEarnings => write!(
70+
f,
71+
"The escrow balance must be equal to the amount of earnings defined for the escrow"
72+
),
73+
ContractError::OnlyPlatformAddressExecuteThisFunction => write!(
74+
f,
75+
"Only the platform address should be able to execute this function"
76+
),
77+
ContractError::OnlyServiceProviderChangeMilstoneStatus => {
78+
write!(f, "Only the service provider can change milestone status")
79+
}
80+
ContractError::NoMilestoneDefined => write!(f, "Escrow initialized without milestone"),
81+
ContractError::InvalidMileStoneIndex => write!(f, "Invalid milestone index"),
82+
ContractError::OnlyApproverChangeMilstoneFlag => {
83+
write!(f, "Only the approver can change milestone flag")
84+
}
85+
ContractError::OnlyDisputeResolverCanExecuteThisFunction => {
86+
write!(f, "Only the dispute resolver can execute this function")
87+
}
88+
ContractError::EscrowAlreadyInDispute => write!(f, "Escrow already in dispute"),
89+
ContractError::EscrowNotInDispute => write!(f, "Escrow not in dispute"),
90+
ContractError::InsufficientFundsForResolution => {
91+
write!(f, "Insufficient funds for resolution")
92+
}
93+
ContractError::EscrowOpenedForDisputeResolution => {
94+
write!(f, "Escrow has been opened for dispute resolution")
95+
}
96+
ContractError::InsufficientApproverFundsForCommissions => {
97+
write!(f, "Insufficient approver funds for commissions")
98+
}
99+
ContractError::InsufficientServiceProviderFundsForCommissions => {
100+
write!(f, "Insufficient Service Provider funds for commissions")
101+
}
102+
ContractError::MilestoneApprovedCantChangeEscrowProperties => {
103+
write!(
104+
f,
105+
"You can't change the escrow properties after the milestone is approved"
106+
)
107+
}
108+
ContractError::EscrowHasFunds => write!(f, "Escrow has funds"),
109+
ContractError::Overflow => write!(f, "This operation can cause an Overflow"),
110+
ContractError::Underflow => write!(f, "This operation can cause an Underflow"),
111+
ContractError::DivisionError => write!(f, "This operation can cause Division error"),
112+
ContractError::EscrowAlreadyResolved => write!(f, "This escrow is already resolved"),
113+
ContractError::TooManyEscrowsRequested => {
114+
write!(f, "You have requested too many escrows")
115+
}
116+
ContractError::UnauthorizedToChangeDisputeFlag => {
117+
write!(f, "You are not authorized to change the dispute flag")
118+
}
119+
ContractError::TooManyMilestones => {
120+
write!(f, "Cannot define more than 50 milestones in an escrow")
121+
}
122+
ContractError::ReceiverAndApproverFundsNotEqual => {
123+
write!(
124+
f,
125+
"The approver's and receiver's funds must equal the current escrow balance."
126+
)
127+
}
128+
ContractError::AmountsToBeTransferredShouldBePositive => {
129+
write!(
130+
f,
131+
"None of the amounts to be transferred should be less or equal than 0."
132+
)
133+
}
134+
ContractError::DistributionsMustEqualEscrowBalance => {
135+
write!(f, "The sum of distributions must equal the current escrow balance when resolving an escrow dispute.")
136+
}
137+
ContractError::MilestoneHasAlreadyBeenApproved => {
138+
write!(
139+
f,
140+
"You cannot approve a milestone that has already been approved previously"
141+
)
142+
}
143+
ContractError::EmptyMilestoneStatus => {
144+
write!(f, "The milestone status cannot be empty")
145+
}
146+
ContractError::PlatformFeeTooHigh => {
147+
write!(f, "The platform fee cannot exceed 99%")
148+
}
149+
ContractError::FlagsMustBeFalse => {
150+
write!(f, "All flags (approved, disputed, released) must be false in order to execute this function.")
151+
}
152+
ContractError::EscrowPropertiesMismatch => {
153+
write!(
154+
f,
155+
"The provided escrow properties do not match the stored escrow."
156+
)
157+
}
158+
ContractError::ApproverOrReceiverFundsLessThanZero => {
159+
write!(
160+
f,
161+
"The funds of the approver or receiver must not be less or equal than 0."
162+
)
163+
}
164+
ContractError::EscrowAlreadyReleased => {
165+
write!(f, "The escrow funds have been released.")
166+
}
167+
ContractError::IncompatibleEscrowWasmHash => {
168+
write!(
169+
f,
170+
"The provided contract address is not an instance of this escrow contract."
171+
)
172+
}
173+
ContractError::PlatformAddressCannotBeChanged => {
174+
write!(f, "The platform address of the escrow cannot be changed.")
175+
}
176+
ContractError::DisputeResolverCannotDisputeTheEscrow => {
177+
write!(f, "The dispute resolver cannot dispute the escrow.")
178+
}
179+
ContractError::TotalAmountCannotBeZero => {
180+
write!(f, "The total amount to be distributed cannot be equal to zero.")
181+
}
182+
ContractError::InsufficientFundsForEscrowFunding => {
183+
write!(f, "The signer has insufficient funds to fund the escrow.")
184+
}
185+
ContractError::MilestoneToApproveDoesNotExist => {
186+
write!(f, "The milestone to approve does not exist")
187+
}
188+
ContractError::EscrowNotFullyProcessed => {
189+
write!(f, "The escrow must be fully processed before withdrawing remaining funds")
190+
}
191+
ContractError::TooManyDistributions => {
192+
write!(f, "Cannot define more than 50 distributions when resolving dispute")
193+
}
194+
ContractError::MilestoneToUpdateDoesNotExist => {
195+
write!(f, "The milestone to update does not exist")
196+
}
197+
}
198+
}
199+
}

0 commit comments

Comments
 (0)