Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Hide withdraw in golecli account if not mainnet #3684

Merged
merged 6 commits into from
Jan 4, 2019

Conversation

dybi
Copy link
Contributor

@dybi dybi commented Dec 18, 2018

@ghost ghost assigned dybi Dec 18, 2018
@ghost ghost added the in progress label Dec 18, 2018
@@ -40,6 +41,19 @@ def exit(self, status=0, message=None):
raise ParsingException(message, self)


def adapt_children(children: Dict[Text, Callable]) -> Dict[Text, Callable]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dybi ... on the surface, this function seems generic but really it's only applicable to a very specific case and hardly reusable... wouldn't it make sense to just get rid of that key specifically in the _build_parser without having a separate function for this task?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shadeofblue, you've got a point - the name of the function is too generic. However, I would be for having it separated from the rest of the code for the sake of better modularity and unit-testing.

golem/interface/cli.py Outdated Show resolved Hide resolved
…thdraw` and change dict comprehension to deepcopy
@dybi dybi force-pushed the chore-hide-withdraw-in-golecli-account-if-not-mainnet branch from 18b31ec to b357060 Compare December 21, 2018 10:08
golem/interface/cli.py Outdated Show resolved Hide resolved
…rmining if `withdraw` should be available in golemcli
Copy link
Contributor

@shadeofblue shadeofblue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good as far as I can tell.

@Krigpl , could you confirm?

Copy link
Contributor

@jiivan jiivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it would be nice to explicitly disable a method in golem.interface.client.account.Account.withdraw(). Possibly by adding a modifier to @command decorator.

@codecov
Copy link

codecov bot commented Jan 2, 2019

Codecov Report

Merging #3684 into develop will increase coverage by 0.02%.
The diff coverage is 100%.

@@             Coverage Diff             @@
##           develop    #3684      +/-   ##
===========================================
+ Coverage    89.11%   89.13%   +0.02%     
===========================================
  Files          202      202              
  Lines        18064    18084      +20     
===========================================
+ Hits         16097    16120      +23     
+ Misses        1967     1964       -3

@dybi
Copy link
Contributor Author

dybi commented Jan 3, 2019

@jiivan the problem with the proposed approach is that @group and @command decorators are evaluated at import and whether we are running on miannet or not is determined later (after arguments are parsed)

@dybi dybi force-pushed the chore-hide-withdraw-in-golecli-account-if-not-mainnet branch from fcf9515 to 65478e0 Compare January 3, 2019 10:33
if m.enabled: # type: ignore
filtered.append((name, m))
else:
filtered.append((name, m))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if getattr(m, 'enabled', False):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return [(name, m) for name, m in methods if getattr(m, 'enabled', False)]
I'm not sure if this list comprehension is worthy of a separate function. I would just use it in CommandHelper.get_methods()

Copy link
Contributor Author

@dybi dybi Jan 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is no longer there - as stated above:

@group and @command decorators are evaluated at import and whether we are running on miannet or not is determined later (after arguments are parsed)

so it seems not to work properly: at the time command_enabled is evaluated IS_MAINET flag is still False - it gets to True later (if -m is provided) when arguments are parsed

Copy link
Contributor

@jiivan jiivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, CommandHelper needs major refactoring, but it's not top priority right now.

@dybi dybi merged commit fde319d into develop Jan 4, 2019
@ghost ghost removed the in progress label Jan 4, 2019
@dybi dybi deleted the chore-hide-withdraw-in-golecli-account-if-not-mainnet branch January 4, 2019 10:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

account withdraw should not be presented in golemcli for testnet
4 participants