Skip to content

Commit 8a22db9

Browse files
committed
fix: use dao auth instead of deployer
1 parent 61f65d3 commit 8a22db9

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

contracts/dao/extensions/aibtcdev-bank-account.clar

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,43 @@
2727
;; public functions
2828
;;
2929

30+
(define-public (is-dao-or-extension)
31+
(ok (asserts! (or (is-eq tx-sender .aibtcdev-dao)
32+
(contract-call? .aibtcdev-dao is-extension contract-caller)) ERR_UNAUTHORIZED
33+
))
34+
)
35+
36+
(define-public (callback (sender principal) (memo (buff 34)))
37+
(ok true)
38+
)
39+
3040
(define-public (set-account-holder (new principal))
3141
(begin
32-
(try! (is-deployer))
42+
(try! (is-dao-or-extension))
3343
(asserts! (not (is-eq (var-get accountHolder) new)) ERR_INVALID)
3444
(ok (var-set accountHolder new))
3545
)
3646
)
3747

3848
(define-public (set-withdrawal-period (period uint))
3949
(begin
40-
(try! (is-deployer))
50+
(try! (is-dao-or-extension))
4151
(asserts! (> period u0) ERR_INVALID)
4252
(ok (var-set withdrawalPeriod period))
4353
)
4454
)
4555

4656
(define-public (set-withdrawal-amount (amount uint))
4757
(begin
48-
(try! (is-deployer))
58+
(try! (is-dao-or-extension))
4959
(asserts! (> amount u0) ERR_INVALID)
5060
(ok (var-set withdrawalAmount amount))
5161
)
5262
)
5363

5464
(define-public (override-last-withdrawal-block (block uint))
5565
(begin
56-
(try! (is-deployer))
66+
(try! (is-dao-or-extension))
5767
(asserts! (> block u0) ERR_INVALID)
5868
(ok (var-set lastWithdrawalBlock block))
5969
)
@@ -95,16 +105,16 @@
95105
)
96106
)
97107

98-
(define-public (callback (sender principal) (memo (buff 34)))
99-
(ok true)
100-
)
101-
102108
;; read only functions
103109
;;
104110
(define-read-only (get-account-balance)
105111
(stx-get-balance SELF)
106112
)
107113

114+
(define-read-only (get-account-holder)
115+
(var-get accountHolder)
116+
)
117+
108118
(define-read-only (get-withdrawal-period)
109119
(var-get withdrawalPeriod)
110120
)
@@ -119,9 +129,10 @@
119129

120130
(define-read-only (get-all-vars)
121131
{
122-
withdrawalPeriod: (var-get withdrawalPeriod),
132+
accountHolder: (var-get accountHolder),
133+
lastWithdrawalBlock: (var-get lastWithdrawalBlock),
123134
withdrawalAmount: (var-get withdrawalAmount),
124-
lastWithdrawalBlock: (var-get lastWithdrawalBlock)
135+
withdrawalPeriod: (var-get withdrawalPeriod),
125136
}
126137
)
127138

0 commit comments

Comments
 (0)