@@ -165,7 +165,7 @@ func govConvertScales(sc []*big.Int) []hexutil.Uint64 {
165165 return res
166166}
167167
168- // GovernanceProposal provides a detail of Proposal of a governance contract
168+ // GovernanceProposalDetails provides a detail of Proposal of a governance contract
169169// specified by its id.
170170func (ftm * FtmBridge ) GovernanceProposalDetails (prop * common.Address ) (* govProposalExtended , error ) {
171171 // get the proposal contract
@@ -216,44 +216,30 @@ func (ftm *FtmBridge) GovernanceOptionState(gov *common.Address, propId *hexutil
216216}
217217
218218// GovernanceOptionStates returns a list of states of options of a proposal.
219- func (ftm * FtmBridge ) GovernanceOptionStates (gov * common.Address , propId * hexutil.Big ) ([]* types.GovernanceOptionState , error ) {
219+ func (ftm * FtmBridge ) GovernanceOptionStates (gov * common.Address , propId * hexutil.Big , optRange int ) ([]* types.GovernanceOptionState , error ) {
220220 // get the contract
221221 gc , err := contracts .NewGovernance (* gov , ftm .eth )
222222 if err != nil {
223223 ftm .log .Errorf ("can not access governance %s; %s" , gov .String (), err .Error ())
224224 return nil , err
225225 }
226226
227- // get the number of options
228- max , err := gc .MaxOptions (nil )
229- if err != nil {
230- ftm .log .Errorf ("unknown options on governance %s; %s" , gov .String (), err .Error ())
231- return nil , err
232- }
233-
234227 // make the container and collect the states
235- zero := new (big.Int )
236- res := make ([]* types.GovernanceOptionState , 0 )
228+ res := make ([]* types.GovernanceOptionState , optRange )
237229
238230 // loop over all possible states and check them one by one
239- for i := int64 ( 0 ) ; i < max . Int64 () ; i ++ {
231+ for i := 0 ; i < optRange ; i ++ {
240232 // get the state of this option
241- gs , err : = ftm .GovernanceOptionStateById (gc , propId , (* hexutil .Big )(big .NewInt (i )))
233+ res [ i ] , err = ftm .GovernanceOptionStateById (gc , propId , (* hexutil .Big )(big .NewInt (int64 ( i ) )))
242234 if err != nil {
243235 ftm .log .Errorf ("unknown option #%d on governance %s; %s" , i , gov .String (), err .Error ())
244236 break
245237 }
246-
247- // is this a state we would like to keep? e.g. any votes?
248- if 0 != zero .Cmp (gs .Votes .ToInt ()) {
249- res = append (res , gs )
250- }
251238 }
252-
253239 return res , nil
254240}
255241
256- // GovernanceOptionState returns a state of the given option of a proposal.
242+ // GovernanceOptionStateById returns a state of the given option of a proposal.
257243func (ftm * FtmBridge ) GovernanceOptionStateById (gc * contracts.Governance , propId * hexutil.Big , optId * hexutil.Big ) (* types.GovernanceOptionState , error ) {
258244 // get the state
259245 data , err := gc .ProposalOptionState (nil , propId .ToInt (), optId .ToInt ())
@@ -322,7 +308,7 @@ func (ftm *FtmBridge) GovernanceProposalsBy(gov *common.Address) ([]*types.Gover
322308 }
323309
324310 // log what we do
325- ftm .log .Debugf ("loading %d proposals of %s" , maxProposalId .Uint64 (), gov .String ())
311+ ftm .log .Noticef ("loading %d proposals of %s" , maxProposalId .Uint64 (), gov .String ())
326312
327313 // make the array; the maxProposalId starts with 1 so we need array for one less
328314 result := make ([]* types.GovernanceProposal , 0 )
@@ -337,7 +323,7 @@ func (ftm *FtmBridge) GovernanceProposalsBy(gov *common.Address) ([]*types.Gover
337323 }
338324
339325 // keep the proposal in the list
340- ftm .log .Debugf ("found proposal #%d on %s" , gp .Id .ToInt ().Uint64 (), gov .String ())
326+ ftm .log .Noticef ("found proposal #%d on %s" , gp .Id .ToInt ().Uint64 (), gov .String ())
341327 result = append (result , gp )
342328 }
343329
0 commit comments