Spaces:
Running
Running
Update src/trust_agent.py
Browse filesimplemented slashing contract
- src/trust_agent.py +8 -1
src/trust_agent.py
CHANGED
|
@@ -213,14 +213,21 @@ class AgentTrust:
|
|
| 213 |
dialect = payload.get("dialect", "Unknown Dialect")
|
| 214 |
license_type = "CC-BY-4.0 (Open Research)" # Academic open data license
|
| 215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
# 6. Build the Transaction
|
| 217 |
nonce = w3.eth.get_transaction_count(wallet_address)
|
| 218 |
|
|
|
|
| 219 |
tx = contract.functions.proposeEntry(
|
| 220 |
phrase,
|
| 221 |
dialect,
|
| 222 |
data_hash,
|
| 223 |
-
license_type
|
|
|
|
| 224 |
).build_transaction({
|
| 225 |
'chainId': w3.eth.chain_id,
|
| 226 |
'gas': 2000000,
|
|
|
|
| 213 |
dialect = payload.get("dialect", "Unknown Dialect")
|
| 214 |
license_type = "CC-BY-4.0 (Open Research)" # Academic open data license
|
| 215 |
|
| 216 |
+
# 🟢 NEW: Safely grab the mobile user's ID, fallback to Lab Admin if missing
|
| 217 |
+
operator_id = payload.get("user", wallet_address)
|
| 218 |
+
if not operator_id.startswith("0x"):
|
| 219 |
+
operator_id = wallet_address # Fallback to Admin if ID is corrupted
|
| 220 |
+
|
| 221 |
# 6. Build the Transaction
|
| 222 |
nonce = w3.eth.get_transaction_count(wallet_address)
|
| 223 |
|
| 224 |
+
# 🟢 UPDATED: Pass operator_id as the 5th parameter!
|
| 225 |
tx = contract.functions.proposeEntry(
|
| 226 |
phrase,
|
| 227 |
dialect,
|
| 228 |
data_hash,
|
| 229 |
+
license_type,
|
| 230 |
+
operator_id
|
| 231 |
).build_transaction({
|
| 232 |
'chainId': w3.eth.chain_id,
|
| 233 |
'gas': 2000000,
|