Branch data Line data Source code
1 : : ;; Title: BME03 Core Proposals
2 : : ;; Synopsis:
3 : : ;; This extension allows for the creation of core proposals by a few trusted
4 : : ;; principals.
5 : : ;; Description:
6 : : ;; Only a list of trusted principals, designated as the
7 : : ;; "core team", can create core proposals. The core proposal
8 : : ;; extension has an optional ~3 month sunset period, after which no more core
9 : : ;; proposals can be made - set it to 0 to disable. The core team members, sunset period, and
10 : : ;; core vote duration can be changed by means of a future proposal.
11 : :
12 : : (impl-trait 'SP3JP0N1ZXGASRJ0F7QAHWFPGTVK9T2XNXDB908Z.extension-trait.extension-trait)
13 : : (use-trait proposal-trait 'SP3JP0N1ZXGASRJ0F7QAHWFPGTVK9T2XNXDB908Z.proposal-trait.proposal-trait)
14 : :
15 : : (define-data-var core-team-sunset-height uint u0) ;; does not expire by default - can be changed by proposal
16 : :
17 : : (define-constant err-unauthorised (err u3300))
18 : : (define-constant err-not-core-team-member (err u3301))
19 : : (define-constant err-sunset-height-reached (err u3302))
20 : : (define-constant err-sunset-height-in-past (err u3303))
21 : : (define-constant err-start-too-soon (err u3304))
22 : : (define-constant err-ends-too-late (err u3305))
23 : :
24 : : (define-constant MIN_PROPOSAL_DELAY u3) ;; at least 3 blocks in future
25 : : (define-constant MAX_PROPOSAL_DURATION u4380) ;; approx. 1 month
26 : :
27 : : (define-map core-team principal bool)
28 : :
29 : : ;; --- Authorisation check
30 : :
31 : 300 : (define-public (is-dao-or-extension)
32 [ - ][ + - ]: 601 : (ok (asserts! (or (is-eq tx-sender .bigmarket-dao) (contract-call? .bigmarket-dao is-extension contract-caller)) err-unauthorised))
33 : : )
34 : :
35 : : ;; --- Internal DAO functions
36 : :
37 : 1 : (define-public (set-core-team-sunset-height (height uint))
38 : 1 : (begin
39 : 1 : (try! (is-dao-or-extension))
40 [ - ]: 1 : (asserts! (> height burn-block-height) err-sunset-height-in-past)
41 : 1 : (ok (var-set core-team-sunset-height height))
42 : : )
43 : : )
44 : :
45 : 300 : (define-public (set-core-team-member (who principal) (member bool))
46 : 600 : (begin
47 : 600 : (try! (is-dao-or-extension))
48 : 600 : (print {event: "set-core-team-member", who: who, member: member})
49 : 600 : (ok (map-set core-team who member))
50 : : )
51 : : )
52 : :
53 : : ;; --- Public functions
54 : :
55 : 38 : (define-read-only (is-core-team-member (who principal))
56 : 55 : (default-to false (map-get? core-team who))
57 : : )
58 : :
59 : 38 : (define-public (core-propose (proposal <proposal-trait>) (start-burn-height uint) (duration uint) (custom-majority (optional uint)))
60 : 55 : (begin
61 [ - ]: 55 : (asserts! (is-core-team-member tx-sender) err-not-core-team-member)
62 [ - ][ + - ]: 55 : (asserts! (or (is-eq (var-get core-team-sunset-height) u0) (< burn-block-height (var-get core-team-sunset-height))) err-sunset-height-reached)
63 : : ;; Bounds enforcement
64 [ - ]: 55 : (asserts! (>= (- start-burn-height burn-block-height) MIN_PROPOSAL_DELAY) err-start-too-soon)
65 [ - ]: 55 : (asserts! (<= duration MAX_PROPOSAL_DURATION) err-ends-too-late)
66 : 55 : (contract-call? .bme001-0-proposal-voting add-proposal proposal
67 : : {
68 : 55 : start-burn-height: start-burn-height,
69 : 55 : end-burn-height: (+ start-burn-height duration),
70 : 55 : custom-majority: custom-majority,
71 : 55 : proposer: tx-sender ;; change to original submitter
72 : : }
73 : : )
74 : : )
75 : : )
76 : :
77 : : ;; --- Extension callback
78 : :
79 : 0 : (define-public (callback (sender principal) (memo (buff 34)))
80 : 0 : (ok true)
81 : : )
|