Skip to content

Commit 2b704e9

Browse files
committed
fix: bring proposal code in sync, use stx block for at-block
Merges some other minor changes, one test passing each should be ready to translate to the templates for testnet.
1 parent 9e181ef commit 2b704e9

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@
5151
createdAt: uint, ;; block height
5252
caller: principal, ;; contract caller
5353
creator: principal, ;; proposal creator (tx-sender)
54-
startBlock: uint, ;; block height
55-
endBlock: uint, ;; block height
54+
startBlockStx: uint, ;; block height for at-block calls
55+
startBlock: uint, ;; burn block height
56+
endBlock: uint, ;; burn block height
5657
votesFor: uint, ;; total votes for
5758
votesAgainst: uint, ;; total votes against
5859
liquidTokens: uint, ;; liquid tokens
@@ -94,6 +95,7 @@
9495
parameters: parameters,
9596
creator: tx-sender,
9697
liquidTokens: liquidTokens,
98+
startBlockStx: block-height,
9799
startBlock: burn-block-height,
98100
endBlock: (+ burn-block-height VOTING_PERIOD)
99101
}
@@ -105,6 +107,7 @@
105107
createdAt: burn-block-height,
106108
caller: contract-caller,
107109
creator: tx-sender,
110+
startBlockStx: block-height,
108111
startBlock: burn-block-height,
109112
endBlock: (+ burn-block-height VOTING_PERIOD),
110113
votesFor: u0,
@@ -122,7 +125,7 @@
122125
(let
123126
(
124127
(proposalRecord (unwrap! (map-get? Proposals proposalId) ERR_PROPOSAL_NOT_FOUND))
125-
(proposalBlock (get startBlock proposalRecord))
128+
(proposalBlock (get startBlockStx proposalRecord))
126129
(proposalBlockHash (unwrap! (get-block-hash proposalBlock) ERR_RETRIEVING_START_BLOCK_HASH))
127130
(senderBalance (unwrap! (at-block proposalBlockHash (contract-call? .aibtc-token get-balance tx-sender)) ERR_FETCHING_TOKEN_DATA))
128131
)
@@ -201,7 +204,7 @@
201204
(let
202205
(
203206
(proposalRecord (unwrap! (map-get? Proposals proposalId) ERR_PROPOSAL_NOT_FOUND))
204-
(proposalBlockHash (unwrap! (get-block-hash (get startBlock proposalRecord)) ERR_RETRIEVING_START_BLOCK_HASH))
207+
(proposalBlockHash (unwrap! (get-block-hash (get startBlockStx proposalRecord)) ERR_RETRIEVING_START_BLOCK_HASH))
205208
)
206209
(at-block proposalBlockHash (contract-call? .aibtc-token get-balance who))
207210
)
@@ -244,7 +247,6 @@
244247
))
245248
)
246249

247-
;; get block hash by height
248250
(define-private (get-block-hash (blockHeight uint))
249251
(get-block-info? id-header-hash blockHeight)
250252
)

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
proposal: proposalContract,
9090
creator: tx-sender,
9191
liquidTokens: liquidTokens,
92+
startBlockStx: block-height,
9293
startBlock: burn-block-height,
9394
endBlock: (+ burn-block-height VOTING_PERIOD)
9495
}
@@ -116,8 +117,7 @@
116117
(proposalRecord (unwrap! (map-get? Proposals proposalContract) ERR_PROPOSAL_NOT_FOUND))
117118
(proposalBlock (get startBlockStx proposalRecord))
118119
(proposalBlockHash (unwrap! (get-block-hash proposalBlock) ERR_RETRIEVING_START_BLOCK_HASH))
119-
(senderBalanceResponse (at-block proposalBlockHash (contract-call? .aibtc-token get-balance tx-sender)))
120-
(senderBalance (unwrap-panic senderBalanceResponse))
120+
(senderBalance (unwrap! (at-block proposalBlockHash (contract-call? .aibtc-token get-balance tx-sender)) ERR_FETCHING_TOKEN_DATA))
121121
)
122122
;; caller has the required balance
123123
(asserts! (> senderBalance u0) ERR_INSUFFICIENT_BALANCE)
@@ -156,8 +156,6 @@
156156
(
157157
(proposalContract (contract-of proposal))
158158
(proposalRecord (unwrap! (map-get? Proposals proposalContract) ERR_PROPOSAL_NOT_FOUND))
159-
(tokenTotalSupply (unwrap! (contract-call? .aibtc-token get-total-supply) ERR_FETCHING_TOKEN_DATA))
160-
(treasuryBalance (unwrap! (contract-call? .aibtc-token get-balance .aibtc-treasury) ERR_FETCHING_TOKEN_DATA))
161159
;; if VOTING_QUORUM <= ((votesFor * 100) / liquidTokens)
162160
(votePassed (<= VOTING_QUORUM (/ (* (get votesFor proposalRecord) u100) (get liquidTokens proposalRecord))))
163161
)
@@ -235,7 +233,6 @@
235233
))
236234
)
237235

238-
;; get block hash by height
239236
(define-private (get-block-hash (blockHeight uint))
240237
(get-block-info? id-header-hash blockHeight)
241238
)

0 commit comments

Comments
 (0)