oli-python 1.2.0__tar.gz → 2.0.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.
Files changed (27) hide show
  1. oli_python-2.0.0/PKG-INFO +253 -0
  2. oli_python-2.0.0/README.md +226 -0
  3. oli_python-2.0.0/oli/__init__.py +3 -0
  4. {oli_python-1.2.0 → oli_python-2.0.0}/oli/attestation/offchain.py +138 -39
  5. {oli_python-1.2.0 → oli_python-2.0.0}/oli/attestation/onchain.py +96 -19
  6. {oli_python-1.2.0 → oli_python-2.0.0}/oli/attestation/utils_other.py +22 -1
  7. {oli_python-1.2.0 → oli_python-2.0.0}/oli/attestation/utils_validator.py +145 -7
  8. {oli_python-1.2.0 → oli_python-2.0.0}/oli/core.py +311 -90
  9. oli_python-2.0.0/oli/data/__init__.py +5 -0
  10. oli_python-2.0.0/oli/data/api.py +438 -0
  11. oli_python-2.0.0/oli/data/trust.py +199 -0
  12. oli_python-2.0.0/oli/data/utils.py +41 -0
  13. oli_python-2.0.0/oli_python.egg-info/PKG-INFO +253 -0
  14. {oli_python-1.2.0 → oli_python-2.0.0}/oli_python.egg-info/SOURCES.txt +3 -2
  15. {oli_python-1.2.0 → oli_python-2.0.0}/setup.py +3 -3
  16. oli_python-1.2.0/PKG-INFO +0 -130
  17. oli_python-1.2.0/README.md +0 -103
  18. oli_python-1.2.0/oli/__init__.py +0 -4
  19. oli_python-1.2.0/oli/data/__init__.py +0 -4
  20. oli_python-1.2.0/oli/data/fetcher.py +0 -124
  21. oli_python-1.2.0/oli/data/graphql.py +0 -156
  22. oli_python-1.2.0/oli_python.egg-info/PKG-INFO +0 -130
  23. {oli_python-1.2.0 → oli_python-2.0.0}/oli/attestation/__init__.py +0 -0
  24. {oli_python-1.2.0 → oli_python-2.0.0}/oli_python.egg-info/dependency_links.txt +0 -0
  25. {oli_python-1.2.0 → oli_python-2.0.0}/oli_python.egg-info/requires.txt +0 -0
  26. {oli_python-1.2.0 → oli_python-2.0.0}/oli_python.egg-info/top_level.txt +0 -0
  27. {oli_python-1.2.0 → oli_python-2.0.0}/setup.cfg +0 -0
@@ -0,0 +1,253 @@
1
+ Metadata-Version: 2.4
2
+ Name: oli-python
3
+ Version: 2.0.0
4
+ Summary: Python SDK for interacting with the Open Labels Initiative; A standard, registry and trust layer for EVM address labels.
5
+ Home-page: https://github.com/openlabelsinitiative/oli-python
6
+ Author: Lorenz Lehmann
7
+ Author-email: lorenz@growthepie.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Requires-Python: >=3.9
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: web3>=6.0.0
17
+ Requires-Dist: PyYAML>=6.0.0
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: classifier
21
+ Dynamic: description
22
+ Dynamic: description-content-type
23
+ Dynamic: home-page
24
+ Dynamic: requires-dist
25
+ Dynamic: requires-python
26
+ Dynamic: summary
27
+
28
+ # OLI Python SDK
29
+
30
+ **`oli-python`** is the official Python SDK for the **[Open Labels Initiative (OLI)](https://github.com/openlabelsinitiative/OLI)**, a framework for standardized and trusted blockchain address labels.
31
+
32
+ This SDK lets you read, write, validate, and revoke address labels within the **OLI Label Pool** and compute confidence scores based on attesters' relationships within the **OLI Label Trust**.
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install oli-python
38
+ ```
39
+
40
+ ## Initialization
41
+
42
+ ```python
43
+ from oli import OLI
44
+ import os
45
+
46
+ # Initialize the client
47
+ oli = OLI(
48
+ private_key=os.getenv("PRIVATE_KEY"),
49
+ api_key=os.getenv("OLI_API_KEY")
50
+ )
51
+ ```
52
+
53
+ **Setup Instructions:**
54
+ * Create a `.env` file to store your private variables
55
+ * Load an EOA wallet by setting the `private_key` variable
56
+ * The EOA wallet is used to track your reputation within OLI
57
+ * To access all advanced API endpoints, pass an `api_key` variable. You can get your free API key from **[here](http://openlabelsinitiative.org/developer)**
58
+
59
+ **Additional Options:**
60
+
61
+ You can also set the `chain` parameter to specify which EAS contracts location to use and the `custom_rpc_url` variable when initializing.
62
+
63
+ ## Submit Labels into the OLI Label Pool
64
+
65
+ ### Single Attestation
66
+
67
+ ```python
68
+ # Define your OLI compliant attestation
69
+ address = "0x9438b8B447179740cD97869997a2FCc9b4AA63a2"
70
+ chain_id = "eip155:1" # Ethereum mainnet
71
+ tags = {
72
+ "contract_name": "growthepie donation address",
73
+ "is_eoa": True,
74
+ "owner_project": "growthepie",
75
+ }
76
+
77
+ # (Optional) Validate your attestation before submission
78
+ is_valid = oli.validate_label(address, chain_id, tags)
79
+ print("Your attestation is OLI compliant:", is_valid)
80
+
81
+ # Submit label to the OLI Label Pool
82
+ response = oli.submit_label(address, chain_id, tags)
83
+ print(response)
84
+ ```
85
+
86
+ ### Bulk Attestation
87
+
88
+ ```python
89
+ attestations = [
90
+ {"address": address, "chain_id": chain_id, "tags": tags},
91
+ {"address": address, "chain_id": chain_id, "tags": tags},
92
+ ]
93
+
94
+ response = oli.submit_label_bulk(attestations)
95
+ print(response)
96
+ ```
97
+
98
+ ## Revoke Attestations
99
+
100
+ **Note:** All revocations are onchain transactions and therefore require you to have ETH on Base for gas in your wallet.
101
+
102
+ ```python
103
+ # Revoke a single attestation
104
+ oli.revoke_by_uid(uid="0x...")
105
+
106
+ # Bulk revocation
107
+ uids = ["0x1...", "0x2..."]
108
+ oli.revoke_bulk_by_uids(uids)
109
+ ```
110
+
111
+ ## Reading the OLI Label Pool
112
+
113
+ ### Get Raw Attestations
114
+
115
+ ```python
116
+ response = oli.get_attestations()
117
+ print(response)
118
+ ```
119
+
120
+ **Available filters:** uid, attester, recipient, schema_info, since, order, limit
121
+
122
+ ### Get Labels for an Address
123
+
124
+ ```python
125
+ # All labels for an address
126
+ response = oli.get_labels(address = "0x9438b8B447179740cD97869997a2FCc9b4AA63a2")
127
+ print(response)
128
+ ```
129
+
130
+ **Available filters:** address, chain_id, limit, include_all
131
+
132
+ ### Bulk Get Labels for Addresses
133
+
134
+ ```python
135
+ response = ["0x9438b8B447179740cD97869997a2FCc9b4AA63a2", "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24"]
136
+ bulk = oli.get_labels_bulk(response)
137
+ print(bulk)
138
+ ```
139
+
140
+ **Available filters:** addresses, chain_id, limit_per_address, include_all
141
+
142
+ ### Get Addresses Based on a Tag
143
+
144
+ ```python
145
+ response = oli.search_addresses_by_tag(
146
+ tag_id="owner_project",
147
+ tag_value="growthepie"
148
+ )
149
+ print(response)
150
+ ```
151
+
152
+ **Available filters:** tag_id, tag_value, chain_id, limit
153
+
154
+ ### Attester Leaderboard
155
+
156
+ ```python
157
+ chain_id = "eip155:1"
158
+ stats = oli.get_attester_analytics(chain_id)
159
+ print(stats)
160
+ ```
161
+
162
+ ## OLI Label Trust
163
+
164
+ ```python
165
+ # Set a new source node for trust propagation
166
+ trust_table = oli.set_trust_node("0xYourAddress")
167
+ print(oli.trust.trust_table)
168
+
169
+ # Import your trust list from YAML file
170
+ import yaml
171
+ with open('example_trust_list.yml', 'r') as file:
172
+ trust_list = yaml.safe_load(file)
173
+ owner_name = trust_list.get('owner_name')
174
+ attesters = trust_list.get('attesters', [])
175
+ attestations = trust_list.get('attestations', [])
176
+
177
+ # Check if the trust list is OLI compliant
178
+ is_valid = oli.validate_trust_list(
179
+ owner_name,
180
+ attesters,
181
+ attestations
182
+ )
183
+ print("Your trust list is OLI compliant:", is_valid)
184
+
185
+ # Add a private trust list to the trust graph
186
+ oli.add_trust_list(
187
+ owner_name,
188
+ attesters,
189
+ attestations
190
+ )
191
+
192
+ # Submit your trust list to the global trust graph
193
+ response = oli.submit_trust_list(
194
+ owner_name,
195
+ attesters,
196
+ attestations
197
+ )
198
+ print(response)
199
+ ```
200
+
201
+ Once you set your trust node or submit your trust list, the transitive trust algorithm can assign a trust score to all labels. Use the following endpoints, which now assign a confidence score to each label. You can also set `min_confidence` to filter based on confidence thresholds.
202
+
203
+ ### Get Trusted Labels for an Address
204
+
205
+ ```python
206
+ # All trusted labels for an address
207
+ response = oli.get_trusted_labels(address = "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24")
208
+ print(response)
209
+ ```
210
+
211
+ **Available filters:** address, chain_id, limit, include_all, min_confidence
212
+
213
+ ### Bulk Get Trusted Labels for Addresses
214
+
215
+ ```python
216
+ addresses = ["0x9438b8B447179740cD97869997a2FCc9b4AA63a2", "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24"]
217
+ response = oli.get_trusted_labels_bulk(addresses)
218
+ print(response)
219
+ ```
220
+
221
+ **Available filters:** addresses, chain_id, limit_per_address, include_all, min_confidence
222
+
223
+ ### Get Trusted Addresses Based on a Tag
224
+
225
+ ```python
226
+ response = oli.search_trusted_addresses_by_tag(
227
+ tag_id = "owner_project",
228
+ tag_value = "growthepie"
229
+ )
230
+ print(response)
231
+ ```
232
+
233
+ **Available filters:** tag_id, tag_value, chain_id, limit, min_confidence
234
+
235
+ ## OLI Label Pool Parquet Exports
236
+
237
+ growthepie provides dataset exports as Parquet files for all attestations inside the OLI Label Pool, updated daily:
238
+
239
+ ```python
240
+ oli.get_full_raw_export_parquet()
241
+ oli.get_full_decoded_export_parquet()
242
+ ```
243
+
244
+ **Option:** Pass the filepath as a variable to store the export in a specific location.
245
+
246
+ ## OLI Documentation
247
+
248
+ * [Open Labels Initiative Docs](https://github.com/openlabelsinitiative/OLI)
249
+ * [OLI Website](https://www.openlabelsinitiative.org/)
250
+
251
+ ## License
252
+
253
+ MIT © Open Labels Initiative
@@ -0,0 +1,226 @@
1
+ # OLI Python SDK
2
+
3
+ **`oli-python`** is the official Python SDK for the **[Open Labels Initiative (OLI)](https://github.com/openlabelsinitiative/OLI)**, a framework for standardized and trusted blockchain address labels.
4
+
5
+ This SDK lets you read, write, validate, and revoke address labels within the **OLI Label Pool** and compute confidence scores based on attesters' relationships within the **OLI Label Trust**.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install oli-python
11
+ ```
12
+
13
+ ## Initialization
14
+
15
+ ```python
16
+ from oli import OLI
17
+ import os
18
+
19
+ # Initialize the client
20
+ oli = OLI(
21
+ private_key=os.getenv("PRIVATE_KEY"),
22
+ api_key=os.getenv("OLI_API_KEY")
23
+ )
24
+ ```
25
+
26
+ **Setup Instructions:**
27
+ * Create a `.env` file to store your private variables
28
+ * Load an EOA wallet by setting the `private_key` variable
29
+ * The EOA wallet is used to track your reputation within OLI
30
+ * To access all advanced API endpoints, pass an `api_key` variable. You can get your free API key from **[here](http://openlabelsinitiative.org/developer)**
31
+
32
+ **Additional Options:**
33
+
34
+ You can also set the `chain` parameter to specify which EAS contracts location to use and the `custom_rpc_url` variable when initializing.
35
+
36
+ ## Submit Labels into the OLI Label Pool
37
+
38
+ ### Single Attestation
39
+
40
+ ```python
41
+ # Define your OLI compliant attestation
42
+ address = "0x9438b8B447179740cD97869997a2FCc9b4AA63a2"
43
+ chain_id = "eip155:1" # Ethereum mainnet
44
+ tags = {
45
+ "contract_name": "growthepie donation address",
46
+ "is_eoa": True,
47
+ "owner_project": "growthepie",
48
+ }
49
+
50
+ # (Optional) Validate your attestation before submission
51
+ is_valid = oli.validate_label(address, chain_id, tags)
52
+ print("Your attestation is OLI compliant:", is_valid)
53
+
54
+ # Submit label to the OLI Label Pool
55
+ response = oli.submit_label(address, chain_id, tags)
56
+ print(response)
57
+ ```
58
+
59
+ ### Bulk Attestation
60
+
61
+ ```python
62
+ attestations = [
63
+ {"address": address, "chain_id": chain_id, "tags": tags},
64
+ {"address": address, "chain_id": chain_id, "tags": tags},
65
+ ]
66
+
67
+ response = oli.submit_label_bulk(attestations)
68
+ print(response)
69
+ ```
70
+
71
+ ## Revoke Attestations
72
+
73
+ **Note:** All revocations are onchain transactions and therefore require you to have ETH on Base for gas in your wallet.
74
+
75
+ ```python
76
+ # Revoke a single attestation
77
+ oli.revoke_by_uid(uid="0x...")
78
+
79
+ # Bulk revocation
80
+ uids = ["0x1...", "0x2..."]
81
+ oli.revoke_bulk_by_uids(uids)
82
+ ```
83
+
84
+ ## Reading the OLI Label Pool
85
+
86
+ ### Get Raw Attestations
87
+
88
+ ```python
89
+ response = oli.get_attestations()
90
+ print(response)
91
+ ```
92
+
93
+ **Available filters:** uid, attester, recipient, schema_info, since, order, limit
94
+
95
+ ### Get Labels for an Address
96
+
97
+ ```python
98
+ # All labels for an address
99
+ response = oli.get_labels(address = "0x9438b8B447179740cD97869997a2FCc9b4AA63a2")
100
+ print(response)
101
+ ```
102
+
103
+ **Available filters:** address, chain_id, limit, include_all
104
+
105
+ ### Bulk Get Labels for Addresses
106
+
107
+ ```python
108
+ response = ["0x9438b8B447179740cD97869997a2FCc9b4AA63a2", "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24"]
109
+ bulk = oli.get_labels_bulk(response)
110
+ print(bulk)
111
+ ```
112
+
113
+ **Available filters:** addresses, chain_id, limit_per_address, include_all
114
+
115
+ ### Get Addresses Based on a Tag
116
+
117
+ ```python
118
+ response = oli.search_addresses_by_tag(
119
+ tag_id="owner_project",
120
+ tag_value="growthepie"
121
+ )
122
+ print(response)
123
+ ```
124
+
125
+ **Available filters:** tag_id, tag_value, chain_id, limit
126
+
127
+ ### Attester Leaderboard
128
+
129
+ ```python
130
+ chain_id = "eip155:1"
131
+ stats = oli.get_attester_analytics(chain_id)
132
+ print(stats)
133
+ ```
134
+
135
+ ## OLI Label Trust
136
+
137
+ ```python
138
+ # Set a new source node for trust propagation
139
+ trust_table = oli.set_trust_node("0xYourAddress")
140
+ print(oli.trust.trust_table)
141
+
142
+ # Import your trust list from YAML file
143
+ import yaml
144
+ with open('example_trust_list.yml', 'r') as file:
145
+ trust_list = yaml.safe_load(file)
146
+ owner_name = trust_list.get('owner_name')
147
+ attesters = trust_list.get('attesters', [])
148
+ attestations = trust_list.get('attestations', [])
149
+
150
+ # Check if the trust list is OLI compliant
151
+ is_valid = oli.validate_trust_list(
152
+ owner_name,
153
+ attesters,
154
+ attestations
155
+ )
156
+ print("Your trust list is OLI compliant:", is_valid)
157
+
158
+ # Add a private trust list to the trust graph
159
+ oli.add_trust_list(
160
+ owner_name,
161
+ attesters,
162
+ attestations
163
+ )
164
+
165
+ # Submit your trust list to the global trust graph
166
+ response = oli.submit_trust_list(
167
+ owner_name,
168
+ attesters,
169
+ attestations
170
+ )
171
+ print(response)
172
+ ```
173
+
174
+ Once you set your trust node or submit your trust list, the transitive trust algorithm can assign a trust score to all labels. Use the following endpoints, which now assign a confidence score to each label. You can also set `min_confidence` to filter based on confidence thresholds.
175
+
176
+ ### Get Trusted Labels for an Address
177
+
178
+ ```python
179
+ # All trusted labels for an address
180
+ response = oli.get_trusted_labels(address = "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24")
181
+ print(response)
182
+ ```
183
+
184
+ **Available filters:** address, chain_id, limit, include_all, min_confidence
185
+
186
+ ### Bulk Get Trusted Labels for Addresses
187
+
188
+ ```python
189
+ addresses = ["0x9438b8B447179740cD97869997a2FCc9b4AA63a2", "0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24"]
190
+ response = oli.get_trusted_labels_bulk(addresses)
191
+ print(response)
192
+ ```
193
+
194
+ **Available filters:** addresses, chain_id, limit_per_address, include_all, min_confidence
195
+
196
+ ### Get Trusted Addresses Based on a Tag
197
+
198
+ ```python
199
+ response = oli.search_trusted_addresses_by_tag(
200
+ tag_id = "owner_project",
201
+ tag_value = "growthepie"
202
+ )
203
+ print(response)
204
+ ```
205
+
206
+ **Available filters:** tag_id, tag_value, chain_id, limit, min_confidence
207
+
208
+ ## OLI Label Pool Parquet Exports
209
+
210
+ growthepie provides dataset exports as Parquet files for all attestations inside the OLI Label Pool, updated daily:
211
+
212
+ ```python
213
+ oli.get_full_raw_export_parquet()
214
+ oli.get_full_decoded_export_parquet()
215
+ ```
216
+
217
+ **Option:** Pass the filepath as a variable to store the export in a specific location.
218
+
219
+ ## OLI Documentation
220
+
221
+ * [Open Labels Initiative Docs](https://github.com/openlabelsinitiative/OLI)
222
+ * [OLI Website](https://www.openlabelsinitiative.org/)
223
+
224
+ ## License
225
+
226
+ MIT © Open Labels Initiative
@@ -0,0 +1,3 @@
1
+ from oli.core import OLI
2
+
3
+ __all__ = ["OLI"]