-
Notifications
You must be signed in to change notification settings - Fork 1
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
PE-6149: delegated staking landing page and stake/unstake modal #8
PE-6149: delegated staking landing page and stake/unstake modal #8
Conversation
…decreasing delegate stake
…tions to use mIOToken
Visit the preview URL for this PR (updated for commit fc79c94): https://ar-io-network-portal-a40ee--pr8-pe-6149-delegated-st-13dnfnio.web.app (expires Fri, 07 Jun 2024 18:35:36 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 7abfae09c4446982a71cbb94b0cbf4688377a111 |
src/components/forms/validation.ts
Outdated
return (v: string) => { | ||
const value = parseFloat(v); | ||
|
||
if (isNaN(v as unknown as number) || isNaN(value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (isNaN(v as unknown as number) || isNaN(value)) { | |
if (isNaN(+v) || isNaN(value)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out, I updated to coerce using unary plus in this file and added a unit test.
}); | ||
|
||
const delegateData = walletAddress | ||
? (gateway?.delegates[walletAddress?.toString()] as any) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
won't this be GatewayDelegate
- do you need the cast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out, looks like it was a holdover from pre-1.0.7 when it was coming in as unknown. Updated to remove that.
}); | ||
|
||
// TODO: replace with logger call at INFO level when logger reinstated | ||
console.log('Increase Delegate Stake txID:', txID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reccomend bunyan
for a web friendly logger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Been meaning to add it, will plan to finally do it in the next PR that finishes up Phase 2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: I tried bunyan but found it kind of painful to get a custom stream going for nicely formatted messages in the browser. Ended up switching to loglevel for now, will leave it to a later tech debt ticket to improve further. (Loglevel work done in PE-6150)
@@ -90,7 +90,12 @@ const Profile = () => { | |||
text="Connect" | |||
onClick={() => setIsModalOpen(true)} | |||
/> | |||
<ConnectModal open={isModalOpen} onClose={() => setIsModalOpen(false)} /> | |||
{isModalOpen && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these params seem redundant no? Atleast with usage - "open" should handle the rendering internally right? If not, then "open" could just always be set to true and you just use this pattern to render it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started with one style of using the param but then switched to using it with the conditional rendering so that it would get fully unmounted from the DOM when not used. I'll take on refactoring out the open param and require using the && pattern in the next PR to keep this PR moving forward.
<div className="pt-[24px]"> | ||
<h1>Staking</h1> | ||
<div className="grow"> | ||
{walletAddress ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is a long ternary making it tricky to understand, consider splitting it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already being broken up and refactored in the next PR; will be addressed there.
|
||
const EPOCHS_PER_YEAR = 52; | ||
const EPOCH_DISTRIBUTION_RATIO = 0.0025; // 0.25% | ||
const GATEWAY_REWARDS_RATIO = 0.95; // 95% |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wondering if this should be in the SDK. Either as a constant or retrieved from the contract.
@@ -2,7 +2,7 @@ | |||
|
|||
// import App from '../src/App'; | |||
|
|||
describe('App', () => { | |||
describe.skip('App', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats up with this? not test rendering the app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, took it out as it's not a useful test at this point since things are still very changing a lot and would require often snapshots. Will reinstate when we can get more value out of the test.
expect(result.totalDelegatedStake.valueOf()).toEqual( | ||
new IOToken(50000).valueOf(), | ||
); | ||
expect(result.rewardsSharedPerEpoch.valueOf()).toBeCloseTo(197.91, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not toEqual?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://jestjs.io/docs/expect#tobeclosetonumber-numdigits
Testing for floating point numbers
}; | ||
}; | ||
|
||
export const calculateUserRewards = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel like this should be a util in the sdk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - should this be calculateWalletRewards
@@ -86,7 +86,7 @@ export const useGatewayInfo = () => { | |||
observerWallet ? formatWalletAddress(observerWallet) : '', | |||
], | |||
['Joined at', 'PENDING'], | |||
['Stake (IO)', formatWithCommas(mioToIo(operatorStake))], | |||
['Stake (IO)', formatWithCommas(mioToIo(operatorStake.valueOf()))], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use the classes exported by the SDK?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mioToIo() uses the classes; I can remove mioToIO() altogether. Will do this in PE-6150.
No description provided.