Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ change, not backfilled later.

## [Unreleased]

### Changed
- **ABI change**: Removed unused `Unauthorized` error variant (code 3) from
`milestones` and `maintenance-pool` contracts. These variants were declared
but never constructed — authorization failures use Soroban's
`require_auth()` host trap instead of returning an error. All subsequent
error codes have been renumbered downward by 1. Also fixed duplicate
error code 21 in `milestones` (`DeadlinePassed` and `DeadlineInPast` both
used 21; now `DeadlinePassed` = 21, `DeadlineInPast` = 22). The `escrow`
contract's `Unauthorized` variant remains (used in `extend_deadline`).
Update client-side error decoders (`scripts/error-codes.mjs`) accordingly.
(#319)

### Added
- `CODEOWNERS`, pinning `contracts/`, `docs/` and `scripts/` review to the
maintainer for automatic reviewer assignment on the high volume of
Expand Down
27 changes: 13 additions & 14 deletions contracts/maintenance-pool/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,28 @@ use soroban_sdk::contracterror;
pub enum Error {
AlreadyInitialized = 1,
NotInitialized = 2,
Unauthorized = 3,
PoolNotFound = 4,
TokenMismatch = 5,
InvalidAmount = 6,
InsufficientBalance = 7,
InvalidFee = 8,
PoolNotFound = 3,
TokenMismatch = 4,
InvalidAmount = 5,
InsufficientBalance = 6,
InvalidFee = 7,
/// Treasury cannot be set to the contract's own address (issue #39).
InvalidTreasury = 9,
InvalidTreasury = 8,
/// The deposit's inactivity window has not yet elapsed (issue #42).
InactivityWindowNotElapsed = 10,
InactivityWindowNotElapsed = 9,
/// The caller is not the deposit's original sponsor (issue #42).
NotDepositSponsor = 11,
NotDepositSponsor = 10,
/// The deposit index is out of range (issue #42).
DepositNotFound = 12,
DepositNotFound = 11,
/// Contract is paused and this operation is not allowed (issue #14).
ContractPaused = 13,
ContractPaused = 12,
/// The deposit count has reached its maximum limit (issue #45).
DepositCountOverflow = 14,
DepositCountOverflow = 13,
/// The pool already holds `MAX_DEPOSITS` deposits (issue #94).
TooManyDeposits = 15,
TooManyDeposits = 14,
/// The deposit has already been reclaimed; a second reclaim is rejected
/// to prevent the same index from draining other sponsors' funds (#479).
AlreadyReclaimed = 17,
AlreadyReclaimed = 15,
/// Checked i128 arithmetic overflowed (e.g. `balance` / monotonic
/// `total_deposited` near `i128::MAX`). Returned instead of panicking
/// under release `overflow-checks = true` + `panic = "abort"`.
Expand Down
39 changes: 19 additions & 20 deletions contracts/milestones/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,39 @@ use soroban_sdk::contracterror;
pub enum Error {
AlreadyInitialized = 1,
NotInitialized = 2,
Unauthorized = 3,
MilestoneNotFound = 4,
IssueAlreadyAllocated = 5,
IssueNotAllocated = 6,
IssueAlreadyReleased = 7,
OverAllocation = 8,
InvalidSplit = 9,
InvalidAmount = 10,
InvalidFee = 11,
MilestoneClosed = 12,
TooManySponsors = 13,
MilestoneNotFound = 3,
IssueAlreadyAllocated = 4,
IssueNotAllocated = 5,
IssueAlreadyReleased = 6,
OverAllocation = 7,
InvalidSplit = 8,
InvalidAmount = 9,
InvalidFee = 10,
MilestoneClosed = 11,
TooManySponsors = 12,
/// Treasury cannot be set to the contract's own address (issue #39).
InvalidTreasury = 14,
InvalidTreasury = 13,
/// A milestone with this id already exists and is not in a terminal state (issue #41).
MilestoneAlreadyExists = 15,
MilestoneAlreadyExists = 14,
/// The milestone's deadline has not yet passed (issue #42).
DeadlineNotPassed = 16,
DeadlineNotPassed = 15,
/// The issue is not allocated, so it cannot be deallocated (issue #43).
IssueNotAllocatedForDeallocate = 17,
IssueNotAllocatedForDeallocate = 16,
/// Contract is paused and this operation is not allowed (issue #14).
ContractPaused = 18,
ContractPaused = 17,
/// The contribution index is out of range for an existing milestone (issue #256).
ContributionNotFound = 19,
ContributionNotFound = 18,
/// A recipient address equals the contract's own address — a self-payout
/// that would strand funds in the contract with no recovery path.
SelfPayout = 20,
SelfPayout = 19,
/// Checked i128 arithmetic overflowed (e.g. budget total near
/// `i128::MAX`). Returned instead of panicking under release
/// `overflow-checks = true` + `panic = "abort"`.
ArithmeticOverflow = 21,
ArithmeticOverflow = 20,
/// `allocate` was called on a milestone whose deadline has already passed
/// (#489). Once past the deadline, sponsors may cancel; allowing further
/// allocations would let the admin pre-empt that cancel.
DeadlinePassed = 22,
DeadlinePassed = 21,
/// The deadline supplied to `create_milestone` is in the past (issue #491).
DeadlineInPast = 22,
/// The stored contract version does not match the requested migration source.
Expand Down
70 changes: 38 additions & 32 deletions scripts/error-codes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,45 +32,51 @@ export const errorMappings = {
milestones: {
1: "AlreadyInitialized",
2: "NotInitialized",
3: "Unauthorized",
4: "MilestoneNotFound",
5: "IssueAlreadyAllocated",
6: "IssueNotAllocated",
7: "IssueAlreadyReleased",
8: "OverAllocation",
9: "InvalidSplit",
10: "InvalidAmount",
11: "InvalidFee",
12: "MilestoneClosed",
13: "TooManySponsors",
14: "InvalidTreasury",
15: "MilestoneAlreadyExists",
16: "DeadlineNotPassed",
17: "IssueNotAllocatedForDeallocate",
18: "ContractPaused",
19: "ContributionNotFound",
20: "SelfPayout",
3: "MilestoneNotFound",
4: "IssueAlreadyAllocated",
5: "IssueNotAllocated",
6: "IssueAlreadyReleased",
7: "OverAllocation",
8: "InvalidSplit",
9: "InvalidAmount",
10: "InvalidFee",
11: "MilestoneClosed",
12: "TooManySponsors",
13: "InvalidTreasury",
14: "MilestoneAlreadyExists",
15: "DeadlineNotPassed",
16: "IssueNotAllocatedForDeallocate",
17: "ContractPaused",
18: "ContributionNotFound",
19: "SelfPayout",
20: "ArithmeticOverflow",
21: "DeadlinePassed",
22: "DeadlineInPast",
23: "InvalidVersion",
24: "InvalidMaxSponsors"
},

// Maintenance-pool contract errors
maintenancePool: {
1: "AlreadyInitialized",
2: "NotInitialized",
3: "Unauthorized",
4: "PoolNotFound",
5: "TokenMismatch",
6: "InvalidAmount",
7: "InsufficientBalance",
8: "InvalidFee",
9: "InvalidTreasury",
10: "InactivityWindowNotElapsed",
11: "NotDepositSponsor",
12: "DepositNotFound",
13: "ContractPaused",
14: "DepositCountOverflow",
15: "TooManyDeposits",
16: "ArithmeticOverflow"
3: "PoolNotFound",
4: "TokenMismatch",
5: "InvalidAmount",
6: "InsufficientBalance",
7: "InvalidFee",
8: "InvalidTreasury",
9: "InactivityWindowNotElapsed",
10: "NotDepositSponsor",
11: "DepositNotFound",
12: "ContractPaused",
13: "DepositCountOverflow",
14: "TooManyDeposits",
15: "AlreadyReclaimed",
16: "ArithmeticOverflow",
17: "InvalidSplit",
18: "SelfPayout",
19: "InvalidVersion"
}
};

Expand Down
Loading