Skip to content

Commit

Permalink
fix: use dao auth instead of deployer
Browse files Browse the repository at this point in the history
  • Loading branch information
whoabuddy committed Nov 25, 2024
1 parent 61f65d3 commit 8a22db9
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions contracts/dao/extensions/aibtcdev-bank-account.clar
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,43 @@
;; public functions
;;

(define-public (is-dao-or-extension)
(ok (asserts! (or (is-eq tx-sender .aibtcdev-dao)
(contract-call? .aibtcdev-dao is-extension contract-caller)) ERR_UNAUTHORIZED
))
)

(define-public (callback (sender principal) (memo (buff 34)))
(ok true)
)

(define-public (set-account-holder (new principal))
(begin
(try! (is-deployer))
(try! (is-dao-or-extension))
(asserts! (not (is-eq (var-get accountHolder) new)) ERR_INVALID)
(ok (var-set accountHolder new))
)
)

(define-public (set-withdrawal-period (period uint))
(begin
(try! (is-deployer))
(try! (is-dao-or-extension))
(asserts! (> period u0) ERR_INVALID)
(ok (var-set withdrawalPeriod period))
)
)

(define-public (set-withdrawal-amount (amount uint))
(begin
(try! (is-deployer))
(try! (is-dao-or-extension))
(asserts! (> amount u0) ERR_INVALID)
(ok (var-set withdrawalAmount amount))
)
)

(define-public (override-last-withdrawal-block (block uint))
(begin
(try! (is-deployer))
(try! (is-dao-or-extension))
(asserts! (> block u0) ERR_INVALID)
(ok (var-set lastWithdrawalBlock block))
)
Expand Down Expand Up @@ -95,16 +105,16 @@
)
)

(define-public (callback (sender principal) (memo (buff 34)))
(ok true)
)

;; read only functions
;;
(define-read-only (get-account-balance)
(stx-get-balance SELF)
)

(define-read-only (get-account-holder)
(var-get accountHolder)
)

(define-read-only (get-withdrawal-period)
(var-get withdrawalPeriod)
)
Expand All @@ -119,9 +129,10 @@

(define-read-only (get-all-vars)
{
withdrawalPeriod: (var-get withdrawalPeriod),
accountHolder: (var-get accountHolder),
lastWithdrawalBlock: (var-get lastWithdrawalBlock),
withdrawalAmount: (var-get withdrawalAmount),
lastWithdrawalBlock: (var-get lastWithdrawalBlock)
withdrawalPeriod: (var-get withdrawalPeriod),
}
)

Expand Down

0 comments on commit 8a22db9

Please sign in to comment.