Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHIA-1348] Port chia wallet coin commands to @chia_command framework #18641

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

Quexington
Copy link
Contributor

@Quexington Quexington commented Sep 25, 2024

(whitespace-less review will likely be beneficial)

This PR takes a step forward in porting existing wallet commands to the @chia_command framework currently in use for the signer commands. The primary benefit of this framework is that we can start writing integration tests with the command line interface at the top instead of the RPC so we can actually test the entire stack that a user utilizes when interacting with our application. It also comes with strong typing for CLI parameters and better code unity (right now the click options and the actual execution code live in separate places).

The coin commands were chosen due to the smaller number of them and the recent attention that has been paid to their tests making it easy to port the commands right on top of those recent changes.

@Quexington Quexington added Changed Required label for PR that categorizes merge commit message as "Changed" for changelog Exclude_Notes Use this label if the changes in the PR should be excluded from the release notes labels Sep 25, 2024
@Quexington Quexington changed the title Port chia wallet coin commands to @chia_command framework [CHIA-1348] Port chia wallet coin commands to @chia_command framework Sep 25, 2024
@Chia-Network Chia-Network deleted a comment from coveralls-official bot Sep 26, 2024
@Chia-Network Chia-Network deleted a comment from github-actions bot Sep 26, 2024
@Chia-Network Chia-Network deleted a comment from github-actions bot Sep 27, 2024
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Nov 15, 2024
@Chia-Network Chia-Network deleted a comment from github-actions bot Nov 15, 2024
@Chia-Network Chia-Network deleted a comment from github-actions bot Nov 15, 2024
@Chia-Network Chia-Network deleted a comment from github-actions bot Nov 15, 2024
@Quexington Quexington closed this Nov 21, 2024
@Quexington Quexington reopened this Nov 21, 2024
@github-actions github-actions bot added the merge_conflict Branch has conflicts that prevent merge to main label Nov 21, 2024
@Quexington Quexington marked this pull request as draft December 3, 2024 21:11
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Dec 4, 2024
@Chia-Network Chia-Network deleted a comment from github-actions bot Dec 9, 2024
@Quexington Quexington marked this pull request as ready for review December 9, 2024 20:45
@github-actions github-actions bot added coverage-diff merge_conflict Branch has conflicts that prevent merge to main labels Dec 9, 2024
@Chia-Network Chia-Network deleted a comment from github-actions bot Dec 10, 2024
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Dec 10, 2024
@Chia-Network Chia-Network deleted a comment from github-actions bot Dec 10, 2024
Copy link
Contributor

File Coverage Missing Lines
chia/cmds/coin_funcs.py 81.4% lines 168-169, 215-216, 219-224, 226-231
Total Missing Coverage
441 lines 16 lines 96%

@Chia-Network Chia-Network deleted a comment from github-actions bot Dec 10, 2024
number_of_coins=100,
amount_per_coin=CliAmount(amount=uint64(100), mojos=True),
target_coin_id=target_coin.name(),
fee=1_000_000_000_000, # 1 XCH
Copy link
Contributor

Choose a reason for hiding this comment

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

As I read it this is still appropriate, just that the hinting is lost with this general dynamic handling.

Suggested change
fee=1_000_000_000_000, # 1 XCH
fee=uint64(1_000_000_000_000), # 1 XCH

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this scenario aren't we really just throwing the uint64 on it to appease mypy though? That was my reading, that we now have the privledge of doing away with this.

Copy link
Contributor

Choose a reason for hiding this comment

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

TransactionEndpoint hints the fee as uint64, so shouldn't it be one? Yes, in this case we have made it so mypy just throws its hands up in despair :] because it can't tell what anything is or should be, but that doesn't seem like a good thing to take advantage of unnecessarily. or maybe i'm misreading here.

chia/_tests/wallet/rpc/test_wallet_rpc.py Outdated Show resolved Hide resolved
chia/_tests/wallet/rpc/test_wallet_rpc.py Outdated Show resolved Hide resolved
chia/_tests/wallet/rpc/test_wallet_rpc.py Outdated Show resolved Hide resolved
chia/_tests/wallet/rpc/test_wallet_rpc.py Outdated Show resolved Hide resolved
chia/_tests/cmds/test_cmd_framework.py Outdated Show resolved Hide resolved
chia/_tests/cmds/test_cmd_framework.py Outdated Show resolved Hide resolved
chia/_tests/environments/wallet.py Outdated Show resolved Hide resolved
chia/_tests/wallet/test_coin_management.py Outdated Show resolved Hide resolved
).to_tx_config(mojo_per_unit, config, fingerprint)


_DECORATOR_APPLIED = "_DECORATOR_APPLIED"
Copy link
Contributor

@altendky altendky Dec 11, 2024

Choose a reason for hiding this comment

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

for stuff like this i often add get/set/is helper functions to spread around instead of the actual getattar()/setattr()/hasattr() calls. and make it really unlikely to collide with anything else.

(providing a suggestion here, but it would at least require this be moved so would have to be applied locally)

Suggested change
_DECORATOR_APPLIED = "_DECORATOR_APPLIED"
_TRANSACTION_ENDPOINT_RUNNER_DECORATOR_APPLIED_ATTRIBUTE_NAME = f"_{__name__.replace('.', '_')}_{transaction_endpoint_runner.__qualname__}_applied"

Comment on lines +31 to +45
STANDARD_TX_ENDPOINT_ARGS: dict[str, Any] = TransactionEndpoint(
rpc_info=NeedsWalletRPC(client_info=None, wallet_rpc_port=None, fingerprint=None),
tx_config_loader=NeedsTXConfig(
min_coin_amount=cli_amount_none,
max_coin_amount=cli_amount_none,
coins_to_exclude=(),
amounts_to_exclude=(),
reuse=None,
),
transaction_writer=TransactionsOut(transaction_file_out=None),
fee=uint64(0),
push=True,
valid_at=None,
expires_at=None,
).__dict__
Copy link
Contributor

Choose a reason for hiding this comment

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

The .__dict__ isn't quite as related to the constructor as the result of dataclasses.asdict() is. .asdict() itself isn't even fully correct depending if you use leading _'s, but it's better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed Required label for PR that categorizes merge commit message as "Changed" for changelog coverage-diff Exclude_Notes Use this label if the changes in the PR should be excluded from the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants