Skip to content

Commit 0c711b1

Browse files
committed
docs: Add documentation for extension and proposal traits
1 parent 26ca77e commit 0c711b1

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

docs/dao/traits/extension.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Extension Trait
2+
3+
The extension trait defines the base interface that all DAO extensions must implement.
4+
5+
## Interface
6+
7+
```clarity
8+
(define-trait extension (
9+
(callback (principal (buff 34)) (response bool uint))
10+
))
11+
```
12+
13+
## Functions
14+
15+
### callback
16+
Standard extension callback support.
17+
- Parameters:
18+
- `sender`: Calling principal
19+
- `memo`: Optional callback data (34 bytes)
20+
- Returns: Success/failure response
21+
22+
## Implementation Requirements
23+
24+
1. Handle callbacks from DAO and other extensions
25+
2. Process callback memos appropriately
26+
3. Return meaningful success/failure responses
27+
4. Implement authorization checks
28+
5. Log callback events consistently
29+
30+
## Usage Pattern
31+
32+
Extensions should implement callback to:
33+
1. Receive notifications from other extensions
34+
2. Process cross-extension requests
35+
3. Handle DAO-initiated actions
36+
4. Support extension-specific callbacks
37+
38+
Example implementation:
39+
```clarity
40+
(define-public (callback (sender principal) (memo (buff 34)))
41+
(begin
42+
;; Verify sender is DAO or extension
43+
(try! (is-dao-or-extension))
44+
45+
;; Process callback
46+
(print {
47+
notification: "callback",
48+
payload: {
49+
sender: sender,
50+
memo: memo
51+
}
52+
})
53+
54+
(ok true)
55+
)
56+
)
57+
```

docs/dao/traits/proposal.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Proposal Trait
2+
3+
The proposal trait defines the interface that all DAO proposals must implement.
4+
5+
## Interface
6+
7+
```clarity
8+
(define-trait proposal (
9+
(execute (principal) (response bool uint))
10+
))
11+
```
12+
13+
## Functions
14+
15+
### execute
16+
Executes the proposal's changes.
17+
- Parameters:
18+
- `sender`: Principal initiating execution
19+
- Returns: Success/failure response
20+
21+
## Implementation Requirements
22+
23+
1. Verify execution authorization
24+
2. Make atomic state changes
25+
3. Return meaningful success/failure
26+
4. Log execution events
27+
5. Handle errors gracefully
28+
29+
## Usage Pattern
30+
31+
Proposals should:
32+
1. Implement authorization checks
33+
2. Make targeted state changes
34+
3. Emit comprehensive logs
35+
4. Return clear status
36+
37+
Example implementation:
38+
```clarity
39+
(define-public (execute (sender principal))
40+
(begin
41+
;; Verify sender
42+
(asserts! (is-eq sender .aibtcdev-dao) ERR_UNAUTHORIZED)
43+
44+
;; Make changes
45+
(try! (contract-call? .aibtcdev-dao set-something new-value))
46+
47+
;; Log execution
48+
(print {
49+
notification: "proposal-executed",
50+
payload: {
51+
sender: sender,
52+
changes: "..."
53+
}
54+
})
55+
56+
(ok true)
57+
)
58+
)
59+
```

0 commit comments

Comments
 (0)