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

Staking changes #134

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open

Staking changes #134

wants to merge 9 commits into from

Conversation

apporc
Copy link
Contributor

@apporc apporc commented Sep 10, 2024

No description provided.

Copy link

cloudflare-workers-and-pages bot commented Sep 10, 2024

Deploying 2nicove with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0194b5f
Status:🚫  Build failed.

View logs

@apporc apporc changed the title Remove usage of exclamation in staking Staking changes Sep 10, 2024
@apporc apporc marked this pull request as ready for review September 14, 2024 09:11
}

return claimable;
return Asset.fromUnits(claimable, network.chain.systemToken!.symbol);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return Asset.fromUnits(claimable, network.chain.systemToken!.symbol);
return Asset.fromUnits(claimable, network.chain.systemToken?.symbol || '4,UNKNOWN);

Copy link
Contributor

@dafuga dafuga Sep 16, 2024

Choose a reason for hiding this comment

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

I would do something like this everywhere that you're using the ! operand.

Copy link
Contributor Author

@apporc apporc Sep 19, 2024

Choose a reason for hiding this comment

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

Just checked that we are using this.chain.systemToken.symbol almost everywhere, without ! or ?. Your IDE doesn't report the error or you ignore it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, that was my bad, it was because I was using an old version of the wharfkit/common package 😅 I have that all cleaned up in my latest PR 👍

try {
const result = await this.wharf!.transact({
if (!this.network || !this.account || !this.account.name || !this.wharf) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I still think that this doesn't belong in a state file.

Copy link
Contributor Author

@apporc apporc Sep 19, 2024

Choose a reason for hiding this comment

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

I could use another class name like WithdrawManager, instead of xxxState, lol. Yeah i agree a pure state should not hold more logics, but here i think what we need is not a pure state. I know how you've wrote other pages, like ram and send pages, read all about them before coding this, but i think this approach in staking is more clear and easy. Tell me which one you like, WithdrawManager or a pure state and dissecting it in another page file? Keep in mind that, there is consistently only 5 lines of code in every page file, it's fully abstraction between ui and logic :

	const { data } = $props();

	let stakeState: StakeState = $state(new StakeState(data.network));

	$effect(() => {
		stakeState.sync(data.network, context.account, context.wharf);
	});

Copy link
Contributor

Choose a reason for hiding this comment

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

Renaming it would be a step in the right direction, but my other issue with your approach is that it's not consistent with what we've been doing on the other pages.

Copy link
Contributor

@dafuga dafuga Sep 23, 2024

Choose a reason for hiding this comment

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

How about you follow the state class format that we have in the other pages, but you can also have another class to manage the action handling? Maybe it can even take a state class instance as a param? The result would be similar to what you have here, but more consistent with the other pages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think state and state manager should be separated. They are just class's members and class's method properties. Why would we make them two classes?
If you think the withdrawManager is the right direction, why not using this approach in all other pages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants