@@ -9,8 +9,8 @@ import { containsFlaggedLinks, flaggedAddresses } from '../helpers/moderation';
9
9
import { isMalicious } from '../helpers/monitoring' ;
10
10
import db from '../helpers/mysql' ;
11
11
import { getLimits , getSpaceType } from '../helpers/options' ;
12
+ import getStrategiesValue from '../helpers/strategiesValue' ;
12
13
import { captureError , getQuorum , jsonParse , validateChoices } from '../helpers/utils' ;
13
- import { setProposalVpValue } from '../helpers/vpValue' ;
14
14
15
15
const scoreAPIUrl = process . env . SCORE_API_URL || 'https://score.snapshot.org' ;
16
16
const broviderUrl = process . env . BROVIDER_URL || 'https://rpc.snapshot.org' ;
@@ -242,9 +242,34 @@ export async function verify(body): Promise<any> {
242
242
if ( msg . payload . choices . length > choicesLimit ) {
243
243
return Promise . reject ( `number of choices can not exceed ${ choicesLimit } ` ) ;
244
244
}
245
+
246
+ let strategiesValue : number [ ] = [ ] ;
247
+
248
+ try {
249
+ strategiesValue = await getStrategiesValue ( {
250
+ network : space . network ,
251
+ start : msg . payload . start ,
252
+ strategies : space . strategies
253
+ } ) ;
254
+
255
+ // Handle unlikely case where strategies value array length does not match strategies length
256
+ if ( strategiesValue . length !== space . strategies . length ) {
257
+ capture ( new Error ( 'Strategies value length mismatch' ) , {
258
+ space : space . id ,
259
+ strategiesLength : space . strategies . length ,
260
+ strategiesValue : JSON . stringify ( strategiesValue )
261
+ } ) ;
262
+ return Promise . reject ( 'failed to get strategies value' ) ;
263
+ }
264
+ } catch ( e : any ) {
265
+ console . log ( 'unable to get strategies value' , e . message ) ;
266
+ return Promise . reject ( 'failed to get strategies value' ) ;
267
+ }
268
+
269
+ return { strategiesValue } ;
245
270
}
246
271
247
- export async function action ( body , ipfs , receipt , id ) : Promise < void > {
272
+ export async function action ( body , ipfs , receipt , id , context ) : Promise < void > {
248
273
const msg = jsonParse ( body . msg ) ;
249
274
const space = msg . space ;
250
275
@@ -302,7 +327,7 @@ export async function action(body, ipfs, receipt, id): Promise<void> {
302
327
scores_state : 'pending' ,
303
328
scores_total : 0 ,
304
329
scores_updated : 0 ,
305
- vp_value_by_strategy : JSON . stringify ( [ ] ) ,
330
+ vp_value_by_strategy : JSON . stringify ( context . strategiesValue ) ,
306
331
votes : 0 ,
307
332
validation,
308
333
flagged : + containsFlaggedLinks ( msg . payload . body )
@@ -317,6 +342,4 @@ export async function action(body, ipfs, receipt, id): Promise<void> {
317
342
` ;
318
343
319
344
await db . queryAsync ( query , [ proposal , space , author , space ] ) ;
320
-
321
- setProposalVpValue ( { ...proposal , strategies : spaceSettings . strategies } ) ;
322
345
}
0 commit comments