Respond to RFCs for #2573.

Co-authored-by: K Prasch <kieranprasch@gmail.com>
pull/2573/head
derekpierre 2021-02-25 19:24:10 -05:00
parent 3ad3e2edc2
commit 3f49a08453
2 changed files with 42 additions and 3 deletions

View File

@ -163,7 +163,7 @@ For example,
PolicyManager::PolicyCreated events written to /<HOME DIRECTORY>/Policy_Events.csv
To write every PolicyManager smart contract events thus far to corresponding CSV files, run:
To write every PolicyManager smart contract event thus far to corresponding CSV files, run:
.. code::
@ -187,6 +187,39 @@ To write every PolicyManager smart contract events thus far to corresponding CSV
PolicyManager::Withdrawn events written to PolicyManager_Withdrawn_2021-02-24_20-47-06.csv
To write StakingEscrow events for a specific Staker for the current period to corresponding CSV files, run:
.. code::
$ nucypher status events --provider <PROVIDER URI> --contract-name StakingEscrow --event-filter staker=<STAKING_ADDRESS> --csv
Reading Latest Chaindata...
Retrieving events from block 11929449 to latest
--------- StakingEscrow Events ---------
StakingEscrow::CommitmentMade events written to StakingEscrow_CommitmentMade_2021-02-26_00-11-53.csv
No StakingEscrow::Deposited events found
No StakingEscrow::Divided events found
No StakingEscrow::Donated events found
No StakingEscrow::Initialized events found
No StakingEscrow::Locked events found
StakingEscrow::Merged events written to StakingEscrow_Merged_2021-02-26_00-12-27.csv
StakingEscrow::Minted events written to StakingEscrow_Minted_2021-02-26_00-12-29.csv
No StakingEscrow::OwnershipTransferred events found
No StakingEscrow::Prolonged events found
No StakingEscrow::ReStakeLocked events found
No StakingEscrow::ReStakeSet events found
No StakingEscrow::Slashed events found
No StakingEscrow::SnapshotSet events found
No StakingEscrow::StateVerified events found
No StakingEscrow::UpgradeFinished events found
No StakingEscrow::WindDownSet events found
No StakingEscrow::Withdrawn events found
No StakingEscrow::WorkMeasurementSet events found
No StakingEscrow::WorkerBonded events found
.. note::
If there were no events found, a CSV file is not written to.

View File

@ -227,7 +227,12 @@ def deployer_pre_launch_warnings(emitter: StdoutEmitter, etherscan: bool, hw_wal
emitter.echo(ETHERSCAN_FLAG_DISABLED_WARNING, color='yellow')
def parse_event_filters_into_argument_filters(event_filters: Tuple) -> Dict:
def parse_event_filters_into_argument_filters(event_filters: Tuple[str]) -> Dict:
"""
Converts tuple of entries of the form <filter_name>=<filter_value> into a dict
of filter_name (key) -> filter_value (value) entries. Filter values can only be strings, but if the filter
value can be converted to an int, then it is converted, otherwise it remains a string.
"""
argument_filters = dict()
for event_filter in event_filters:
event_filter_split = event_filter.split('=')
@ -235,6 +240,7 @@ def parse_event_filters_into_argument_filters(event_filters: Tuple) -> Dict:
raise ValueError(f"Invalid filter format: {event_filter}")
key = event_filter_split[0]
value = event_filter_split[1]
# events are only indexed by string or int values
if value.isnumeric():
value = int(value)
argument_filters[key] = value
@ -247,7 +253,7 @@ def retrieve_events(emitter: StdoutEmitter,
from_block: BlockIdentifier,
to_block: BlockIdentifier,
argument_filters: Dict,
csv_output_file: Optional[str] = None):
csv_output_file: Optional[str] = None) -> None:
if csv_output_file:
if Path(csv_output_file).exists():
click.confirm(CONFIRM_OVERWRITE_EVENTS_CSV_FILE.format(csv_file=csv_output_file), abort=True)