-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from aibtcdev/feat/add-remaining-actions
Add remaining action proposals
- Loading branch information
Showing
9 changed files
with
176 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
contracts/dao/extensions/actions/aibtc-action-add-resource.clar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(impl-trait .aibtcdev-dao-traits-v1.extension) | ||
(impl-trait .aibtcdev-dao-traits-v1.action) | ||
|
||
(define-constant ERR_UNAUTHORIZED (err u10001)) | ||
(define-constant ERR_INVALID_PARAMS (err u10002)) | ||
|
||
(define-public (callback (sender principal) (memo (buff 34))) (ok true)) | ||
|
||
(define-public (run (parameters (buff 2048))) | ||
(let | ||
( | ||
(paramsTuple (unwrap! (from-consensus-buff? | ||
{ name: (string-utf8 50), description: (string-utf8 255), price: uint, url: (optional (string-utf8 255)) } | ||
parameters) ERR_INVALID_PARAMS)) | ||
) | ||
(try! (is-dao-or-extension)) | ||
(try! (contract-call? .aibtc-payments-invoices add-resource (get name paramsTuple) (get description paramsTuple) (get price paramsTuple) (get url paramsTuple))) | ||
(ok true) | ||
) | ||
) | ||
|
||
(define-private (is-dao-or-extension) | ||
(ok (asserts! (or (is-eq tx-sender .aibtcdev-base-dao) | ||
(contract-call? .aibtcdev-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED | ||
)) | ||
) |
23 changes: 23 additions & 0 deletions
23
contracts/dao/extensions/actions/aibtc-action-allow-asset.clar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(impl-trait .aibtcdev-dao-traits-v1.extension) | ||
(impl-trait .aibtcdev-dao-traits-v1.action) | ||
|
||
(define-constant ERR_UNAUTHORIZED (err u10001)) | ||
(define-constant ERR_INVALID_PARAMS (err u10002)) | ||
|
||
(define-public (callback (sender principal) (memo (buff 34))) (ok true)) | ||
|
||
(define-public (run (parameters (buff 2048))) | ||
(let | ||
( | ||
(asset (unwrap! (from-consensus-buff? principal parameters) ERR_INVALID_PARAMS)) | ||
) | ||
(try! (is-dao-or-extension)) | ||
(contract-call? .aibtc-treasury allow-asset asset true) | ||
) | ||
) | ||
|
||
(define-private (is-dao-or-extension) | ||
(ok (asserts! (or (is-eq tx-sender .aibtcdev-base-dao) | ||
(contract-call? .aibtcdev-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED | ||
)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
contracts/dao/extensions/actions/aibtc-action-set-withdrawal-amount.clar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(impl-trait .aibtcdev-dao-traits-v1.extension) | ||
(impl-trait .aibtcdev-dao-traits-v1.action) | ||
|
||
(define-constant ERR_UNAUTHORIZED (err u10001)) | ||
(define-constant ERR_INVALID_PARAMS (err u10002)) | ||
(define-constant ERR_PARAMS_OUT_OF_RANGE (err u10003)) | ||
|
||
(define-public (callback (sender principal) (memo (buff 34))) (ok true)) | ||
|
||
(define-public (run (parameters (buff 2048))) | ||
(let | ||
( | ||
(amount (unwrap! (from-consensus-buff? uint parameters) ERR_INVALID_PARAMS)) | ||
) | ||
(try! (is-dao-or-extension)) | ||
;; verify within limits for low quorum | ||
;; more than 0, less than 100 STX (100_000_000) | ||
(asserts! (and (> amount u0) (< amount u100000000)) ERR_INVALID_PARAMS) | ||
(contract-call? .aibtc-bank-account set-withdrawal-amount amount) | ||
) | ||
) | ||
|
||
(define-private (is-dao-or-extension) | ||
(ok (asserts! (or (is-eq tx-sender .aibtcdev-base-dao) | ||
(contract-call? .aibtcdev-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED | ||
)) | ||
) |
27 changes: 27 additions & 0 deletions
27
contracts/dao/extensions/actions/aibtc-action-set-withdrawal-period.clar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(impl-trait .aibtcdev-dao-traits-v1.extension) | ||
(impl-trait .aibtcdev-dao-traits-v1.action) | ||
|
||
(define-constant ERR_UNAUTHORIZED (err u10001)) | ||
(define-constant ERR_INVALID_PARAMS (err u10002)) | ||
(define-constant ERR_PARAMS_OUT_OF_RANGE (err u10003)) | ||
|
||
(define-public (callback (sender principal) (memo (buff 34))) (ok true)) | ||
|
||
(define-public (run (parameters (buff 2048))) | ||
(let | ||
( | ||
(period (unwrap! (from-consensus-buff? uint parameters) ERR_INVALID_PARAMS)) | ||
) | ||
(try! (is-dao-or-extension)) | ||
;; verify within limits for low quorum | ||
;; more than 6 blocks (1hr), less than 1008 blocks (~1 week) | ||
(asserts! (and (> period u6) (< period u1008)) ERR_PARAMS_OUT_OF_RANGE) | ||
(contract-call? .aibtc-bank-account set-withdrawal-period period) | ||
) | ||
) | ||
|
||
(define-private (is-dao-or-extension) | ||
(ok (asserts! (or (is-eq tx-sender .aibtcdev-base-dao) | ||
(contract-call? .aibtcdev-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED | ||
)) | ||
) |
23 changes: 23 additions & 0 deletions
23
contracts/dao/extensions/actions/aibtc-action-toggle-resource-by-name.clar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
(impl-trait .aibtcdev-dao-traits-v1.extension) | ||
(impl-trait .aibtcdev-dao-traits-v1.action) | ||
|
||
(define-constant ERR_UNAUTHORIZED (err u10001)) | ||
(define-constant ERR_INVALID_PARAMS (err u10002)) | ||
|
||
(define-public (callback (sender principal) (memo (buff 34))) (ok true)) | ||
|
||
(define-public (run (parameters (buff 2048))) | ||
(let | ||
( | ||
(resourceName (unwrap! (from-consensus-buff? (string-utf8 50) parameters) ERR_INVALID_PARAMS)) | ||
) | ||
(try! (is-dao-or-extension)) | ||
(contract-call? .aibtc-payments-invoices toggle-resource-by-name resourceName) | ||
) | ||
) | ||
|
||
(define-private (is-dao-or-extension) | ||
(ok (asserts! (or (is-eq tx-sender .aibtcdev-base-dao) | ||
(contract-call? .aibtcdev-base-dao is-extension contract-caller)) ERR_UNAUTHORIZED | ||
)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters