package quillbounty import ( "strconv" "strings" ) const ( DenomUgnot = "ugnot" MinDurationBlocks = int64(10) MaxDurationBlocks = int64(5_000_000) MaxTitleLen = 120 MaxSpecLen = 4000 MaxSummaryLen = 1000 MaxURLLen = 300 ) type BountyStatus string const ( StatusOpen BountyStatus = "open" StatusCompleted BountyStatus = "completed" StatusExpired BountyStatus = "expired" ) type SubmissionStatus string const ( SubPending SubmissionStatus = "pending" SubNeedsRevision SubmissionStatus = "needs_revision" SubApproved SubmissionStatus = "approved" ) type Submission struct { ID uint64 BountyID uint64 Builder address ProofURL string CommitHash string Summary string Status SubmissionStatus ReviewNote string PayoutUgnot int64 SubmittedAt int64 ReviewedAt int64 } type Bounty struct { ID uint64 Sponsor address Reviewer address Title string Category string Spec string TotalFunded int64 RemainingUgnot int64 CreatedHeight int64 DeadlineHeight int64 Status BountyStatus Submissions []*Submission } type BuilderProfile struct { Address address CompletedCount int TotalEarnedUgnot int64 LastBountyID uint64 } func padID(id uint64) string { s := strconv.FormatUint(id, 10) if len(s) >= 12 { return s } return strings.Repeat("0", 12-len(s)) + s } func normalizeCategory(cat string) string { c := strings.ToLower(strings.TrimSpace(cat)) switch c { case "dev", "ai", "security", "docs", "design": return c default: return "dev" } } func formatGNOT(ugnot int64) string { if ugnot < 0 { return "-" + formatGNOT(-ugnot) } whole := ugnot / 1_000_000 frac := ugnot % 1_000_000 if frac == 0 { return strconv.FormatInt(whole, 10) + " GNOT" } f := strconv.FormatInt(frac, 10) f = strings.Repeat("0", 6-len(f)) + f f = strings.TrimRight(f, "0") return strconv.FormatInt(whole, 10) + "." + f + " GNOT" } func escapeJSON(s string) string { var b strings.Builder for i := 0; i < len(s); i++ { c := s[i] switch c { case '"': b.WriteString(`\"`) case '\\': b.WriteString(`\\`) case '\n': b.WriteString(`\n`) case '\r': b.WriteString(`\r`) case '\t': b.WriteString(`\t`) default: if c < 0x20 { b.WriteString(" ") } else { b.WriteByte(c) } } } return b.String() } func shortAddr(a address) string { s := a.String() if len(s) <= 14 { return s } return s[:8] + "..." + s[len(s)-4:] }