|
27 | 27 | ;; public functions
|
28 | 28 | ;;
|
29 | 29 |
|
| 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 | + |
30 | 40 | (define-public (set-account-holder (new principal))
|
31 | 41 | (begin
|
32 |
| - (try! (is-deployer)) |
| 42 | + (try! (is-dao-or-extension)) |
33 | 43 | (asserts! (not (is-eq (var-get accountHolder) new)) ERR_INVALID)
|
34 | 44 | (ok (var-set accountHolder new))
|
35 | 45 | )
|
36 | 46 | )
|
37 | 47 |
|
38 | 48 | (define-public (set-withdrawal-period (period uint))
|
39 | 49 | (begin
|
40 |
| - (try! (is-deployer)) |
| 50 | + (try! (is-dao-or-extension)) |
41 | 51 | (asserts! (> period u0) ERR_INVALID)
|
42 | 52 | (ok (var-set withdrawalPeriod period))
|
43 | 53 | )
|
44 | 54 | )
|
45 | 55 |
|
46 | 56 | (define-public (set-withdrawal-amount (amount uint))
|
47 | 57 | (begin
|
48 |
| - (try! (is-deployer)) |
| 58 | + (try! (is-dao-or-extension)) |
49 | 59 | (asserts! (> amount u0) ERR_INVALID)
|
50 | 60 | (ok (var-set withdrawalAmount amount))
|
51 | 61 | )
|
52 | 62 | )
|
53 | 63 |
|
54 | 64 | (define-public (override-last-withdrawal-block (block uint))
|
55 | 65 | (begin
|
56 |
| - (try! (is-deployer)) |
| 66 | + (try! (is-dao-or-extension)) |
57 | 67 | (asserts! (> block u0) ERR_INVALID)
|
58 | 68 | (ok (var-set lastWithdrawalBlock block))
|
59 | 69 | )
|
|
95 | 105 | )
|
96 | 106 | )
|
97 | 107 |
|
98 |
| -(define-public (callback (sender principal) (memo (buff 34))) |
99 |
| - (ok true) |
100 |
| -) |
101 |
| - |
102 | 108 | ;; read only functions
|
103 | 109 | ;;
|
104 | 110 | (define-read-only (get-account-balance)
|
105 | 111 | (stx-get-balance SELF)
|
106 | 112 | )
|
107 | 113 |
|
| 114 | +(define-read-only (get-account-holder) |
| 115 | + (var-get accountHolder) |
| 116 | +) |
| 117 | + |
108 | 118 | (define-read-only (get-withdrawal-period)
|
109 | 119 | (var-get withdrawalPeriod)
|
110 | 120 | )
|
|
119 | 129 |
|
120 | 130 | (define-read-only (get-all-vars)
|
121 | 131 | {
|
122 |
| - withdrawalPeriod: (var-get withdrawalPeriod), |
| 132 | + accountHolder: (var-get accountHolder), |
| 133 | + lastWithdrawalBlock: (var-get lastWithdrawalBlock), |
123 | 134 | withdrawalAmount: (var-get withdrawalAmount),
|
124 |
| - lastWithdrawalBlock: (var-get lastWithdrawalBlock) |
| 135 | + withdrawalPeriod: (var-get withdrawalPeriod), |
125 | 136 | }
|
126 | 137 | )
|
127 | 138 |
|
|
0 commit comments