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

[WIP] Chore/short code refactor #731

Closed
wants to merge 14 commits into from
Closed

Conversation

towanTG
Copy link
Collaborator

@towanTG towanTG commented Apr 12, 2024

No description provided.

@@ -26,20 +26,21 @@ for (const { provider } of providers) {

try {
const tokenList = await RequestClient.get<TokensResponse>(
`https://static.thorswap.net/token-list/${provider}.json`,
`https://dev-api.swapkit.dev/tokens?provider=${provider.toUpperCase()}`,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This will have to change before merge. either api v2 will be supporting all provider or v1 will have to add short codes

import { MemoAction } from "./types";
import type { MemoInfo, MemoSwapInfo } from "./types/memo";

export function parseMemo(memo: string): MemoInfo {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

whats the idea here @olegpetroveth ? currently this is just throwing errors.

also, what do we need shortestIdentifier for? I think we should not add those into asset value but rather have a helper that matches it into identifier, wdyt?

Copy link
Collaborator

@ice-chillios ice-chillios left a comment

Choose a reason for hiding this comment

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

Need second look as I have few doubts how code is structure.
Also tests could be done in ~80% of code as they have cases which are repetitive

Comment on lines +67 to +74
const limitWithSS = limit
? `${limit}/${ssInterval ? `${ssInterval}` : ""}/${ssQuantity ? `${ssQuantity}` : ""}`
: "";
return `${asset?.toString()}:${address}:${limitWithSS}:${
affiliateAddress ? `${affiliateAddress}` : ""
}:${affiliateFee ? `${affiliateFee}` : ""}:${dexAggAddress ? `${dexAggAddress}` : ""}:${
dexAggAsset ? `${dexAggAsset}` : ""
}`;
Copy link
Collaborator

@ice-chillios ice-chillios May 5, 2024

Choose a reason for hiding this comment

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

That part is definitely too complex to be binded as those ternaries. Use more variables and be more descriptive or extract those to functions. By having multiple ternaries - code become unreadable.

Comment on lines +162 to +165
// parseMemoAction('=')
// parseMemoAction('SWAP')
// MemoType.SWAP
const parseMemoAction = (action: string): MemoType | undefined => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

If that's comment - why it's not required by type?

Suggested change
// parseMemoAction('=')
// parseMemoAction('SWAP')
// MemoType.SWAP
const parseMemoAction = (action: string): MemoType | undefined => {
// parseMemoAction('=')
// parseMemoAction('SWAP')
// MemoType.SWAP
const parseMemoAction = (action: 'SWAP' | '='): MemoType | undefined => {

}
}

// If no match is found, return undefined
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
// If no match is found, return undefined

✂️

Do not leave comments which describe exactly what code does

@ice-chillios ice-chillios deleted the chore/short-code-refactor branch June 26, 2024 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants