-
Notifications
You must be signed in to change notification settings - Fork 3
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
Bypass rollback #7
Conversation
} | ||
const secondsFromPurchase = Date.now() / 1000 - firstPurchase.timestamp | ||
// Estimated time to bypass a rollback | ||
if (secondsFromPurchase <= 60) { |
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.
Please move to an env variable
@@ -27,6 +28,15 @@ export async function* getNotifications( | |||
const addressJettonsFromDb = await getJettonsFromDB(wallet.id) | |||
for (const jetton of addressJettonsFromDb) { | |||
if (!addressJettonsFromChainObj[jetton.token]) { | |||
const firstPurchase = await getFirstAddressJettonPurchaseFromDB(jetton.id) | |||
if (!firstPurchase) { |
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.
Is this possible? If we think it's not, we need to log this.
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.
This is technically possible. if we have a race condition.
I replaced multiple queries with a single postgres transaction with these queries to completly avoid that possibility now.
src/utils/parseTxData/api.ts
Outdated
@@ -21,7 +21,9 @@ export const api = async (address: string) => { | |||
res[jettonInfo.symbol] = { | |||
...jettonInfo, | |||
pnlPercentage, | |||
chart: (slicedChart.length >= 2 ? slicedChart : chart).reverse().map(entity => [entity[0], normalizePrice(entity[1], jettonInfo.decimals)]), | |||
chart: (slicedChart.length >= 2 ? slicedChart : chart) |
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 slicedChart
does not have at least two elements, that means our algorithm is wrong. log it as error.
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.
Do not reverse the chart here. Reverse it on the frontend
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 just didn't touch that, but sure.
src/utils/parseTxData/api.ts
Outdated
chart: (slicedChart.length >= 2 ? slicedChart : chart).reverse().map(entity => [entity[0], normalizePrice(entity[1], jettonInfo.decimals)]), | ||
chart: (slicedChart.length >= 2 ? slicedChart : chart) | ||
.reverse() | ||
.map(entity => [entity[0], normalizePrice(entity[1], jettonInfo.decimals)]), |
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.
This logic should not be here. return the literal price value, and normalize it on the frontend. Less load on the server + eventually I want to turn it into a string (not valid number at all), e.g. something like 0.₉1234
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.
Actually, frontend is completely ok with displaying a string. But I guess our clients have decent hardware and don't care about some client-side transformations anyway.
No description provided.