-
Notifications
You must be signed in to change notification settings - Fork 27
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
Conversation
@@ -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()}`, |
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 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 { |
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 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?
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.
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
const limitWithSS = limit | ||
? `${limit}/${ssInterval ? `${ssInterval}` : ""}/${ssQuantity ? `${ssQuantity}` : ""}` | ||
: ""; | ||
return `${asset?.toString()}:${address}:${limitWithSS}:${ | ||
affiliateAddress ? `${affiliateAddress}` : "" | ||
}:${affiliateFee ? `${affiliateFee}` : ""}:${dexAggAddress ? `${dexAggAddress}` : ""}:${ | ||
dexAggAsset ? `${dexAggAsset}` : "" | ||
}`; |
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.
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.
// parseMemoAction('=') | ||
// parseMemoAction('SWAP') | ||
// MemoType.SWAP | ||
const parseMemoAction = (action: string): MemoType | undefined => { |
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 that's comment - why it's not required by type?
// 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 |
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 no match is found, return undefined |
✂️
Do not leave comments which describe exactly what code does
No description provided.