diff --git a/contracts/dao/extensions/aibtcdev-messaging.clar b/contracts/dao/extensions/aibtcdev-messaging.clar index ef41573..7c78be0 100644 --- a/contracts/dao/extensions/aibtcdev-messaging.clar +++ b/contracts/dao/extensions/aibtcdev-messaging.clar @@ -18,8 +18,9 @@ (ok true) ) -(define-public (send (msg (string-ascii 1048576)) (opcode (optional (buff 16)))) +(define-public (send (msg (string-ascii 1048576)) (isFromDao bool)) (begin + (and isFromDao (try! (is-dao-or-extension))) (asserts! (> (len msg) u0) INPUT_ERROR) ;; print the message as the first event (print msg) @@ -29,9 +30,19 @@ payload: { caller: contract-caller, height: block-height, + isFromDao: isFromDao, sender: tx-sender, } }) (ok true) ) ) + +;; private functions +;; + +(define-private (is-dao-or-extension) + (ok (asserts! (or (is-eq tx-sender .aibtcdev-dao) + (contract-call? .aibtcdev-dao is-extension contract-caller)) ERR_UNAUTHORIZED + )) +) diff --git a/contracts/dao/traits/aibtcdev-dao-traits-v1.clar b/contracts/dao/traits/aibtcdev-dao-traits-v1.clar index 4b716d2..445f021 100644 --- a/contracts/dao/traits/aibtcdev-dao-traits-v1.clar +++ b/contracts/dao/traits/aibtcdev-dao-traits-v1.clar @@ -47,10 +47,11 @@ (define-trait messaging ( - ;; send a message on-chain + ;; send a message on-chain (opt from DAO) ;; @param msg the message to send (up to 1MB) + ;; @param isFromDao whether the message is from the DAO ;; @returns (response bool uint) - (send ((string-ascii 1048576)) (response bool uint)) + (send ((string-ascii 1048576) bool) (response bool uint)) ) )