Skip to content
Open
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
557 changes: 493 additions & 64 deletions contracts/Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ members = [
"species-voting",
"treasury",
"platform-governance",
"nft-certificate",
"subscription-sponsorship",
"planter-registry",
]
Expand Down
136 changes: 101 additions & 35 deletions contracts/harvesta-errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
//! Import the crate, then call `panic_with_error!(env, HarvestaError::Variant)`
//! instead of raw string panics. Error codes are stable u32 values embedded in
//! the Stellar XDR so off-chain tooling can parse them without string matching.
//!
//! NOTE: Error count reduced to stay within Soroban SDK limits.
//! Only essential errors for current contracts are included.

use soroban_sdk::contracterror;

#[contracterror]
// Export is disabled because the consolidated error enum exceeds the Soroban
// XDR spec limit of 50 cases for `contracterror` types. The enum still
// implements all traits required by `panic_with_error!`, so contracts can
// continue to use it; it simply won't be embedded in the contract spec XDR.
#[contracterror(export = false)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[repr(u32)]
pub enum HarvestaError {
Expand All @@ -35,50 +36,115 @@ pub enum HarvestaError {
SlotAmountMustBePositive = 15,

// ── Escrow state (16–25) ──────────────────────────────────────────────────
// EscrowAlreadyExists = 16,
// EscrowNotFound = 17,
// PlantingAlreadyVerified = 18,
// PlantingNotVerified = 19,
// RefundAfterPlanting = 20,
// SurvivalThresholdOutOfRange = 21,
// SurvivalRateOutOfRange = 22,
// SurvivalRateBelowMinimum = 23,
// SurvivalPeriodNotElapsed = 24,
// NothingToRelease = 25,
EscrowAlreadyExists = 16,
EscrowNotFound = 17,
PlantingAlreadyVerified = 18,
PlantingNotVerified = 19,
RefundAfterPlanting = 20,
SurvivalThresholdOutOfRange = 21,
SurvivalRateOutOfRange = 22,
SurvivalRateBelowMinimum = 23,
SurvivalPeriodNotElapsed = 24,
NothingToRelease = 25,

// ── Oracle / tree co-fund (26–34) ─────────────────────────────────────────
// UnauthorizedOracle = 26,
// NoOracleReport = 27,
// BatchEmpty = 28,
// BatchTooLarge = 29,
// TreeAlreadyRegistered = 30,
// TreeNotRegistered = 31,
// TreeNotOpenForContributions = 32,
// TreeNotOpenForRelease = 33,
// NoFundsToRelease = 34,
UnauthorizedOracle = 26,
NoOracleReport = 27,
BatchEmpty = 28,
BatchTooLarge = 29,
TreeAlreadyRegistered = 30,
TreeNotRegistered = 31,
TreeNotOpenForContributions = 32,
TreeNotOpenForRelease = 33,
NoFundsToRelease = 34,

// ── Farmer registry (35–37) ───────────────────────────────────────────────
// FarmerAlreadyRegistered = 35,
// FarmerNotRegistered = 36,
// InvalidRegion = 37,
FarmerAlreadyRegistered = 35,
FarmerNotRegistered = 36,
InvalidRegion = 37,

// ── Dispute / arbiter (38–46) ─────────────────────────────────────────────
// DisputeAlreadyOpen = 38,
// NoOpenDispute = 39,
// EscrowAlreadyFinalised = 40,
// NotArbiter = 41,
// NotBuyerOrSeller = 42,
// MilestoneReleaseBlocked = 43,
// MilestoneAlreadyProcessed = 44,
// CompletionPercentageOutOfRange = 45,
// TotalReleasedExceedsMilestone = 46,
DisputeAlreadyOpen = 38,
NoOpenDispute = 39,
EscrowAlreadyFinalised = 40,
NotArbiter = 41,
NotBuyerOrSeller = 42,
MilestoneReleaseBlocked = 43,
MilestoneAlreadyProcessed = 44,
CompletionPercentageOutOfRange = 45,
TotalReleasedExceedsMilestone = 46,

// ── Naira payout (47–54) ──────────────────────────────────────────────────
PendingPayoutAlreadyExists = 47,
PayoutIntervalTooShort = 48,
MaxDailyPayoutExceeded = 49,
PayoutNotPending = 50,
CanOnlyCancelPending = 51,
PayoutNotFound = 52,
ExpectedNgnMustBePositive = 53,
UnsupportedToken = 54,

// ── Aggregate impact verifier (55–59) ─────────────────────────────────────
FarmCountMustBePositive = 55,
PeriodEndBeforeStart = 56,
ProofDigestAlreadyRegistered = 57,
ProofNotFound = 58,
ProofAlreadyRevoked = 59,

// ── Nullifier registry (60) ───────────────────────────────────────────────
CommitmentAlreadyRegistered = 60,

// ── KYC attestation (61) ──────────────────────────────────────────────────
NotVerifier = 61,

// ── Species registry (62–64) ──────────────────────────────────────────────
Co2MustBePositive = 62,
MaturityYearsMustBePositive = 63,
SpeciesNotFound = 64,

// ── Location / ZK proofs (65–70) ──────────────────────────────────────────
OutsideNigeriaRegion = 65,
ProofCommitmentAlreadyRegistered = 66,
CommitmentAlreadySubmitted = 67,
CommitmentNotFound = 68,
CommitmentNotPending = 69,
InvalidProof = 70,

// ── Donation escrow (71–79) ───────────────────────────────────────────────
AlreadyProcessed = 71,
NotDonor = 72,
DonationAlreadyCancelled = 73,
DonationCancelled = 74,
IntervalNotElapsed = 75,
ProjectNotRegistered = 76,
AmountPerIntervalMustBePositive = 77,
IntervalSecondsMustBePositive = 78,
RecurringDonationNotFound = 79,

// ── Arithmetic overflows (80–81) ──────────────────────────────────────────
TreeTokenMintOverflow = 80,
TokenUnitOverflow = 81,

// ── NFT certificate (90–93) ───────────────────────────────────────────────
TokenAlreadyMinted = 90,
InvalidPlantingDate = 91,
TokenNotFound = 92,
NotTokenOwner = 93,

// ── Verifier staking (94–97) ──────────────────────────────────────────────
// NOTE: renumbered from the original 91–95 range to avoid collision with
// the NFT certificate errors introduced in the same feature branch.
MinStakeMustBePositive = 94,
VerifierNotStaked = 95,
SlashExceedsStake = 96,
InsufficientStake = 97,

// ── Carbon credit marketplace (101–107) ───────────────────────────────────
ListingAmountMustBePositive = 101,
PriceMustBePositive = 102,
ListingNotFound = 103,
ListingNotActive = 104,
BuyAmountMustBePositive = 105,
InsufficientLiquidity = 106,
SelfTrade = 107,
}
24 changes: 24 additions & 0 deletions contracts/nft-certificate/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "nft-certificate"
version = "0.1.0"
edition = "2021"

[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
soroban-sdk = { version = "21.7.7", features = ["alloc"] }
harvesta-errors = { path = "../harvesta-errors" }

[dev-dependencies]
soroban-sdk = { version = "21.7.7", features = ["testutils", "alloc"] }

[profile.release]
opt-level = "z"
overflow-checks = true
debug = 0
strip = "symbols"
debug-assertions = false
panic = "abort"
codegen-units = 1
lto = true
Loading