@@ -5,10 +5,11 @@ import { addOrUpdateSpace, getSpace } from '../helpers/actions';
5
5
import log from '../helpers/log' ;
6
6
import db from '../helpers/mysql' ;
7
7
import { getLimit , getSpaceType } from '../helpers/options' ;
8
- import { clearStampCache , DEFAULT_NETWORK , jsonParse } from '../helpers/utils' ;
8
+ import { clearStampCache , DEFAULT_NETWORK , fetchWithKeepAlive , jsonParse } from '../helpers/utils' ;
9
9
10
10
const SNAPSHOT_ENV = process . env . NETWORK || 'testnet' ;
11
11
const broviderUrl = process . env . BROVIDER_URL || 'https://rpc.snapshot.org' ;
12
+ const scoreAPIUrl = process . env . SCORE_API_URL || 'https://score.snapshot.org' ;
12
13
13
14
export async function validateSpaceSettings ( originalSpace : any ) {
14
15
const spaceType = originalSpace . turbo ? 'turbo' : 'default' ;
@@ -80,6 +81,26 @@ export async function verify(body): Promise<any> {
80
81
return Promise . reject ( `max number of strategies is ${ strategiesLimit } ` ) ;
81
82
}
82
83
84
+ try {
85
+ const strategiesList = await ( await fetchWithKeepAlive ( `${ scoreAPIUrl } /api/strategies` ) ) . json ( ) ;
86
+
87
+ msg . payload . strategies
88
+ . map ( strategy => strategy . name )
89
+ . forEach ( strategyName => {
90
+ const strategy = strategiesList [ strategyName ] ;
91
+
92
+ if ( ! strategy ) {
93
+ return Promise . reject ( `strategy "${ strategyName } " is not a valid strategy` ) ;
94
+ }
95
+
96
+ if ( strategy . disabled ) {
97
+ return Promise . reject ( `strategy "${ strategyName } " has been deprecated` ) ;
98
+ }
99
+ } ) ;
100
+ } catch ( e ) {
101
+ return Promise . reject ( 'failed to validate strategies' ) ;
102
+ }
103
+
83
104
const controller = await snapshot . utils . getSpaceController ( msg . space , DEFAULT_NETWORK , {
84
105
broviderUrl
85
106
} ) ;
0 commit comments