@snapshot-labs/snapshot.js 0.12.21 → 0.12.23

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.
@@ -593,9 +593,7 @@ var definitions = {
593
593
  maxItems: 100,
594
594
  items: {
595
595
  type: "string",
596
- pattern: "^0x[a-fA-F0-9]{40}$",
597
- minLength: 42,
598
- maxLength: 42
596
+ format: "evmAddress"
599
597
  },
600
598
  title: "members",
601
599
  uniqueItems: true
@@ -605,9 +603,7 @@ var definitions = {
605
603
  maxItems: 100,
606
604
  items: {
607
605
  type: "string",
608
- pattern: "^0x[a-fA-F0-9]{40}$",
609
- minLength: 42,
610
- maxLength: 42
606
+ format: "evmAddress"
611
607
  },
612
608
  title: "admins",
613
609
  uniqueItems: true
@@ -617,9 +613,7 @@ var definitions = {
617
613
  maxItems: 100,
618
614
  items: {
619
615
  type: "string",
620
- pattern: "^0x[a-fA-F0-9]{40}$",
621
- minLength: 42,
622
- maxLength: 42
616
+ format: "evmAddress"
623
617
  },
624
618
  title: "moderators",
625
619
  uniqueItems: true
@@ -722,20 +716,32 @@ var definitions = {
722
716
  },
723
717
  delegationContract: {
724
718
  type: "string",
725
- format: "address",
726
719
  title: "Contract address",
727
720
  description: "The address of your delegation contract",
728
721
  examples: [
729
722
  "0x3901D0fDe202aF1427216b79f5243f8A022d68cf"
723
+ ],
724
+ anyOf: [
725
+ {
726
+ format: "evmAddress"
727
+ },
728
+ {
729
+ format: "starknetAddress"
730
+ }
730
731
  ]
731
732
  },
732
733
  delegationNetwork: {
733
734
  type: "string",
734
- snapshotNetwork: true,
735
735
  title: "Delegation network",
736
- minLength: 1,
737
- maxLength: 32,
738
- description: "The network of your delegation contract"
736
+ description: "The network of your delegation contract",
737
+ anyOf: [
738
+ {
739
+ snapshotNetwork: true
740
+ },
741
+ {
742
+ starknetNetwork: true
743
+ }
744
+ ]
739
745
  },
740
746
  delegationApi: {
741
747
  type: "string",
@@ -749,6 +755,7 @@ var definitions = {
749
755
  },
750
756
  required: [
751
757
  "delegationType",
758
+ "delegationNetwork",
752
759
  "delegationApi",
753
760
  "delegationContract"
754
761
  ],
@@ -853,7 +860,7 @@ var definitions = {
853
860
  ],
854
861
  anyOf: [
855
862
  {
856
- format: "address"
863
+ format: "evmAddress"
857
864
  },
858
865
  {
859
866
  format: "starknetAddress"
@@ -862,9 +869,15 @@ var definitions = {
862
869
  },
863
870
  network: {
864
871
  type: "string",
865
- snapshotNetwork: true,
866
872
  title: "Network",
867
- maxLength: 12
873
+ anyOf: [
874
+ {
875
+ snapshotNetwork: true
876
+ },
877
+ {
878
+ starknetNetwork: true
879
+ }
880
+ ]
868
881
  }
869
882
  },
870
883
  required: [
@@ -3863,6 +3876,7 @@ const ENS_ABI = [
3863
3876
  'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
3864
3877
  ];
3865
3878
  const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
3879
+ const STARKNET_NETWORKS = ['0x534e5f4d41494e', '0x534e5f5345504f4c4941'];
3866
3880
  const scoreApiHeaders = {
3867
3881
  Accept: 'application/json',
3868
3882
  'Content-Type': 'application/json'
@@ -3922,6 +3936,17 @@ ajv.addFormat('address', {
3922
3936
  }
3923
3937
  }
3924
3938
  });
3939
+ ajv.addFormat('evmAddress', {
3940
+ validate: (value) => {
3941
+ try {
3942
+ address.getAddress(value);
3943
+ return true;
3944
+ }
3945
+ catch (e) {
3946
+ return false;
3947
+ }
3948
+ }
3949
+ });
3925
3950
  ajv.addFormat('starknetAddress', {
3926
3951
  validate: (value) => {
3927
3952
  try {
@@ -3973,6 +3998,15 @@ ajv.addKeyword({
3973
3998
  message: 'network not allowed'
3974
3999
  }
3975
4000
  });
4001
+ ajv.addKeyword({
4002
+ keyword: 'starknetNetwork',
4003
+ validate: function (schema, data) {
4004
+ return STARKNET_NETWORKS.includes(data);
4005
+ },
4006
+ error: {
4007
+ message: 'network not allowed'
4008
+ }
4009
+ });
3976
4010
  ajv.addKeyword({
3977
4011
  keyword: 'maxLengthWithSpaceType',
3978
4012
  validate: function validate(schema, data) {
@@ -583,9 +583,7 @@ var definitions = {
583
583
  maxItems: 100,
584
584
  items: {
585
585
  type: "string",
586
- pattern: "^0x[a-fA-F0-9]{40}$",
587
- minLength: 42,
588
- maxLength: 42
586
+ format: "evmAddress"
589
587
  },
590
588
  title: "members",
591
589
  uniqueItems: true
@@ -595,9 +593,7 @@ var definitions = {
595
593
  maxItems: 100,
596
594
  items: {
597
595
  type: "string",
598
- pattern: "^0x[a-fA-F0-9]{40}$",
599
- minLength: 42,
600
- maxLength: 42
596
+ format: "evmAddress"
601
597
  },
602
598
  title: "admins",
603
599
  uniqueItems: true
@@ -607,9 +603,7 @@ var definitions = {
607
603
  maxItems: 100,
608
604
  items: {
609
605
  type: "string",
610
- pattern: "^0x[a-fA-F0-9]{40}$",
611
- minLength: 42,
612
- maxLength: 42
606
+ format: "evmAddress"
613
607
  },
614
608
  title: "moderators",
615
609
  uniqueItems: true
@@ -712,20 +706,32 @@ var definitions = {
712
706
  },
713
707
  delegationContract: {
714
708
  type: "string",
715
- format: "address",
716
709
  title: "Contract address",
717
710
  description: "The address of your delegation contract",
718
711
  examples: [
719
712
  "0x3901D0fDe202aF1427216b79f5243f8A022d68cf"
713
+ ],
714
+ anyOf: [
715
+ {
716
+ format: "evmAddress"
717
+ },
718
+ {
719
+ format: "starknetAddress"
720
+ }
720
721
  ]
721
722
  },
722
723
  delegationNetwork: {
723
724
  type: "string",
724
- snapshotNetwork: true,
725
725
  title: "Delegation network",
726
- minLength: 1,
727
- maxLength: 32,
728
- description: "The network of your delegation contract"
726
+ description: "The network of your delegation contract",
727
+ anyOf: [
728
+ {
729
+ snapshotNetwork: true
730
+ },
731
+ {
732
+ starknetNetwork: true
733
+ }
734
+ ]
729
735
  },
730
736
  delegationApi: {
731
737
  type: "string",
@@ -739,6 +745,7 @@ var definitions = {
739
745
  },
740
746
  required: [
741
747
  "delegationType",
748
+ "delegationNetwork",
742
749
  "delegationApi",
743
750
  "delegationContract"
744
751
  ],
@@ -843,7 +850,7 @@ var definitions = {
843
850
  ],
844
851
  anyOf: [
845
852
  {
846
- format: "address"
853
+ format: "evmAddress"
847
854
  },
848
855
  {
849
856
  format: "starknetAddress"
@@ -852,9 +859,15 @@ var definitions = {
852
859
  },
853
860
  network: {
854
861
  type: "string",
855
- snapshotNetwork: true,
856
862
  title: "Network",
857
- maxLength: 12
863
+ anyOf: [
864
+ {
865
+ snapshotNetwork: true
866
+ },
867
+ {
868
+ starknetNetwork: true
869
+ }
870
+ ]
858
871
  }
859
872
  },
860
873
  required: [
@@ -3853,6 +3866,7 @@ const ENS_ABI = [
3853
3866
  'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
3854
3867
  ];
3855
3868
  const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
3869
+ const STARKNET_NETWORKS = ['0x534e5f4d41494e', '0x534e5f5345504f4c4941'];
3856
3870
  const scoreApiHeaders = {
3857
3871
  Accept: 'application/json',
3858
3872
  'Content-Type': 'application/json'
@@ -3912,6 +3926,17 @@ ajv.addFormat('address', {
3912
3926
  }
3913
3927
  }
3914
3928
  });
3929
+ ajv.addFormat('evmAddress', {
3930
+ validate: (value) => {
3931
+ try {
3932
+ getAddress(value);
3933
+ return true;
3934
+ }
3935
+ catch (e) {
3936
+ return false;
3937
+ }
3938
+ }
3939
+ });
3915
3940
  ajv.addFormat('starknetAddress', {
3916
3941
  validate: (value) => {
3917
3942
  try {
@@ -3963,6 +3988,15 @@ ajv.addKeyword({
3963
3988
  message: 'network not allowed'
3964
3989
  }
3965
3990
  });
3991
+ ajv.addKeyword({
3992
+ keyword: 'starknetNetwork',
3993
+ validate: function (schema, data) {
3994
+ return STARKNET_NETWORKS.includes(data);
3995
+ },
3996
+ error: {
3997
+ message: 'network not allowed'
3998
+ }
3999
+ });
3966
4000
  ajv.addKeyword({
3967
4001
  keyword: 'maxLengthWithSpaceType',
3968
4002
  validate: function validate(schema, data) {