Skip to content

Commit 172817b

Browse files
committed
fix: expand trait docs, clean up proxy
1 parent 65c450c commit 172817b

File tree

2 files changed

+88
-62
lines changed

2 files changed

+88
-62
lines changed

contracts/dao/traits/aibtcdev-dao-traits-v1.clar

Lines changed: 88 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -45,58 +45,94 @@
4545
(withdraw-stx () (response bool uint))
4646
))
4747

48-
(define-trait messaging
49-
(
50-
;; send a message on-chain (opt from DAO)
51-
;; @param msg the message to send (up to 1MB)
52-
;; @param isFromDao whether the message is from the DAO
53-
;; @returns (response bool uint)
54-
(send ((string-ascii 1048576) bool) (response bool uint))
55-
)
56-
)
57-
58-
(define-trait resources
59-
(
60-
;; set payment address for resource invoices
61-
;; @param principal the new payment address
62-
;; @returns (response bool uint)
63-
(set-payment-address (principal) (response bool uint))
64-
;; adds a new resource that users can pay for
65-
;; @param name the name of the resource (unique!)
66-
;; @param price the price of the resource in microSTX
67-
;; @param description a description of the resource
68-
;; @returns (response uint uint)
69-
(add-resource ((string-utf8 50) (string-utf8 255) uint (optional (string-utf8 255))) (response uint uint))
70-
;; toggles a resource on or off for payment
71-
;; @param resource the ID of the resource
72-
;; @returns (response bool uint)
73-
(toggle-resource (uint) (response bool uint))
74-
;; toggles a resource on or off for payment by name
75-
;; @param name the name of the resource
76-
;; @returns (response bool uint)
77-
(toggle-resource-by-name ((string-utf8 50)) (response bool uint))
78-
)
79-
)
80-
81-
(define-trait invoices
82-
(
83-
(pay-invoice (uint (optional (buff 34))) (response uint uint))
84-
(pay-invoice-by-resource-name ((string-utf8 50) (optional (buff 34))) (response uint uint))
85-
)
86-
)
48+
(define-trait messaging (
49+
;; send a message on-chain (opt from DAO)
50+
;; @param msg the message to send (up to 1MB)
51+
;; @param isFromDao whether the message is from the DAO
52+
;; @returns (response bool uint)
53+
(send ((string-ascii 1048576) bool) (response bool uint))
54+
))
8755

88-
(define-trait treasury
89-
(
90-
;; STX deposits and withdrawals
91-
(deposit-stx (uint) (response bool uint))
92-
(withdraw-stx (uint principal) (response bool uint))
56+
(define-trait resources (
57+
;; set payment address for resource invoices
58+
;; @param principal the new payment address
59+
;; @returns (response bool uint)
60+
(set-payment-address (principal) (response bool uint))
61+
;; adds a new resource that users can pay for
62+
;; @param name the name of the resource (unique!)
63+
;; @param price the price of the resource in microSTX
64+
;; @param description a description of the resource
65+
;; @returns (response uint uint)
66+
(add-resource ((string-utf8 50) (string-utf8 255) uint (optional (string-utf8 255))) (response uint uint))
67+
;; toggles a resource on or off for payment
68+
;; @param resource the ID of the resource
69+
;; @returns (response bool uint)
70+
(toggle-resource (uint) (response bool uint))
71+
;; toggles a resource on or off for payment by name
72+
;; @param name the name of the resource
73+
;; @returns (response bool uint)
74+
(toggle-resource-by-name ((string-utf8 50)) (response bool uint))
75+
))
9376

94-
;; Fungible token deposits and withdrawals
95-
(deposit-ft (<ft-trait> uint) (response bool uint))
96-
(withdraw-ft (<ft-trait> uint principal) (response bool uint))
77+
(define-trait invoices (
78+
;; pay an invoice by ID
79+
;; @param invoice the ID of the invoice
80+
;; @returns (response uint uint)
81+
(pay-invoice (uint (optional (buff 34))) (response uint uint))
82+
;; pay an invoice by resource name
83+
;; @param name the name of the resource
84+
;; @returns (response uint uint)
85+
(pay-invoice-by-resource-name ((string-utf8 50) (optional (buff 34))) (response uint uint))
86+
))
9787

98-
;; NFT deposits and withdrawals
99-
(deposit-nft (<nft-trait> uint) (response bool uint))
100-
(withdraw-nft (<nft-trait> uint principal) (response bool uint))
101-
)
102-
)
88+
(define-trait treasury (
89+
;; allow an asset for deposit/withdrawal
90+
;; @param token the asset contract principal
91+
;; @param enabled whether the asset is allowed
92+
;; @returns (response bool uint)
93+
(allow-asset (principal bool) (response bool uint))
94+
;; allow multiple assets for deposit/withdrawal
95+
;; @param allowList a list of asset contracts and enabled status
96+
;; @returns (response bool uint)
97+
;; TODO: removed due to conflict with contract definition (both are the same?)
98+
;; (allow-assets ((list 100 (tuple (token principal) (enabled bool)))) (response bool uint))
99+
;; deposit STX to the treasury
100+
;; @param amount amount of microSTX to deposit
101+
;; @returns (response bool uint)
102+
(deposit-stx (uint) (response bool uint))
103+
;; deposit FT to the treasury
104+
;; @param ft the fungible token contract principal
105+
;; @param amount amount of tokens to deposit
106+
;; @returns (response bool uint)
107+
(deposit-ft (<ft-trait> uint) (response bool uint))
108+
;; deposit NFT to the treasury
109+
;; @param nft the non-fungible token contract principal
110+
;; @param id the ID of the token to deposit
111+
;; @returns (response bool uint)
112+
(deposit-nft (<nft-trait> uint) (response bool uint))
113+
;; withdraw STX from the treasury
114+
;; @param amount amount of microSTX to withdraw
115+
;; @param recipient the recipient of the STX
116+
;; @returns (response bool uint)
117+
(withdraw-stx (uint principal) (response bool uint))
118+
;; withdraw FT from the treasury
119+
;; @param ft the fungible token contract principal
120+
;; @param amount amount of tokens to withdraw
121+
;; @param recipient the recipient of the tokens
122+
;; @returns (response bool uint)
123+
(withdraw-ft (<ft-trait> uint principal) (response bool uint))
124+
;; withdraw NFT from the treasury
125+
;; @param nft the non-fungible token contract principal
126+
;; @param id the ID of the token to withdraw
127+
;; @param recipient the recipient of the token
128+
;; @returns (response bool uint)
129+
(withdraw-nft (<nft-trait> uint principal) (response bool uint))
130+
;; delegate STX for stacking in PoX
131+
;; @param amount max amount of microSTX that can be delegated
132+
;; @param to the address to delegate to
133+
;; @returns (response bool uint)
134+
(delegate-stx (uint principal) (response bool uint))
135+
;; revoke delegation of STX from stacking in PoX
136+
;; @returns (response bool uint)
137+
(revoke-delegate-stx () (response bool uint))
138+
))

contracts/test-proxy.clar

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@
88

99
;; public functions
1010
;;
11-
(define-public (get-standard-caller)
12-
(begin
13-
(print {
14-
caller: contract-caller,
15-
sender: tx-sender,
16-
})
17-
(ok (contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.aibtcdev-bank-account get-standard-caller))
18-
)
19-
)
20-
2111
(define-public (mint-aibtcdev-1 (to principal))
2212
(contract-call? 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.aibtcdev-airdrop-1 mint to)
2313
)

0 commit comments

Comments
 (0)