@snapshot-labs/snapshot.js 0.9.8 → 0.10.0
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.
- package/dist/index.d.ts +9 -2
- package/dist/schemas/index.d.ts +9 -2
- package/dist/snapshot.cjs.js +54 -6
- package/dist/snapshot.esm.js +54 -6
- package/dist/snapshot.min.js +3 -3
- package/dist/utils.d.ts +5 -3
- package/package.json +1 -1
- package/src/networks.json +3 -3
- package/src/schemas/proposal.json +4 -1
- package/src/schemas/space.json +5 -1
- package/src/utils.ts +51 -2
package/dist/utils.d.ts
CHANGED
|
@@ -31,9 +31,11 @@ export declare function sendTransaction(web3: any, contractAddress: string, abi:
|
|
|
31
31
|
export declare function getScores(space: string, strategies: Strategy[], network: string, addresses: string[], snapshot?: number | string, scoreApiUrl?: string, options?: any): Promise<any>;
|
|
32
32
|
export declare function getVp(address: string, network: string, strategies: Strategy[], snapshot: number | 'latest', space: string, delegation: boolean, options?: Options): Promise<any>;
|
|
33
33
|
export declare function validate(validation: string, author: string, space: string, network: string, snapshot: number | 'latest', params: any, options: any): Promise<any>;
|
|
34
|
-
|
|
35
|
-
snapshotEnv
|
|
36
|
-
|
|
34
|
+
interface validateSchemaOptions {
|
|
35
|
+
snapshotEnv?: string;
|
|
36
|
+
spaceType?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function validateSchema(schema: any, data: any, options?: validateSchemaOptions): true | import("ajv").ErrorObject<string, Record<string, any>, unknown>[] | null | undefined;
|
|
37
39
|
export declare function getEnsTextRecord(ens: string, record: string, network?: string, options?: any): Promise<any>;
|
|
38
40
|
export declare function getSpaceUri(id: string, network?: string, options?: any): Promise<string | null>;
|
|
39
41
|
export declare function getEnsOwner(ens: string, network?: string, options?: any): Promise<string | null>;
|
package/package.json
CHANGED
package/src/networks.json
CHANGED
|
@@ -711,7 +711,7 @@
|
|
|
711
711
|
"url": "https://andromeda-explorer.metis.io"
|
|
712
712
|
},
|
|
713
713
|
"start": 451,
|
|
714
|
-
"logo": "ipfs://
|
|
714
|
+
"logo": "ipfs://bafkreiaqr4atnjpdnk3c4vu4377ai7bzqpgaefefbl5j5imfsvr4puimtu"
|
|
715
715
|
},
|
|
716
716
|
"1101": {
|
|
717
717
|
"key": "1101",
|
|
@@ -735,13 +735,13 @@
|
|
|
735
735
|
"network": "mainnet",
|
|
736
736
|
"multicall": "0x024f0041b76B598c2A0a75004F8447FaF67BD004",
|
|
737
737
|
"rpc": [
|
|
738
|
-
"https://
|
|
738
|
+
"https://rpcar.coredao.org/"
|
|
739
739
|
],
|
|
740
740
|
"explorer": {
|
|
741
741
|
"url": "https://scan.coredao.org"
|
|
742
742
|
},
|
|
743
743
|
"start": 853908,
|
|
744
|
-
"logo": "ipfs://
|
|
744
|
+
"logo": "ipfs://bafkreigjv5yb7uhlrryzib7j2f73nnwqan2tmfnwjdu26vkk365fyesoiu"
|
|
745
745
|
},
|
|
746
746
|
"1284": {
|
|
747
747
|
"key": "1284",
|
package/src/schemas/space.json
CHANGED
package/src/utils.ts
CHANGED
|
@@ -92,6 +92,49 @@ ajv.addKeyword({
|
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
+
ajv.addKeyword({
|
|
96
|
+
keyword: 'maxLengthWithSpaceType',
|
|
97
|
+
validate: function validate(schema, data) {
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
const spaceType = this.spaceType || 'default';
|
|
100
|
+
const isValid = data.length <= schema[spaceType];
|
|
101
|
+
if (!isValid) {
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
validate.errors = [
|
|
104
|
+
{
|
|
105
|
+
keyword: 'maxLengthWithSpaceType',
|
|
106
|
+
message: `must NOT have more than ${schema[spaceType]} characters`,
|
|
107
|
+
params: { limit: schema[spaceType] }
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
return isValid;
|
|
112
|
+
},
|
|
113
|
+
errors: true
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
ajv.addKeyword({
|
|
117
|
+
keyword: 'maxItemsWithSpaceType',
|
|
118
|
+
validate: function validate(schema, data) {
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
const spaceType = this.spaceType || 'default';
|
|
121
|
+
const isValid = data.length <= schema[spaceType];
|
|
122
|
+
if (!isValid) {
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
validate.errors = [
|
|
125
|
+
{
|
|
126
|
+
keyword: 'maxItemsWithSpaceType',
|
|
127
|
+
message: `must NOT have more than ${schema[spaceType]} items`,
|
|
128
|
+
params: { limit: schema[spaceType] }
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
return isValid;
|
|
133
|
+
},
|
|
134
|
+
errors: true
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
|
|
95
138
|
// Custom URL format to allow empty string values
|
|
96
139
|
// https://github.com/snapshot-labs/snapshot.js/pull/541/files
|
|
97
140
|
ajv.addFormat('customUrl', {
|
|
@@ -423,11 +466,17 @@ export async function validate(
|
|
|
423
466
|
}
|
|
424
467
|
}
|
|
425
468
|
|
|
469
|
+
interface validateSchemaOptions {
|
|
470
|
+
snapshotEnv?: string;
|
|
471
|
+
spaceType?: string;
|
|
472
|
+
}
|
|
473
|
+
|
|
426
474
|
export function validateSchema(
|
|
427
475
|
schema,
|
|
428
476
|
data,
|
|
429
|
-
options = {
|
|
430
|
-
snapshotEnv: 'default'
|
|
477
|
+
options: validateSchemaOptions = {
|
|
478
|
+
snapshotEnv: 'default',
|
|
479
|
+
spaceType: 'default'
|
|
431
480
|
}
|
|
432
481
|
) {
|
|
433
482
|
const ajvValidate = ajv.compile(schema);
|