File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -288,18 +288,25 @@ export function CreateVoteForm() {
288288 break
289289 }
290290 default : {
291- if ( data . customAddresses . length === 0 ) {
291+ // Filter out empty addresses to ensure we only process valid ones
292+ const validAddresses = data . customAddresses . filter ( Boolean )
293+
294+ if ( validAddresses . length === 0 ) {
292295 throw new Error ( 'Please add at least one address to the custom addresses list' )
293296 }
294297
295298 // Step 1: Create census
296299 const censusId = await api . census . createCensus ( )
297300
298- // Step 2: Add participants
299- const participants = data . customAddresses . map ( ( address , index ) => ( {
300- key : address ,
301- weight : data . useWeightedVoting && data . customAddressWeights [ index ] ? data . customAddressWeights [ index ] : '1' ,
302- } ) )
301+ // Step 2: Add participants (only with valid addresses)
302+ const participants = validAddresses . map ( ( address ) => {
303+ // Find the original index to get the correct weight
304+ const originalIndex = data . customAddresses . indexOf ( address )
305+ return {
306+ key : address ,
307+ weight : data . useWeightedVoting && data . customAddressWeights [ originalIndex ] ? data . customAddressWeights [ originalIndex ] : '1' ,
308+ }
309+ } )
303310 await api . census . addParticipants ( censusId , participants )
304311 const censusRoot = await api . census . getCensusRoot ( censusId )
305312 const censusSize = await api . census . getCensusSize ( censusId )
You can’t perform that action at this time.
0 commit comments