Fix conditions used in scripts/examples - should be versioned.

pull/3145/head
derekpierre 2023-06-15 08:56:30 -04:00
parent f9df0fa0ca
commit fa40b32620
2 changed files with 15 additions and 14 deletions

View File

@ -7,6 +7,7 @@ import nucypher
from nucypher.blockchain.eth.agents import CoordinatorAgent
from nucypher.blockchain.eth.registry import LocalContractRegistry
from nucypher.characters.lawful import Bob, Enrico, Ursula
from nucypher.policy.conditions.lingo import ConditionLingo
from nucypher.utilities.logging import GlobalLoggerSettings
######################
@ -39,19 +40,15 @@ print(f'Fetched DKG public key {bytes(enrico.policy_pubkey).hex()} '
f'from Coordinator {coordinator_agent.contract.address}')
eth_balance_condition = {
"chain": 80001,
"method": "eth_getBalance",
"parameters": [
"0x210eeAC07542F815ebB6FD6689637D8cA2689392",
"latest"
],
"returnValueTest": {
"comparator": "==",
"value": 0
}
"version": ConditionLingo.VERSION,
"condition": {
"chain": 80001,
"method": "eth_getBalance",
"parameters": ["0x210eeAC07542F815ebB6FD6689637D8cA2689392", "latest"],
"returnValueTest": {"comparator": "==", "value": 0},
},
}
message = "hello world".encode()
ciphertext = enrico.encrypt_for_dkg(plaintext=message, conditions=eth_balance_condition)

View File

@ -35,6 +35,7 @@ from nucypher.blockchain.eth.registry import (
from nucypher.blockchain.eth.signers import Signer
from nucypher.characters.lawful import Bob, Enrico, Ursula
from nucypher.crypto.powers import TransactingPower
from nucypher.policy.conditions.lingo import ConditionLingo
from nucypher.utilities.emitters import StdoutEmitter
from nucypher.utilities.logging import GlobalLoggerSettings
@ -197,9 +198,12 @@ Those who know the essential to be essential and the unessential to be unessenti
# -- Dhammapada
CONDITIONS = {
"returnValueTest": {"value": "0", "comparator": ">"},
"method": "blocktime",
"chain": blockchain.client.chain_id,
"version": ConditionLingo.VERSION,
"condition": {
"returnValueTest": {"value": "0", "comparator": ">"},
"method": "blocktime",
"chain": blockchain.client.chain_id,
},
}
encrypting_key = DkgPublicKey.from_bytes(