-
Notifications
You must be signed in to change notification settings - Fork 9
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
[#522] chore: refactor pending transaction #523
Conversation
0f0d73c
to
48a585e
Compare
Provide PR description |
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.
After CR I've got the information that getUTxos getter is copy&pasted and in our case most of the code execution won't go after 1st if, so you can skip comments regarding refactoring that method. I'll just leave the comments for the history
@@ -324,14 +302,14 @@ export const DashboardCards = () => { | |||
<Box | |||
sx={{ | |||
columnGap: 3, | |||
display: "grid", | |||
display: 'grid', | |||
gridTemplateColumns: | |||
screenWidth < 1280 |
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 refactor of this component already happened - it would be great to also get rid of this nested ternaries
Box, CircularProgress, Tab, Tabs, styled, | ||
} from "@mui/material"; | ||
import { useLocation } from "react-router-dom"; | ||
Box, CircularProgress, Tab, Tabs, styled |
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.
Revert this object-curly-newline
is faulty set rule and will be removed
{ | ||
proposalId: getFullGovActionId( | ||
onClick={() => | ||
(onDashboard && |
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.
get rid of nested ternaries
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.
Probably @JanJaroszczak will be modifying this file, so it I will leave it as it to avoid conflicts
const keys = multiasset.keys(); // policy Ids of thee multiasset | ||
const N = keys.len(); | ||
|
||
for (let i = 0; i < N; i++) { |
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 just iterate through keys? What is the reason for using nested for loops with having the builtin methods that does the job for us? 🤔
resourceId?: never; | ||
}; | ||
|
||
export type TransactionStateWithResource = { |
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.
They are exactly the same except type
which might be passed as generic
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.
resourceId
is required in one but not the other
export type TransactionStateWithResource = { | ||
type: TransactionTypeWithResource; | ||
transactionHash: string; | ||
time: Date; |
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 time comes from an API it couldn't be of type Date, as JSON only allows primitive types
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.
its point of time which describes when transaction was confirmed, only for internal service/hook connected with pending transactions
let count = 0; | ||
let isDBSyncUpdated = false; | ||
while (!isDBSyncUpdated && count < DB_SYNC_MAX_ATTEMPTS) { | ||
count++; |
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.
We should avoid ++
as it might cause hard-to-debug problems on production
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.
what do you recomend for this solution ?, I mean insted of while interation
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.
isn't it confusing only as art of a bigger expression?
}; | ||
|
||
const isTransactionExpired = (time: Date): boolean => | ||
new Date().getTime() - time.getTime() > TIME_TO_EXPIRE_TRANSACTION; |
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 just Date.now()
? It is ~2 times faster in execution than new Date().getTime()
giving the same result
pendingTransaction.registerAsDrep || | ||
pendingTransaction.registerAsSoleVoter || | ||
pendingTransaction.retireAsDrep || | ||
pendingTransaction.retireAsSoleVoter, | ||
], | ||
enabled: !!dRepID, | ||
queryFn: async () => await getVoterInfo(dRepID), |
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.
By the way - you could also remove async
and await
here as they are redundant
Co-authored-by: Bartłomiej Sworzeń <b.sworzen@gmail.com>
210d91c
to
66ebbc6
Compare
66ebbc6
to
467460f
Compare
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.
Awesome work, really appreciate 💪
List of changes
Checklist