oli-python 1.1.0__tar.gz → 1.2.0__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oli-python
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Python SDK for interacting with the Open Labels Initiative; A framework for address labels in the blockchain space. Read & write labels into the OLI Label Pool, check your labels for OLI compliance.
5
5
  Home-page: https://github.com/openlabelsinitiative/oli-python
6
6
  Author: Lorenz Lehmann
@@ -19,7 +19,7 @@ class UtilsValidator:
19
19
  def fix_simple_tags_formatting(self, tags: dict) -> dict:
20
20
  """
21
21
  Fix basic formatting in the tags dictionary. This includes:
22
- - Ensuring all tag_ids and their value are lowercase
22
+ - Ensuring all tag_ids are lowercase
23
23
  - Booling values are converted from strings to booleans
24
24
  - Removing leading/trailing whitespace from string values
25
25
  - Checksum address (string(42)) tags
@@ -33,21 +33,22 @@ class UtilsValidator:
33
33
  # Convert tag_ids to lowercase
34
34
  tags = {k.lower(): v for k, v in tags.items()}
35
35
 
36
- # Convert all tag_values to lower case & strip whitespaces, then single boolean values from strings to booleans
36
+ # Strip whitespaces, then turn boolean values from strings to booleans
37
37
  for k, v in tags.items():
38
38
  if isinstance(v, str):
39
- tags[k] = v.strip().lower()
39
+ tags[k] = v.strip()
40
40
  if tags[k] == 'true':
41
41
  tags[k] = True
42
42
  elif tags[k] == 'false':
43
43
  tags[k] = False
44
44
  elif isinstance(v, list):
45
- tags[k] = [i.strip().lower() if isinstance(i, str) else i for i in v]
45
+ tags[k] = [i.strip() if isinstance(i, str) else i for i in v]
46
46
 
47
- # Checksum address (string(42)) and transaction hash (string(66)) tags
47
+ # Checksum address tags
48
48
  for k, v in tags.items():
49
- if k in self.oli.tag_definitions and self.oli.tag_definitions[k]['type'] == 'string(42)':
50
- tags[k] = self.oli.w3.to_checksum_address(v)
49
+ if k in self.oli.tag_definitions and 'minLength' in self.oli.tag_definitions[k]['schema']:
50
+ if self.oli.tag_definitions[k]['schema']['minLength'] == 42 and self.oli.tag_definitions[k]['schema']['maxLength'] == 42:
51
+ tags[k] = self.oli.w3.to_checksum_address(v)
51
52
 
52
53
  return tags
53
54
 
@@ -138,7 +139,7 @@ class UtilsValidator:
138
139
  print(tags)
139
140
  raise ValueError("Tags must be a dictionary with OLI compliant tags (e.g., {'contract_name': 'example', 'is_eoa': True})")
140
141
 
141
- # Check each tag_id in the dictionary
142
+ # Check each tag_id in the dictionary # TODO: redo this with tag_definitions 2.0 and schema, should be more efficient
142
143
  for tag_id in tags.keys():
143
144
 
144
145
  # Check if the tag_id is in the official OLI tag list
@@ -147,22 +148,36 @@ class UtilsValidator:
147
148
 
148
149
  # Check if the tag_id is in the correct format. So far implemented [boolean, string, integer, list, float, string(42), string(66), date (YYYY-MM-DD HH:MM:SS)]
149
150
  else:
150
- if self.oli.tag_definitions[tag_id]['type'] == 'boolean' and not isinstance(tags[tag_id], bool):
151
+ if self.oli.tag_definitions[tag_id]['schema']['type'] == 'boolean' and not isinstance(tags[tag_id], bool):
151
152
  print(f"WARNING: Tag value for {tag_id} must be a boolean (True/False).")
152
- elif self.oli.tag_definitions[tag_id]['type'] == 'string' and not isinstance(tags[tag_id], str):
153
+ elif self.oli.tag_definitions[tag_id]['schema']['type'] == 'string' and not isinstance(tags[tag_id], str):
153
154
  print(f"WARNING: Tag value for {tag_id} must be a string.")
154
- elif self.oli.tag_definitions[tag_id]['type'] == 'integer' and not isinstance(tags[tag_id], int):
155
+ elif self.oli.tag_definitions[tag_id]['schema']['type'] == 'integer' and not isinstance(tags[tag_id], int):
155
156
  print(f"WARNING: Tag value for {tag_id} must be an integer.")
156
- elif self.oli.tag_definitions[tag_id]['type'] == 'float' and not isinstance(tags[tag_id], float):
157
+ elif self.oli.tag_definitions[tag_id]['schema']['type'] == 'float' and not isinstance(tags[tag_id], float):
157
158
  print(f"WARNING: Tag value for {tag_id} must be a float.")
158
- elif self.oli.tag_definitions[tag_id]['type'] == 'list' and not isinstance(tags[tag_id], list):
159
- print(f"WARNING: Tag value for {tag_id} must be a list.")
160
- elif self.oli.tag_definitions[tag_id]['type'] == 'string(42)' and not self.oli.w3.is_address(tags[tag_id]):
159
+ elif self.oli.tag_definitions[tag_id]['schema']['type'] == 'array' and not isinstance(tags[tag_id], list):
160
+ print(f"WARNING: Tag value for {tag_id} must be an array.")
161
+ elif (
162
+ self.oli.tag_definitions[tag_id]['schema']['type'] == 'string' and
163
+ self.oli.tag_definitions[tag_id]['schema'].get('minLength') == 42 and
164
+ self.oli.tag_definitions[tag_id]['schema'].get('maxLength') == 42 and
165
+ not self.oli.w3.is_address(tags[tag_id])
166
+ ):
161
167
  print(f"WARNING: Tag value for {tag_id} must be a valid Ethereum address string with '0x'.")
162
- elif self.oli.tag_definitions[tag_id]['type'] == 'string(66)' and not (len(tags[tag_id]) == 66 and tags[tag_id].startswith('0x')):
168
+ elif (
169
+ self.oli.tag_definitions[tag_id]['schema']['type'] == 'string' and
170
+ self.oli.tag_definitions[tag_id]['schema'].get('minLength') == 66 and
171
+ self.oli.tag_definitions[tag_id]['schema'].get('maxLength') == 66 and
172
+ not (len(tags[tag_id]) == 66 and tags[tag_id].startswith('0x'))
173
+ ):
163
174
  print(f"WARNING: Tag value for {tag_id} must be a valid hex string with '0x' prefix and 64 hex characters (66 characters total).")
164
- elif self.oli.tag_definitions[tag_id]['type'] == 'date (YYYY-MM-DD HH:MM:SS)' and not isinstance(tags[tag_id], str):
165
- print(f"WARNING: Tag value for {tag_id} must be a string in the format 'YYYY-MM-DD HH:MM:SS'.")
175
+ elif (
176
+ self.oli.tag_definitions[tag_id]['schema']['type'] == 'string' and
177
+ self.oli.tag_definitions[tag_id]['schema'].get('format') == 'date-time' and
178
+ not isinstance(tags[tag_id], str)
179
+ ):
180
+ print(f"WARNING: Tag value for {tag_id} must be a string in date-time format (e.g., '2023-12-31 23:59:59').")
166
181
 
167
182
  # Check if the value is in the value set
168
183
  if tag_id in self.oli.tag_value_sets:
@@ -36,13 +36,26 @@ class DataFetcher:
36
36
  """
37
37
  value_sets = {}
38
38
 
39
- # value sets from self.oli.tag_definitions (must be a list)
40
- additional_value_sets = {i['tag_id']: i['value_set'] for i in self.oli.tag_definitions.values() if 'value_set' in i}
41
- for tag_id, value_set in additional_value_sets.items():
42
- if isinstance(value_set, list):
43
- # convert all string values to lowercase and keep the rest as is
44
- value_set = [i.lower() if isinstance(i, str) else i for i in value_set]
45
- value_sets[tag_id] = value_set
39
+ # Extract value sets from tag definitions (must be a list)
40
+ for tag_def in self.oli.tag_definitions.values():
41
+ if 'schema' not in tag_def:
42
+ continue
43
+
44
+ schema = tag_def['schema']
45
+ tag_id = tag_def['tag_id']
46
+ value_set = None
47
+
48
+ # Get enum from direct schema or array items
49
+ if 'enum' in schema:
50
+ value_set = schema['enum']
51
+ elif (schema.get('type') == 'array' and
52
+ 'items' in schema and
53
+ 'enum' in schema['items']):
54
+ value_set = schema['items']['enum']
55
+
56
+ # Process and add to value_sets
57
+ if value_set and isinstance(value_set, list):
58
+ value_sets[tag_id] = [i.lower() if isinstance(i, str) else i for i in value_set]
46
59
 
47
60
  # value set for owner_project
48
61
  url = "https://api.growthepie.xyz/v1/labels/projects.json"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oli-python
3
- Version: 1.1.0
3
+ Version: 1.2.0
4
4
  Summary: Python SDK for interacting with the Open Labels Initiative; A framework for address labels in the blockchain space. Read & write labels into the OLI Label Pool, check your labels for OLI compliance.
5
5
  Home-page: https://github.com/openlabelsinitiative/oli-python
6
6
  Author: Lorenz Lehmann
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="oli-python",
8
- version="1.1.0",
8
+ version="1.2.0",
9
9
  author="Lorenz Lehmann",
10
10
  author_email="lorenz@growthepie.xyz",
11
11
  description="Python SDK for interacting with the Open Labels Initiative; A framework for address labels in the blockchain space. Read & write labels into the OLI Label Pool, check your labels for OLI compliance.",
File without changes
File without changes
File without changes
File without changes