Skip to content

Commit 91b41b2

Browse files
committed
Add extra helper function to calculate user voting power in specific proposal
1 parent cd8af2c commit 91b41b2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

contracts/dao/extensions/aibtc-action-proposals.clar

+11
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,17 @@
238238
;; read only functions
239239
;;
240240

241+
(define-read-only (get-voting-power (who principal) (proposalId uint))
242+
(let
243+
(
244+
(proposalRecord (unwrap! (map-get? Proposals proposalId) ERR_PROPOSAL_NOT_FOUND))
245+
(proposalBlockHash (unwrap! (get-block-hash (get startBlock proposalRecord)) ERR_RETRIEVING_START_BLOCK_HASH))
246+
)
247+
(at-block proposalBlockHash (contract-call? .aibtc-token get-balance who))
248+
)
249+
)
250+
251+
241252
(define-read-only (get-protocol-treasury)
242253
(if (is-eq (var-get protocolTreasury) SELF)
243254
none

0 commit comments

Comments
 (0)