@snapshot-labs/snapshot.js 0.12.22 → 0.12.24
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/snapshot.cjs.js +58 -9
- package/dist/snapshot.esm.js +58 -9
- package/dist/snapshot.min.js +2 -2
- package/dist/src/index.d.ts +21 -6
- package/dist/src/schemas/index.d.ts +21 -6
- package/package.json +1 -1
- package/src/schemas/space.json +20 -10
- package/src/utils.ts +28 -0
package/dist/src/index.d.ts
CHANGED
|
@@ -258,18 +258,26 @@ declare const _default: {
|
|
|
258
258
|
};
|
|
259
259
|
delegationContract: {
|
|
260
260
|
type: string;
|
|
261
|
-
format: string;
|
|
262
261
|
title: string;
|
|
263
262
|
description: string;
|
|
264
263
|
examples: string[];
|
|
264
|
+
anyOf: {
|
|
265
|
+
format: string;
|
|
266
|
+
}[];
|
|
267
|
+
errorMessage: string;
|
|
265
268
|
};
|
|
266
269
|
delegationNetwork: {
|
|
267
270
|
type: string;
|
|
268
|
-
snapshotNetwork: boolean;
|
|
269
271
|
title: string;
|
|
270
|
-
minLength: number;
|
|
271
|
-
maxLength: number;
|
|
272
272
|
description: string;
|
|
273
|
+
anyOf: ({
|
|
274
|
+
snapshotNetwork: boolean;
|
|
275
|
+
starknetNetwork?: undefined;
|
|
276
|
+
} | {
|
|
277
|
+
starknetNetwork: boolean;
|
|
278
|
+
snapshotNetwork?: undefined;
|
|
279
|
+
})[];
|
|
280
|
+
errorMessage: string;
|
|
273
281
|
};
|
|
274
282
|
delegationApi: {
|
|
275
283
|
type: string;
|
|
@@ -364,12 +372,19 @@ declare const _default: {
|
|
|
364
372
|
anyOf: {
|
|
365
373
|
format: string;
|
|
366
374
|
}[];
|
|
375
|
+
errorMessage: string;
|
|
367
376
|
};
|
|
368
377
|
network: {
|
|
369
378
|
type: string;
|
|
370
|
-
snapshotNetwork: boolean;
|
|
371
379
|
title: string;
|
|
372
|
-
|
|
380
|
+
anyOf: ({
|
|
381
|
+
snapshotNetwork: boolean;
|
|
382
|
+
starknetNetwork?: undefined;
|
|
383
|
+
} | {
|
|
384
|
+
starknetNetwork: boolean;
|
|
385
|
+
snapshotNetwork?: undefined;
|
|
386
|
+
})[];
|
|
387
|
+
errorMessage: string;
|
|
373
388
|
};
|
|
374
389
|
};
|
|
375
390
|
required: string[];
|
|
@@ -254,18 +254,26 @@ declare const _default: {
|
|
|
254
254
|
};
|
|
255
255
|
delegationContract: {
|
|
256
256
|
type: string;
|
|
257
|
-
format: string;
|
|
258
257
|
title: string;
|
|
259
258
|
description: string;
|
|
260
259
|
examples: string[];
|
|
260
|
+
anyOf: {
|
|
261
|
+
format: string;
|
|
262
|
+
}[];
|
|
263
|
+
errorMessage: string;
|
|
261
264
|
};
|
|
262
265
|
delegationNetwork: {
|
|
263
266
|
type: string;
|
|
264
|
-
snapshotNetwork: boolean;
|
|
265
267
|
title: string;
|
|
266
|
-
minLength: number;
|
|
267
|
-
maxLength: number;
|
|
268
268
|
description: string;
|
|
269
|
+
anyOf: ({
|
|
270
|
+
snapshotNetwork: boolean;
|
|
271
|
+
starknetNetwork?: undefined;
|
|
272
|
+
} | {
|
|
273
|
+
starknetNetwork: boolean;
|
|
274
|
+
snapshotNetwork?: undefined;
|
|
275
|
+
})[];
|
|
276
|
+
errorMessage: string;
|
|
269
277
|
};
|
|
270
278
|
delegationApi: {
|
|
271
279
|
type: string;
|
|
@@ -360,12 +368,19 @@ declare const _default: {
|
|
|
360
368
|
anyOf: {
|
|
361
369
|
format: string;
|
|
362
370
|
}[];
|
|
371
|
+
errorMessage: string;
|
|
363
372
|
};
|
|
364
373
|
network: {
|
|
365
374
|
type: string;
|
|
366
|
-
snapshotNetwork: boolean;
|
|
367
375
|
title: string;
|
|
368
|
-
|
|
376
|
+
anyOf: ({
|
|
377
|
+
snapshotNetwork: boolean;
|
|
378
|
+
starknetNetwork?: undefined;
|
|
379
|
+
} | {
|
|
380
|
+
starknetNetwork: boolean;
|
|
381
|
+
snapshotNetwork?: undefined;
|
|
382
|
+
})[];
|
|
383
|
+
errorMessage: string;
|
|
369
384
|
};
|
|
370
385
|
};
|
|
371
386
|
required: string[];
|
package/package.json
CHANGED
package/src/schemas/space.json
CHANGED
|
@@ -258,18 +258,24 @@
|
|
|
258
258
|
},
|
|
259
259
|
"delegationContract": {
|
|
260
260
|
"type": "string",
|
|
261
|
-
"format": "evmAddress",
|
|
262
261
|
"title": "Contract address",
|
|
263
262
|
"description": "The address of your delegation contract",
|
|
264
|
-
"examples": ["0x3901D0fDe202aF1427216b79f5243f8A022d68cf"]
|
|
263
|
+
"examples": ["0x3901D0fDe202aF1427216b79f5243f8A022d68cf"],
|
|
264
|
+
"anyOf": [
|
|
265
|
+
{ "format": "evmAddress" },
|
|
266
|
+
{ "format": "starknetAddress" }
|
|
267
|
+
],
|
|
268
|
+
"errorMessage": "Must be a valid EVM of Starknet address"
|
|
265
269
|
},
|
|
266
270
|
"delegationNetwork": {
|
|
267
271
|
"type": "string",
|
|
268
|
-
"snapshotNetwork": true,
|
|
269
272
|
"title": "Delegation network",
|
|
270
|
-
"
|
|
271
|
-
"
|
|
272
|
-
|
|
273
|
+
"description": "The network of your delegation contract",
|
|
274
|
+
"anyOf": [
|
|
275
|
+
{ "snapshotNetwork": true },
|
|
276
|
+
{ "starknetNetwork": true }
|
|
277
|
+
],
|
|
278
|
+
"errorMessage": "Must be a valid network"
|
|
273
279
|
},
|
|
274
280
|
"delegationApi": {
|
|
275
281
|
"type": "string",
|
|
@@ -281,7 +287,7 @@
|
|
|
281
287
|
]
|
|
282
288
|
}
|
|
283
289
|
},
|
|
284
|
-
"required": ["delegationType", "delegationApi", "delegationContract"],
|
|
290
|
+
"required": ["delegationType", "delegationNetwork", "delegationApi", "delegationContract"],
|
|
285
291
|
"additionalProperties": false
|
|
286
292
|
},
|
|
287
293
|
"allowAlias": {
|
|
@@ -375,13 +381,17 @@
|
|
|
375
381
|
"anyOf": [
|
|
376
382
|
{ "format": "evmAddress" },
|
|
377
383
|
{ "format": "starknetAddress" }
|
|
378
|
-
]
|
|
384
|
+
],
|
|
385
|
+
"errorMessage": "Must be a valid EVM of Starknet address"
|
|
379
386
|
},
|
|
380
387
|
"network": {
|
|
381
388
|
"type": "string",
|
|
382
|
-
"snapshotNetwork": true,
|
|
383
389
|
"title": "Network",
|
|
384
|
-
"
|
|
390
|
+
"anyOf": [
|
|
391
|
+
{ "snapshotNetwork": true },
|
|
392
|
+
{ "starknetNetwork": true }
|
|
393
|
+
],
|
|
394
|
+
"errorMessage": "Must be a valid network"
|
|
385
395
|
}
|
|
386
396
|
},
|
|
387
397
|
"required": ["name", "address", "network"],
|
package/src/utils.ts
CHANGED
|
@@ -36,6 +36,16 @@ const ENS_ABI = [
|
|
|
36
36
|
'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
|
|
37
37
|
];
|
|
38
38
|
const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
|
|
39
|
+
const STARKNET_NETWORKS = {
|
|
40
|
+
'0x534e5f4d41494e': {
|
|
41
|
+
name: 'Starknet',
|
|
42
|
+
testnet: false
|
|
43
|
+
},
|
|
44
|
+
'0x534e5f5345504f4c4941': {
|
|
45
|
+
name: 'Starknet Sepolia',
|
|
46
|
+
testnet: true
|
|
47
|
+
}
|
|
48
|
+
};
|
|
39
49
|
|
|
40
50
|
const scoreApiHeaders = {
|
|
41
51
|
Accept: 'application/json',
|
|
@@ -166,6 +176,24 @@ ajv.addKeyword({
|
|
|
166
176
|
}
|
|
167
177
|
});
|
|
168
178
|
|
|
179
|
+
ajv.addKeyword({
|
|
180
|
+
keyword: 'starknetNetwork',
|
|
181
|
+
validate: function (schema, data) {
|
|
182
|
+
// @ts-ignore
|
|
183
|
+
const snapshotEnv = this.snapshotEnv || 'default';
|
|
184
|
+
if (snapshotEnv === 'mainnet') {
|
|
185
|
+
return Object.keys(STARKNET_NETWORKS)
|
|
186
|
+
.filter((id) => !STARKNET_NETWORKS[id].testnet)
|
|
187
|
+
.includes(data);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return Object.keys(STARKNET_NETWORKS).includes(data);
|
|
191
|
+
},
|
|
192
|
+
error: {
|
|
193
|
+
message: 'network not allowed'
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
169
197
|
ajv.addKeyword({
|
|
170
198
|
keyword: 'maxLengthWithSpaceType',
|
|
171
199
|
validate: function validate(schema, data) {
|