@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.
@@ -716,20 +716,34 @@ var definitions = {
716
716
  },
717
717
  delegationContract: {
718
718
  type: "string",
719
- format: "evmAddress",
720
719
  title: "Contract address",
721
720
  description: "The address of your delegation contract",
722
721
  examples: [
723
722
  "0x3901D0fDe202aF1427216b79f5243f8A022d68cf"
724
- ]
723
+ ],
724
+ anyOf: [
725
+ {
726
+ format: "evmAddress"
727
+ },
728
+ {
729
+ format: "starknetAddress"
730
+ }
731
+ ],
732
+ errorMessage: "Must be a valid EVM of Starknet address"
725
733
  },
726
734
  delegationNetwork: {
727
735
  type: "string",
728
- snapshotNetwork: true,
729
736
  title: "Delegation network",
730
- minLength: 1,
731
- maxLength: 32,
732
- description: "The network of your delegation contract"
737
+ description: "The network of your delegation contract",
738
+ anyOf: [
739
+ {
740
+ snapshotNetwork: true
741
+ },
742
+ {
743
+ starknetNetwork: true
744
+ }
745
+ ],
746
+ errorMessage: "Must be a valid network"
733
747
  },
734
748
  delegationApi: {
735
749
  type: "string",
@@ -743,6 +757,7 @@ var definitions = {
743
757
  },
744
758
  required: [
745
759
  "delegationType",
760
+ "delegationNetwork",
746
761
  "delegationApi",
747
762
  "delegationContract"
748
763
  ],
@@ -852,13 +867,21 @@ var definitions = {
852
867
  {
853
868
  format: "starknetAddress"
854
869
  }
855
- ]
870
+ ],
871
+ errorMessage: "Must be a valid EVM of Starknet address"
856
872
  },
857
873
  network: {
858
874
  type: "string",
859
- snapshotNetwork: true,
860
875
  title: "Network",
861
- maxLength: 12
876
+ anyOf: [
877
+ {
878
+ snapshotNetwork: true
879
+ },
880
+ {
881
+ starknetNetwork: true
882
+ }
883
+ ],
884
+ errorMessage: "Must be a valid network"
862
885
  }
863
886
  },
864
887
  required: [
@@ -3857,6 +3880,16 @@ const ENS_ABI = [
3857
3880
  'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
3858
3881
  ];
3859
3882
  const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
3883
+ const STARKNET_NETWORKS = {
3884
+ '0x534e5f4d41494e': {
3885
+ name: 'Starknet',
3886
+ testnet: false
3887
+ },
3888
+ '0x534e5f5345504f4c4941': {
3889
+ name: 'Starknet Sepolia',
3890
+ testnet: true
3891
+ }
3892
+ };
3860
3893
  const scoreApiHeaders = {
3861
3894
  Accept: 'application/json',
3862
3895
  'Content-Type': 'application/json'
@@ -3978,6 +4011,22 @@ ajv.addKeyword({
3978
4011
  message: 'network not allowed'
3979
4012
  }
3980
4013
  });
4014
+ ajv.addKeyword({
4015
+ keyword: 'starknetNetwork',
4016
+ validate: function (schema, data) {
4017
+ // @ts-ignore
4018
+ const snapshotEnv = this.snapshotEnv || 'default';
4019
+ if (snapshotEnv === 'mainnet') {
4020
+ return Object.keys(STARKNET_NETWORKS)
4021
+ .filter((id) => !STARKNET_NETWORKS[id].testnet)
4022
+ .includes(data);
4023
+ }
4024
+ return Object.keys(STARKNET_NETWORKS).includes(data);
4025
+ },
4026
+ error: {
4027
+ message: 'network not allowed'
4028
+ }
4029
+ });
3981
4030
  ajv.addKeyword({
3982
4031
  keyword: 'maxLengthWithSpaceType',
3983
4032
  validate: function validate(schema, data) {
@@ -706,20 +706,34 @@ var definitions = {
706
706
  },
707
707
  delegationContract: {
708
708
  type: "string",
709
- format: "evmAddress",
710
709
  title: "Contract address",
711
710
  description: "The address of your delegation contract",
712
711
  examples: [
713
712
  "0x3901D0fDe202aF1427216b79f5243f8A022d68cf"
714
- ]
713
+ ],
714
+ anyOf: [
715
+ {
716
+ format: "evmAddress"
717
+ },
718
+ {
719
+ format: "starknetAddress"
720
+ }
721
+ ],
722
+ errorMessage: "Must be a valid EVM of Starknet address"
715
723
  },
716
724
  delegationNetwork: {
717
725
  type: "string",
718
- snapshotNetwork: true,
719
726
  title: "Delegation network",
720
- minLength: 1,
721
- maxLength: 32,
722
- description: "The network of your delegation contract"
727
+ description: "The network of your delegation contract",
728
+ anyOf: [
729
+ {
730
+ snapshotNetwork: true
731
+ },
732
+ {
733
+ starknetNetwork: true
734
+ }
735
+ ],
736
+ errorMessage: "Must be a valid network"
723
737
  },
724
738
  delegationApi: {
725
739
  type: "string",
@@ -733,6 +747,7 @@ var definitions = {
733
747
  },
734
748
  required: [
735
749
  "delegationType",
750
+ "delegationNetwork",
736
751
  "delegationApi",
737
752
  "delegationContract"
738
753
  ],
@@ -842,13 +857,21 @@ var definitions = {
842
857
  {
843
858
  format: "starknetAddress"
844
859
  }
845
- ]
860
+ ],
861
+ errorMessage: "Must be a valid EVM of Starknet address"
846
862
  },
847
863
  network: {
848
864
  type: "string",
849
- snapshotNetwork: true,
850
865
  title: "Network",
851
- maxLength: 12
866
+ anyOf: [
867
+ {
868
+ snapshotNetwork: true
869
+ },
870
+ {
871
+ starknetNetwork: true
872
+ }
873
+ ],
874
+ errorMessage: "Must be a valid network"
852
875
  }
853
876
  },
854
877
  required: [
@@ -3847,6 +3870,16 @@ const ENS_ABI = [
3847
3870
  'function resolver(bytes32 node) view returns (address)' // ENS registry ABI
3848
3871
  ];
3849
3872
  const EMPTY_ADDRESS = '0x0000000000000000000000000000000000000000';
3873
+ const STARKNET_NETWORKS = {
3874
+ '0x534e5f4d41494e': {
3875
+ name: 'Starknet',
3876
+ testnet: false
3877
+ },
3878
+ '0x534e5f5345504f4c4941': {
3879
+ name: 'Starknet Sepolia',
3880
+ testnet: true
3881
+ }
3882
+ };
3850
3883
  const scoreApiHeaders = {
3851
3884
  Accept: 'application/json',
3852
3885
  'Content-Type': 'application/json'
@@ -3968,6 +4001,22 @@ ajv.addKeyword({
3968
4001
  message: 'network not allowed'
3969
4002
  }
3970
4003
  });
4004
+ ajv.addKeyword({
4005
+ keyword: 'starknetNetwork',
4006
+ validate: function (schema, data) {
4007
+ // @ts-ignore
4008
+ const snapshotEnv = this.snapshotEnv || 'default';
4009
+ if (snapshotEnv === 'mainnet') {
4010
+ return Object.keys(STARKNET_NETWORKS)
4011
+ .filter((id) => !STARKNET_NETWORKS[id].testnet)
4012
+ .includes(data);
4013
+ }
4014
+ return Object.keys(STARKNET_NETWORKS).includes(data);
4015
+ },
4016
+ error: {
4017
+ message: 'network not allowed'
4018
+ }
4019
+ });
3971
4020
  ajv.addKeyword({
3972
4021
  keyword: 'maxLengthWithSpaceType',
3973
4022
  validate: function validate(schema, data) {