-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathconstants.py
More file actions
248 lines (216 loc) · 9.27 KB
/
constants.py
File metadata and controls
248 lines (216 loc) · 9.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
from enum import Enum
import os
from web3 import Web3
class ChainId(Enum):
"""Supported blockchain network identifiers.
Attributes:
MAINNET: Ethereum Mainnet (Chain ID: 1)
SEPOLIA: Ethereum Sepolia Testnet (Chain ID: 11155111)
BSC_MAINNET: Binance Smart Chain Mainnet (Chain ID: 56)
BSC_TESTNET: Binance Smart Chain Testnet (Chain ID: 97)
POLYGON: Polygon Mainnet (Chain ID: 137)
POLYGON_AMOY: Polygon Amoy Testnet (Chain ID: 80002)
LOCALHOST: Local development network (Chain ID: 1338)
"""
MAINNET = 1
SEPOLIA = 11155111
BSC_MAINNET = 56
BSC_TESTNET = 97
POLYGON = 137
POLYGON_AMOY = 80002
LOCALHOST = 1338
class OrderDirection(Enum):
"""Sort order for query results.
Attributes:
ASC: Ascending order (lowest to highest).
DESC: Descending order (highest to lowest).
"""
ASC = "asc"
DESC = "desc"
class OperatorCategory(Enum):
"""Categories for operator classification.
Attributes:
MACHINE_LEARNING: Operators providing machine learning services.
MARKET_MAKING: Operators providing market making services.
"""
MACHINE_LEARNING = "machine_learning"
MARKET_MAKING = "market_making"
NETWORKS = {
ChainId.MAINNET: {
"title": "Ethereum",
"scan_url": "https://etherscan.io",
"subgraph_url": (
"https://api.studio.thegraph.com/query/74256/ethereum/version/latest"
),
"subgraph_url_api_key": (
"https://gateway.thegraph.com/api/deployments/id/QmeCB3KX49nRAkzgqancc3yL3VMJvt65YtL1zrLCFgr2n5"
),
"hmt_address": "0xd1ba9BAC957322D6e8c07a160a3A8dA11A0d2867",
"factory_address": "0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a",
"staking_address": "0xEf6Da3aB52c33925Be3F84038193a7e1331F51E6",
"kvstore_address": "0xB6d36B1CDaD50302BCB3DB43bAb0D349458e1b8D",
"old_subgraph_url": "",
"old_factory_address": "",
},
ChainId.SEPOLIA: {
"title": "Sepolia",
"scan_url": "https://sepolia.etherscan.io",
"subgraph_url": (
"https://api.studio.thegraph.com/query/74256/sepolia/version/latest"
),
"subgraph_url_api_key": (
"https://gateway.thegraph.com/api/deployments/id/QmcMntqZSTh8wJddxgp2hYcdw78wZFU86LHTHzJ1bTVUDc"
),
"hmt_address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33",
"factory_address": "0x5987A5558d961ee674efe4A8c8eB7B1b5495D3bf",
"staking_address": "0x2163e3A40032Af1C359ac731deaB48258b317890",
"kvstore_address": "0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60",
"old_subgraph_url": (""),
"old_factory_address": "0x98108c28B7767a52BE38B4860832dd4e11A7ecad",
},
ChainId.BSC_MAINNET: {
"title": "Binance Smart Chain",
"scan_url": "https://bscscan.com",
"subgraph_url": (
"https://api.studio.thegraph.com/query/74256/bsc/version/latest"
),
"subgraph_url_api_key": (
"https://gateway.thegraph.com/api/deployments/id/QmRexbu8eLZ1iE7ZLMtKxAr9GJnQ1JVrXhybKq6JkJ9XLE"
),
"hmt_address": "0x711Fd6ab6d65A98904522d4e3586F492B989c527",
"factory_address": "0x92FD968AcBd521c232f5fB8c33b342923cC72714",
"staking_address": "0xE24e5C08E28331D24758b69A5E9f383D2bDD1c98",
"kvstore_address": "0x21A0C4CED7aE447fCf87D9FE3A29FA9B3AB20Ff1",
"old_subgraph_url": "https://api.thegraph.com/subgraphs/name/humanprotocol/bsc",
"old_factory_address": "0xc88bC422cAAb2ac8812de03176402dbcA09533f4",
},
ChainId.BSC_TESTNET: {
"title": "Binance Smart Chain (Testnet)",
"scan_url": "https://testnet.bscscan.com",
"subgraph_url": (
"https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest"
),
"subgraph_url_api_key": (
"https://gateway.thegraph.com/api/deployments/id/QmfFBXsAP7nbckFx34XYcNq2hRnfoVNrfqCvuk7hmAtYJT"
),
"hmt_address": "0xE3D74BBFa45B4bCa69FF28891fBE392f4B4d4e4d",
"factory_address": "0x2bfA592DBDaF434DDcbb893B1916120d181DAD18",
"staking_address": "0xD6D347ba6987519B4e42EcED43dF98eFf5465a23",
"kvstore_address": "0x32e27177BA6Ea91cf28dfd91a0Da9822A4b74EcF",
"old_subgraph_url": (
"https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest"
),
"old_factory_address": "0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f",
},
ChainId.POLYGON: {
"title": "Polygon",
"scan_url": "https://polygonscan.com",
"subgraph_url": (
"https://api.studio.thegraph.com/query/74256/polygon/version/latest"
),
"subgraph_url_api_key": (
"https://gateway.thegraph.com/api/deployments/id/QmUwHMDjnDHDB5cowGqd96SRJ1sZegoAPanjxBWUyLZghv"
),
"hmt_address": "0xc748B2A084F8eFc47E086ccdDD9b7e67aEb571BF",
"factory_address": "0xBDBfD2cC708199C5640C6ECdf3B0F4A4C67AdfcB",
"staking_address": "0x01D115E9E8bF0C58318793624CC662a030D07F1D",
"kvstore_address": "0xbcB28672F826a50B03EE91B28145EAbddA73B2eD",
"old_subgraph_url": (
"https://api.thegraph.com/subgraphs/name/humanprotocol/polygon"
),
"old_factory_address": "0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794",
},
ChainId.POLYGON_AMOY: {
"title": "Polygon Amoy",
"scan_url": "https://amoy.polygonscan.com",
"subgraph_url": (
"https://api.studio.thegraph.com/query/74256/amoy/version/latest"
),
"subgraph_url_api_key": (
"https://gateway.thegraph.com/api/deployments/id/QmTJfcvVVmw8fe5CwRP6tZD5FzE2ESrm3ryygS1YZMYhM7"
),
"hmt_address": "0x792abbcC99c01dbDec49c9fa9A828a186Da45C33",
"factory_address": "0xAFf5a986A530ff839d49325A5dF69F96627E8D29",
"staking_address": "0xffE496683F842a923110415b7278ded3F265f2C5",
"kvstore_address": "0x724AeFC243EdacCA27EAB86D3ec5a76Af4436Fc7",
"old_subgraph_url": "",
"old_factory_address": "",
},
ChainId.LOCALHOST: {
"title": "Localhost",
"scan_url": "",
"subgraph_url": "http://localhost:8000/subgraphs/name/humanprotocol/localhost",
"subgraph_url_api_key": "",
"hmt_address": "0x5FbDB2315678afecb367f032d93F642f64180aa3",
"factory_address": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9",
"staking_address": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512",
"kvstore_address": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9",
"old_subgraph_url": "",
"old_factory_address": "",
},
}
class Status(Enum):
"""Escrow contract lifecycle statuses.
Attributes:
Launched: Escrow created but not yet funded or configured.
Pending: Escrow funded and awaiting oracle actions.
Partial: Escrow partially paid out to workers.
Paid: All funds distributed but not yet marked complete.
Complete: Escrow fully processed and finalized.
Cancelled: Escrow cancelled and funds refunded.
ToCancel: Cancellation requested, awaiting finalization.
"""
Launched = 0
Pending = 1
Partial = 2
Paid = 3
Complete = 4
Cancelled = 5
ToCancel = 6
class Role(Enum):
"""Oracle and operator role identifiers.
Attributes:
job_launcher: Entity that creates and funds escrows.
exchange_oracle: Oracle handling job distribution and exchange.
reputation_oracle: Oracle managing worker reputation scoring.
recording_oracle: Oracle recording and validating job results.
"""
job_launcher = "job_launcher"
exchange_oracle = "exchange_oracle"
reputation_oracle = "reputation_oracle"
recording_oracle = "recording_oracle"
ARTIFACTS_FOLDER = os.path.join(os.path.dirname(os.path.dirname(__file__)), "artifacts")
"""Path to the directory containing compiled smart contract artifacts (ABIs and bytecode)."""
class KVStoreKeys(Enum):
"""Standard key names for the on-chain key-value store.
These keys are used by operators to store configuration and metadata on-chain.
Attributes:
category: Operator category classification.
fee: Operator fee percentage.
job_types: Comma-separated list of supported job types.
operator_name: Display name of the operator.
public_key: PGP public key for encrypted communication.
public_key_hash: Hash of the public key file.
registration_instructions: Instructions for worker registration.
registration_needed: Whether registration is required (boolean).
role: Operator role identifier.
url: Primary URL for the operator.
website: Public-facing website URL.
webhook_url: Webhook endpoint for notifications.
"""
category = "category"
fee = "fee"
job_types = "job_types"
operator_name = "name"
public_key = "public_key"
public_key_hash = "public_key_hash"
registration_instructions = "registration_instructions"
registration_needed = "registration_needed"
role = "role"
url = "url"
website = "website"
webhook_url = "webhook_url"
ESCROW_BULK_PAYOUT_MAX_ITEMS = 99
"""Maximum number of recipients allowed in a single bulk payout transaction."""
DEFAULT_CONFIRMATION_POLL_INTERVAL = 4
"""Default interval (in seconds) between polling attempts for transaction confirmation."""