@snapshot-labs/snapshot.js 0.8.3 → 0.9.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 +4 -0
- package/dist/schemas/index.d.ts +4 -0
- package/dist/snapshot.cjs.js +35 -5
- package/dist/snapshot.esm.js +35 -5
- package/dist/snapshot.min.js +2 -2
- package/dist/utils.d.ts +3 -1
- package/package.json +1 -1
- package/src/schemas/space.json +4 -1
- package/src/schemas/zodiac.json +2 -1
- package/src/utils.ts +36 -3
package/dist/index.d.ts
CHANGED
|
@@ -80,6 +80,7 @@ declare const _default: {
|
|
|
80
80
|
};
|
|
81
81
|
network: {
|
|
82
82
|
type: string;
|
|
83
|
+
snapshotNetwork: boolean;
|
|
83
84
|
title: string;
|
|
84
85
|
minLength: number;
|
|
85
86
|
maxLength: number;
|
|
@@ -116,6 +117,7 @@ declare const _default: {
|
|
|
116
117
|
type: string;
|
|
117
118
|
maxLength: number;
|
|
118
119
|
title: string;
|
|
120
|
+
snapshotNetwork: boolean;
|
|
119
121
|
};
|
|
120
122
|
params: {
|
|
121
123
|
type: string;
|
|
@@ -337,6 +339,7 @@ declare const _default: {
|
|
|
337
339
|
};
|
|
338
340
|
network: {
|
|
339
341
|
type: string;
|
|
342
|
+
snapshotNetwork: boolean;
|
|
340
343
|
title: string;
|
|
341
344
|
maxLength: number;
|
|
342
345
|
};
|
|
@@ -554,6 +557,7 @@ declare const _default: {
|
|
|
554
557
|
network: {
|
|
555
558
|
title: string;
|
|
556
559
|
type: string;
|
|
560
|
+
snapshotNetwork: boolean;
|
|
557
561
|
};
|
|
558
562
|
multisend: {
|
|
559
563
|
title: string;
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ declare const _default: {
|
|
|
76
76
|
};
|
|
77
77
|
network: {
|
|
78
78
|
type: string;
|
|
79
|
+
snapshotNetwork: boolean;
|
|
79
80
|
title: string;
|
|
80
81
|
minLength: number;
|
|
81
82
|
maxLength: number;
|
|
@@ -112,6 +113,7 @@ declare const _default: {
|
|
|
112
113
|
type: string;
|
|
113
114
|
maxLength: number;
|
|
114
115
|
title: string;
|
|
116
|
+
snapshotNetwork: boolean;
|
|
115
117
|
};
|
|
116
118
|
params: {
|
|
117
119
|
type: string;
|
|
@@ -333,6 +335,7 @@ declare const _default: {
|
|
|
333
335
|
};
|
|
334
336
|
network: {
|
|
335
337
|
type: string;
|
|
338
|
+
snapshotNetwork: boolean;
|
|
336
339
|
title: string;
|
|
337
340
|
maxLength: number;
|
|
338
341
|
};
|
|
@@ -550,6 +553,7 @@ declare const _default: {
|
|
|
550
553
|
network: {
|
|
551
554
|
title: string;
|
|
552
555
|
type: string;
|
|
556
|
+
snapshotNetwork: boolean;
|
|
553
557
|
};
|
|
554
558
|
multisend: {
|
|
555
559
|
title: string;
|
package/dist/snapshot.cjs.js
CHANGED
|
@@ -650,6 +650,7 @@ var definitions = {
|
|
|
650
650
|
},
|
|
651
651
|
network: {
|
|
652
652
|
type: "string",
|
|
653
|
+
snapshotNetwork: true,
|
|
653
654
|
title: "network",
|
|
654
655
|
minLength: 1,
|
|
655
656
|
maxLength: 32
|
|
@@ -685,7 +686,8 @@ var definitions = {
|
|
|
685
686
|
network: {
|
|
686
687
|
type: "string",
|
|
687
688
|
maxLength: 12,
|
|
688
|
-
title: "network"
|
|
689
|
+
title: "network",
|
|
690
|
+
snapshotNetwork: true
|
|
689
691
|
},
|
|
690
692
|
params: {
|
|
691
693
|
type: "object",
|
|
@@ -941,6 +943,7 @@ var definitions = {
|
|
|
941
943
|
},
|
|
942
944
|
network: {
|
|
943
945
|
type: "string",
|
|
946
|
+
snapshotNetwork: true,
|
|
944
947
|
title: "Network",
|
|
945
948
|
maxLength: 12
|
|
946
949
|
}
|
|
@@ -1269,7 +1272,8 @@ var definitions$6 = {
|
|
|
1269
1272
|
properties: {
|
|
1270
1273
|
network: {
|
|
1271
1274
|
title: "Network",
|
|
1272
|
-
type: "string"
|
|
1275
|
+
type: "string",
|
|
1276
|
+
snapshotNetwork: true
|
|
1273
1277
|
},
|
|
1274
1278
|
multisend: {
|
|
1275
1279
|
title: "Multisend contract address",
|
|
@@ -3430,7 +3434,12 @@ var scoreApiHeaders = {
|
|
|
3430
3434
|
Accept: 'application/json',
|
|
3431
3435
|
'Content-Type': 'application/json'
|
|
3432
3436
|
};
|
|
3433
|
-
var ajv = new Ajv__default['default']({
|
|
3437
|
+
var ajv = new Ajv__default['default']({
|
|
3438
|
+
allErrors: true,
|
|
3439
|
+
allowUnionTypes: true,
|
|
3440
|
+
$data: true,
|
|
3441
|
+
passContext: true
|
|
3442
|
+
});
|
|
3434
3443
|
// @ts-ignore
|
|
3435
3444
|
addFormats__default['default'](ajv);
|
|
3436
3445
|
ajv.addFormat('address', {
|
|
@@ -3459,6 +3468,24 @@ ajv.addFormat('ethValue', {
|
|
|
3459
3468
|
}
|
|
3460
3469
|
}
|
|
3461
3470
|
});
|
|
3471
|
+
var networksIds = Object.keys(networks);
|
|
3472
|
+
var mainnetNetworkIds = Object.keys(networks).filter(function (id) { return !networks[id].testnet; });
|
|
3473
|
+
var testnetNetworkIds = Object.keys(networks).filter(function (id) { return networks[id].testnet; });
|
|
3474
|
+
ajv.addKeyword({
|
|
3475
|
+
keyword: 'snapshotNetwork',
|
|
3476
|
+
validate: function (schema, data) {
|
|
3477
|
+
// @ts-ignore
|
|
3478
|
+
var snapshotEnv = this.snapshotEnv || 'default';
|
|
3479
|
+
if (snapshotEnv === 'mainnet')
|
|
3480
|
+
return mainnetNetworkIds.includes(data);
|
|
3481
|
+
if (snapshotEnv === 'testnet')
|
|
3482
|
+
return testnetNetworkIds.includes(data);
|
|
3483
|
+
return networksIds.includes(data);
|
|
3484
|
+
},
|
|
3485
|
+
error: {
|
|
3486
|
+
message: 'must be a valid network used by snapshot'
|
|
3487
|
+
}
|
|
3488
|
+
});
|
|
3462
3489
|
// Custom URL format to allow empty string values
|
|
3463
3490
|
// https://github.com/snapshot-labs/snapshot.js/pull/541/files
|
|
3464
3491
|
ajv.addFormat('customUrl', {
|
|
@@ -3774,9 +3801,12 @@ function validate(validation, author, space, network, snapshot, params, options)
|
|
|
3774
3801
|
});
|
|
3775
3802
|
});
|
|
3776
3803
|
}
|
|
3777
|
-
function validateSchema(schema, data) {
|
|
3804
|
+
function validateSchema(schema, data, options) {
|
|
3805
|
+
if (options === void 0) { options = {
|
|
3806
|
+
snapshotEnv: 'default'
|
|
3807
|
+
}; }
|
|
3778
3808
|
var ajvValidate = ajv.compile(schema);
|
|
3779
|
-
var valid = ajvValidate(data);
|
|
3809
|
+
var valid = ajvValidate.call(options, data);
|
|
3780
3810
|
return valid ? valid : ajvValidate.errors;
|
|
3781
3811
|
}
|
|
3782
3812
|
function getEnsTextRecord(ens, record, network, options) {
|
package/dist/snapshot.esm.js
CHANGED
|
@@ -641,6 +641,7 @@ var definitions = {
|
|
|
641
641
|
},
|
|
642
642
|
network: {
|
|
643
643
|
type: "string",
|
|
644
|
+
snapshotNetwork: true,
|
|
644
645
|
title: "network",
|
|
645
646
|
minLength: 1,
|
|
646
647
|
maxLength: 32
|
|
@@ -676,7 +677,8 @@ var definitions = {
|
|
|
676
677
|
network: {
|
|
677
678
|
type: "string",
|
|
678
679
|
maxLength: 12,
|
|
679
|
-
title: "network"
|
|
680
|
+
title: "network",
|
|
681
|
+
snapshotNetwork: true
|
|
680
682
|
},
|
|
681
683
|
params: {
|
|
682
684
|
type: "object",
|
|
@@ -932,6 +934,7 @@ var definitions = {
|
|
|
932
934
|
},
|
|
933
935
|
network: {
|
|
934
936
|
type: "string",
|
|
937
|
+
snapshotNetwork: true,
|
|
935
938
|
title: "Network",
|
|
936
939
|
maxLength: 12
|
|
937
940
|
}
|
|
@@ -1260,7 +1263,8 @@ var definitions$6 = {
|
|
|
1260
1263
|
properties: {
|
|
1261
1264
|
network: {
|
|
1262
1265
|
title: "Network",
|
|
1263
|
-
type: "string"
|
|
1266
|
+
type: "string",
|
|
1267
|
+
snapshotNetwork: true
|
|
1264
1268
|
},
|
|
1265
1269
|
multisend: {
|
|
1266
1270
|
title: "Multisend contract address",
|
|
@@ -3421,7 +3425,12 @@ var scoreApiHeaders = {
|
|
|
3421
3425
|
Accept: 'application/json',
|
|
3422
3426
|
'Content-Type': 'application/json'
|
|
3423
3427
|
};
|
|
3424
|
-
var ajv = new Ajv({
|
|
3428
|
+
var ajv = new Ajv({
|
|
3429
|
+
allErrors: true,
|
|
3430
|
+
allowUnionTypes: true,
|
|
3431
|
+
$data: true,
|
|
3432
|
+
passContext: true
|
|
3433
|
+
});
|
|
3425
3434
|
// @ts-ignore
|
|
3426
3435
|
addFormats(ajv);
|
|
3427
3436
|
ajv.addFormat('address', {
|
|
@@ -3450,6 +3459,24 @@ ajv.addFormat('ethValue', {
|
|
|
3450
3459
|
}
|
|
3451
3460
|
}
|
|
3452
3461
|
});
|
|
3462
|
+
var networksIds = Object.keys(networks);
|
|
3463
|
+
var mainnetNetworkIds = Object.keys(networks).filter(function (id) { return !networks[id].testnet; });
|
|
3464
|
+
var testnetNetworkIds = Object.keys(networks).filter(function (id) { return networks[id].testnet; });
|
|
3465
|
+
ajv.addKeyword({
|
|
3466
|
+
keyword: 'snapshotNetwork',
|
|
3467
|
+
validate: function (schema, data) {
|
|
3468
|
+
// @ts-ignore
|
|
3469
|
+
var snapshotEnv = this.snapshotEnv || 'default';
|
|
3470
|
+
if (snapshotEnv === 'mainnet')
|
|
3471
|
+
return mainnetNetworkIds.includes(data);
|
|
3472
|
+
if (snapshotEnv === 'testnet')
|
|
3473
|
+
return testnetNetworkIds.includes(data);
|
|
3474
|
+
return networksIds.includes(data);
|
|
3475
|
+
},
|
|
3476
|
+
error: {
|
|
3477
|
+
message: 'must be a valid network used by snapshot'
|
|
3478
|
+
}
|
|
3479
|
+
});
|
|
3453
3480
|
// Custom URL format to allow empty string values
|
|
3454
3481
|
// https://github.com/snapshot-labs/snapshot.js/pull/541/files
|
|
3455
3482
|
ajv.addFormat('customUrl', {
|
|
@@ -3765,9 +3792,12 @@ function validate(validation, author, space, network, snapshot, params, options)
|
|
|
3765
3792
|
});
|
|
3766
3793
|
});
|
|
3767
3794
|
}
|
|
3768
|
-
function validateSchema(schema, data) {
|
|
3795
|
+
function validateSchema(schema, data, options) {
|
|
3796
|
+
if (options === void 0) { options = {
|
|
3797
|
+
snapshotEnv: 'default'
|
|
3798
|
+
}; }
|
|
3769
3799
|
var ajvValidate = ajv.compile(schema);
|
|
3770
|
-
var valid = ajvValidate(data);
|
|
3800
|
+
var valid = ajvValidate.call(options, data);
|
|
3771
3801
|
return valid ? valid : ajvValidate.errors;
|
|
3772
3802
|
}
|
|
3773
3803
|
function getEnsTextRecord(ens, record, network, options) {
|