@snapshot-labs/snapshot.js 0.12.44 → 0.12.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -94,7 +94,6 @@ declare const _default: {
94
94
  symbol: {
95
95
  type: string;
96
96
  title: string;
97
- minLength: number;
98
97
  maxLength: number;
99
98
  };
100
99
  skin: {
@@ -122,10 +121,6 @@ declare const _default: {
122
121
  strategies: {
123
122
  type: string;
124
123
  minItems: number;
125
- maxItemsWithSpaceType: {
126
- default: number;
127
- turbo: number;
128
- };
129
124
  uniqueItems: boolean;
130
125
  items: {
131
126
  type: string;
@@ -460,6 +455,54 @@ declare const _default: {
460
455
  required: string[];
461
456
  additionalProperties: boolean;
462
457
  };
458
+ skinSettings: {
459
+ type: string;
460
+ properties: {
461
+ bg_color: {
462
+ type: string;
463
+ format: string;
464
+ };
465
+ link_color: {
466
+ type: string;
467
+ format: string;
468
+ };
469
+ text_color: {
470
+ type: string;
471
+ format: string;
472
+ };
473
+ content_color: {
474
+ type: string;
475
+ format: string;
476
+ };
477
+ border_color: {
478
+ type: string;
479
+ format: string;
480
+ };
481
+ heading_color: {
482
+ type: string;
483
+ format: string;
484
+ };
485
+ primary_color: {
486
+ type: string;
487
+ format: string;
488
+ };
489
+ header_color: {
490
+ type: string;
491
+ format: string;
492
+ };
493
+ theme: {
494
+ type: string;
495
+ enum: string[];
496
+ };
497
+ logo: {
498
+ type: string;
499
+ title: string;
500
+ format: string;
501
+ maxLength: number;
502
+ };
503
+ };
504
+ additionalProperties: boolean;
505
+ };
463
506
  };
464
507
  required: string[];
465
508
  additionalProperties: boolean;
@@ -478,10 +521,6 @@ declare const _default: {
478
521
  type: string;
479
522
  title: string;
480
523
  minLength: number;
481
- maxLengthWithSpaceType: {
482
- default: number;
483
- turbo: number;
484
- };
485
524
  };
486
525
  discussion: {
487
526
  type: string;
@@ -493,10 +532,6 @@ declare const _default: {
493
532
  type: string;
494
533
  title: string;
495
534
  minItems: number;
496
- maxLengthWithSpaceType: {
497
- default: number;
498
- turbo: number;
499
- };
500
535
  };
501
536
  labels: {
502
537
  type: string;
@@ -565,10 +600,6 @@ declare const _default: {
565
600
  type: string;
566
601
  title: string;
567
602
  minLength: number;
568
- maxLengthWithSpaceType: {
569
- default: number;
570
- turbo: number;
571
- };
572
603
  };
573
604
  discussion: {
574
605
  type: string;
@@ -580,10 +611,6 @@ declare const _default: {
580
611
  type: string;
581
612
  title: string;
582
613
  minItems: number;
583
- maxLengthWithSpaceType: {
584
- default: number;
585
- turbo: number;
586
- };
587
614
  };
588
615
  labels: {
589
616
  type: string;
@@ -90,7 +90,6 @@ declare const _default: {
90
90
  symbol: {
91
91
  type: string;
92
92
  title: string;
93
- minLength: number;
94
93
  maxLength: number;
95
94
  };
96
95
  skin: {
@@ -118,10 +117,6 @@ declare const _default: {
118
117
  strategies: {
119
118
  type: string;
120
119
  minItems: number;
121
- maxItemsWithSpaceType: {
122
- default: number;
123
- turbo: number;
124
- };
125
120
  uniqueItems: boolean;
126
121
  items: {
127
122
  type: string;
@@ -456,6 +451,54 @@ declare const _default: {
456
451
  required: string[];
457
452
  additionalProperties: boolean;
458
453
  };
454
+ skinSettings: {
455
+ type: string;
456
+ properties: {
457
+ bg_color: {
458
+ type: string;
459
+ format: string;
460
+ };
461
+ link_color: {
462
+ type: string;
463
+ format: string;
464
+ };
465
+ text_color: {
466
+ type: string;
467
+ format: string;
468
+ };
469
+ content_color: {
470
+ type: string;
471
+ format: string;
472
+ };
473
+ border_color: {
474
+ type: string;
475
+ format: string;
476
+ };
477
+ heading_color: {
478
+ type: string;
479
+ format: string;
480
+ };
481
+ primary_color: {
482
+ type: string;
483
+ format: string;
484
+ };
485
+ header_color: {
486
+ type: string;
487
+ format: string;
488
+ };
489
+ theme: {
490
+ type: string;
491
+ enum: string[];
492
+ };
493
+ logo: {
494
+ type: string;
495
+ title: string;
496
+ format: string;
497
+ maxLength: number;
498
+ };
499
+ };
500
+ additionalProperties: boolean;
501
+ };
459
502
  };
460
503
  required: string[];
461
504
  additionalProperties: boolean;
@@ -474,10 +517,6 @@ declare const _default: {
474
517
  type: string;
475
518
  title: string;
476
519
  minLength: number;
477
- maxLengthWithSpaceType: {
478
- default: number;
479
- turbo: number;
480
- };
481
520
  };
482
521
  discussion: {
483
522
  type: string;
@@ -489,10 +528,6 @@ declare const _default: {
489
528
  type: string;
490
529
  title: string;
491
530
  minItems: number;
492
- maxLengthWithSpaceType: {
493
- default: number;
494
- turbo: number;
495
- };
496
531
  };
497
532
  labels: {
498
533
  type: string;
@@ -561,10 +596,6 @@ declare const _default: {
561
596
  type: string;
562
597
  title: string;
563
598
  minLength: number;
564
- maxLengthWithSpaceType: {
565
- default: number;
566
- turbo: number;
567
- };
568
599
  };
569
600
  discussion: {
570
601
  type: string;
@@ -576,10 +607,6 @@ declare const _default: {
576
607
  type: string;
577
608
  title: string;
578
609
  minItems: number;
579
- maxLengthWithSpaceType: {
580
- default: number;
581
- turbo: number;
582
- };
583
610
  };
584
611
  labels: {
585
612
  type: string;
@@ -1,5 +1,6 @@
1
1
  export type ProviderOptions = {
2
2
  broviderUrl?: string;
3
+ timeout?: number;
3
4
  };
4
- export default function getProvider(network: any, { broviderUrl }?: ProviderOptions): any;
5
- export declare function getBatchedProvider(network: any, { broviderUrl }?: ProviderOptions): any;
5
+ export default function getProvider(network: any, { broviderUrl, timeout }?: ProviderOptions): any;
6
+ export declare function getBatchedProvider(network: any, { broviderUrl, timeout }?: ProviderOptions): any;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snapshot-labs/snapshot.js",
3
- "version": "0.12.44",
3
+ "version": "0.12.46",
4
4
  "repository": "snapshot-labs/snapshot.js",
5
5
  "license": "MIT",
6
6
  "main": "dist/snapshot.cjs.js",
@@ -15,11 +15,7 @@
15
15
  "body": {
16
16
  "type": "string",
17
17
  "title": "body",
18
- "minLength": 0,
19
- "maxLengthWithSpaceType": {
20
- "default": 10000,
21
- "turbo": 40000
22
- }
18
+ "minLength": 0
23
19
  },
24
20
  "discussion": {
25
21
  "type": "string",
@@ -30,11 +26,7 @@
30
26
  "choices": {
31
27
  "type": "array",
32
28
  "title": "choices",
33
- "minItems": 1,
34
- "maxLengthWithSpaceType": {
35
- "default": 500,
36
- "turbo": 1000
37
- }
29
+ "minItems": 1
38
30
  },
39
31
  "labels": {
40
32
  "type": "array",
@@ -93,7 +93,6 @@
93
93
  "symbol": {
94
94
  "type": "string",
95
95
  "title": "symbol",
96
- "minLength": 1,
97
96
  "maxLength": 16
98
97
  },
99
98
  "skin": {
@@ -121,10 +120,6 @@
121
120
  "strategies": {
122
121
  "type": "array",
123
122
  "minItems": 1,
124
- "maxItemsWithSpaceType": {
125
- "default": 8,
126
- "turbo": 10
127
- },
128
123
  "uniqueItems": true,
129
124
  "items": {
130
125
  "type": "object",
@@ -475,6 +470,54 @@
475
470
  },
476
471
  "required": ["enabled", "bribeEnabled"],
477
472
  "additionalProperties": false
473
+ },
474
+ "skinSettings": {
475
+ "type": "object",
476
+ "properties": {
477
+ "bg_color": {
478
+ "type": "string",
479
+ "format": "color"
480
+ },
481
+ "link_color": {
482
+ "type": "string",
483
+ "format": "color"
484
+ },
485
+ "text_color": {
486
+ "type": "string",
487
+ "format": "color"
488
+ },
489
+ "content_color": {
490
+ "type": "string",
491
+ "format": "color"
492
+ },
493
+ "border_color" : {
494
+ "type": "string",
495
+ "format": "color"
496
+ },
497
+ "heading_color" : {
498
+ "type": "string",
499
+ "format": "color"
500
+ },
501
+ "primary_color": {
502
+ "type": "string",
503
+ "format": "color"
504
+ },
505
+ "header_color": {
506
+ "type": "string",
507
+ "format": "color"
508
+ },
509
+ "theme": {
510
+ "type": "string",
511
+ "enum": ["light", "dark"]
512
+ },
513
+ "logo": {
514
+ "type": "string",
515
+ "title": "logo",
516
+ "format": "customUrl",
517
+ "maxLength": 256
518
+ }
519
+ },
520
+ "additionalProperties": false
478
521
  }
479
522
  },
480
523
  "required": ["name", "network", "strategies"],
@@ -19,11 +19,7 @@
19
19
  "body": {
20
20
  "type": "string",
21
21
  "title": "body",
22
- "minLength": 0,
23
- "maxLengthWithSpaceType": {
24
- "default": 10000,
25
- "turbo": 20000
26
- }
22
+ "minLength": 0
27
23
  },
28
24
  "discussion": {
29
25
  "type": "string",
@@ -34,11 +30,7 @@
34
30
  "choices": {
35
31
  "type": "array",
36
32
  "title": "choices",
37
- "minItems": 1,
38
- "maxLengthWithSpaceType": {
39
- "default": 500,
40
- "turbo": 1000
41
- }
33
+ "minItems": 1
42
34
  },
43
35
  "labels": {
44
36
  "type": "array",
@@ -8,20 +8,25 @@ const batchedProviders = {};
8
8
 
9
9
  export type ProviderOptions = {
10
10
  broviderUrl?: string;
11
+ timeout?: number;
11
12
  };
12
13
 
13
14
  const DEFAULT_BROVIDER_URL = 'https://rpc.snapshot.org';
15
+ const DEFAULT_TIMEOUT = 25000;
14
16
 
15
17
  export default function getProvider(
16
18
  network,
17
- { broviderUrl = DEFAULT_BROVIDER_URL }: ProviderOptions = {}
19
+ {
20
+ broviderUrl = DEFAULT_BROVIDER_URL,
21
+ timeout = DEFAULT_TIMEOUT
22
+ }: ProviderOptions = {}
18
23
  ) {
19
24
  const url = `${broviderUrl}/${network}`;
20
25
  if (!providers[network])
21
26
  providers[network] = new StaticJsonRpcProvider(
22
27
  {
23
28
  url,
24
- timeout: 25000,
29
+ timeout,
25
30
  allowGzip: true
26
31
  },
27
32
  Number(network)
@@ -31,13 +36,16 @@ export default function getProvider(
31
36
 
32
37
  export function getBatchedProvider(
33
38
  network,
34
- { broviderUrl = DEFAULT_BROVIDER_URL }: ProviderOptions = {}
39
+ {
40
+ broviderUrl = DEFAULT_BROVIDER_URL,
41
+ timeout = DEFAULT_TIMEOUT
42
+ }: ProviderOptions = {}
35
43
  ) {
36
44
  const url = `${broviderUrl}/${network}`;
37
45
  if (!batchedProviders[network])
38
46
  batchedProviders[network] = new JsonRpcBatchProvider({
39
47
  url,
40
- timeout: 25000,
48
+ timeout,
41
49
  allowGzip: true
42
50
  });
43
51
  return batchedProviders[network];
package/src/utils.ts CHANGED
@@ -194,48 +194,6 @@ ajv.addKeyword({
194
194
  }
195
195
  });
196
196
 
197
- ajv.addKeyword({
198
- keyword: 'maxLengthWithSpaceType',
199
- validate: function validate(schema, data) {
200
- // @ts-ignore
201
- const spaceType = this.spaceType || 'default';
202
- const isValid = data.length <= schema[spaceType];
203
- if (!isValid) {
204
- // @ts-ignore
205
- validate.errors = [
206
- {
207
- keyword: 'maxLengthWithSpaceType',
208
- message: `must not have more than ${schema[spaceType]}`,
209
- params: { limit: schema[spaceType] }
210
- }
211
- ];
212
- }
213
- return isValid;
214
- },
215
- errors: true
216
- });
217
-
218
- ajv.addKeyword({
219
- keyword: 'maxItemsWithSpaceType',
220
- validate: function validate(schema, data) {
221
- // @ts-ignore
222
- const spaceType = this.spaceType || 'default';
223
- const isValid = data.length <= schema[spaceType];
224
- if (!isValid) {
225
- // @ts-ignore
226
- validate.errors = [
227
- {
228
- keyword: 'maxItemsWithSpaceType',
229
- message: `must NOT have more than ${schema[spaceType]} items`,
230
- params: { limit: schema[spaceType] }
231
- }
232
- ];
233
- }
234
- return isValid;
235
- },
236
- errors: true
237
- });
238
-
239
197
  // Custom URL format to allow empty string values
240
198
  // https://github.com/snapshot-labs/snapshot.js/pull/541/files
241
199
  ajv.addFormat('customUrl', {