From 3f49a08453f9c8af2ca06176291a91426c294833 Mon Sep 17 00:00:00 2001 From: derekpierre Date: Thu, 25 Feb 2021 19:24:10 -0500 Subject: [PATCH] Respond to RFCs for #2573. Co-authored-by: K Prasch --- docs/source/references/network_events.rst | 35 ++++++++++++++++++++++- nucypher/cli/utils.py | 10 +++++-- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/docs/source/references/network_events.rst b/docs/source/references/network_events.rst index ebc0fd945..0634dae3c 100644 --- a/docs/source/references/network_events.rst +++ b/docs/source/references/network_events.rst @@ -163,7 +163,7 @@ For example, PolicyManager::PolicyCreated events written to //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 --contract-name StakingEscrow --event-filter staker= --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. diff --git a/nucypher/cli/utils.py b/nucypher/cli/utils.py index edd924e26..d818b9af1 100644 --- a/nucypher/cli/utils.py +++ b/nucypher/cli/utils.py @@ -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 = 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)