@snapshot-labs/snapshot.js 0.4.96 → 0.4.97
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 +1 -1
- package/dist/schemas/index.d.ts +1 -1
- package/dist/snapshot.cjs.js +28 -1
- package/dist/snapshot.esm.js +28 -1
- package/dist/snapshot.min.js +8 -7
- package/package.json +2 -1
- package/src/schemas/space.json +1 -1
- package/src/utils.ts +28 -0
package/dist/index.d.ts
CHANGED
package/dist/schemas/index.d.ts
CHANGED
package/dist/snapshot.cjs.js
CHANGED
|
@@ -4,6 +4,7 @@ var fetch = require('cross-fetch');
|
|
|
4
4
|
var address = require('@ethersproject/address');
|
|
5
5
|
var abi = require('@ethersproject/abi');
|
|
6
6
|
var contracts = require('@ethersproject/contracts');
|
|
7
|
+
var units = require('@ethersproject/units');
|
|
7
8
|
var ethEnsNamehash = require('@ensdomains/eth-ens-namehash');
|
|
8
9
|
var jsonToGraphqlQuery = require('json-to-graphql-query');
|
|
9
10
|
var Ajv = require('ajv');
|
|
@@ -767,7 +768,7 @@ var definitions = {
|
|
|
767
768
|
},
|
|
768
769
|
delegationContract: {
|
|
769
770
|
type: "string",
|
|
770
|
-
|
|
771
|
+
format: "address",
|
|
771
772
|
title: "Contract address",
|
|
772
773
|
description: "The address of your delegation contract",
|
|
773
774
|
examples: [
|
|
@@ -4023,6 +4024,32 @@ var ENS_RESOLVER_ABI = [
|
|
|
4023
4024
|
var ajv = new Ajv__default['default']({ allErrors: true, allowUnionTypes: true, $data: true });
|
|
4024
4025
|
// @ts-ignore
|
|
4025
4026
|
addFormats__default['default'](ajv);
|
|
4027
|
+
ajv.addFormat('address', {
|
|
4028
|
+
validate: function (value) {
|
|
4029
|
+
try {
|
|
4030
|
+
return address.isAddress(value);
|
|
4031
|
+
}
|
|
4032
|
+
catch (err) {
|
|
4033
|
+
return false;
|
|
4034
|
+
}
|
|
4035
|
+
}
|
|
4036
|
+
});
|
|
4037
|
+
ajv.addFormat('long', {
|
|
4038
|
+
validate: function () { return true; }
|
|
4039
|
+
});
|
|
4040
|
+
ajv.addFormat('ethValue', {
|
|
4041
|
+
validate: function (value) {
|
|
4042
|
+
if (!value.match(/^([0-9]|[1-9][0-9]+)(\.[0-9]+)?$/))
|
|
4043
|
+
return false;
|
|
4044
|
+
try {
|
|
4045
|
+
units.parseUnits(value, 18);
|
|
4046
|
+
return true;
|
|
4047
|
+
}
|
|
4048
|
+
catch (_a) {
|
|
4049
|
+
return false;
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
});
|
|
4026
4053
|
// Custom URL format to allow empty string values
|
|
4027
4054
|
// https://github.com/snapshot-labs/snapshot.js/pull/541/files
|
|
4028
4055
|
ajv.addFormat('customUrl', {
|
package/dist/snapshot.esm.js
CHANGED
|
@@ -2,6 +2,7 @@ import fetch from 'cross-fetch';
|
|
|
2
2
|
import { getAddress, isAddress } from '@ethersproject/address';
|
|
3
3
|
import { Interface } from '@ethersproject/abi';
|
|
4
4
|
import { Contract } from '@ethersproject/contracts';
|
|
5
|
+
import { parseUnits } from '@ethersproject/units';
|
|
5
6
|
import { hash, normalize } from '@ensdomains/eth-ens-namehash';
|
|
6
7
|
import { jsonToGraphQLQuery } from 'json-to-graphql-query';
|
|
7
8
|
import Ajv from 'ajv';
|
|
@@ -758,7 +759,7 @@ var definitions = {
|
|
|
758
759
|
},
|
|
759
760
|
delegationContract: {
|
|
760
761
|
type: "string",
|
|
761
|
-
|
|
762
|
+
format: "address",
|
|
762
763
|
title: "Contract address",
|
|
763
764
|
description: "The address of your delegation contract",
|
|
764
765
|
examples: [
|
|
@@ -4014,6 +4015,32 @@ var ENS_RESOLVER_ABI = [
|
|
|
4014
4015
|
var ajv = new Ajv({ allErrors: true, allowUnionTypes: true, $data: true });
|
|
4015
4016
|
// @ts-ignore
|
|
4016
4017
|
addFormats(ajv);
|
|
4018
|
+
ajv.addFormat('address', {
|
|
4019
|
+
validate: function (value) {
|
|
4020
|
+
try {
|
|
4021
|
+
return isAddress(value);
|
|
4022
|
+
}
|
|
4023
|
+
catch (err) {
|
|
4024
|
+
return false;
|
|
4025
|
+
}
|
|
4026
|
+
}
|
|
4027
|
+
});
|
|
4028
|
+
ajv.addFormat('long', {
|
|
4029
|
+
validate: function () { return true; }
|
|
4030
|
+
});
|
|
4031
|
+
ajv.addFormat('ethValue', {
|
|
4032
|
+
validate: function (value) {
|
|
4033
|
+
if (!value.match(/^([0-9]|[1-9][0-9]+)(\.[0-9]+)?$/))
|
|
4034
|
+
return false;
|
|
4035
|
+
try {
|
|
4036
|
+
parseUnits(value, 18);
|
|
4037
|
+
return true;
|
|
4038
|
+
}
|
|
4039
|
+
catch (_a) {
|
|
4040
|
+
return false;
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
});
|
|
4017
4044
|
// Custom URL format to allow empty string values
|
|
4018
4045
|
// https://github.com/snapshot-labs/snapshot.js/pull/541/files
|
|
4019
4046
|
ajv.addFormat('customUrl', {
|