-
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
Feat: Multiple tokens form #17
Feat: Multiple tokens form #17
Conversation
Signed-off-by: Stanislaw <[email protected]>
src/App.tsx
Outdated
formData.map(async (item) => { | ||
const tokenId = item.tokenId; | ||
const minAmount = item.minAmount; | ||
const url = `${nodeUrl}/api/v1/tokens/${tokenId}/balances?account.balance=gte:${minAmount}&limit=100`; | ||
return fetchData(url); |
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 think you can destructure tokenId
and minAmount
here right away
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.
Done
…threshold-for-each Signed-off-by: Stanislaw <[email protected]> # Conflicts: # src/App.tsx # src/components/HoldersForm.tsx # src/dictionary/en.json
Signed-off-by: Stanislaw <[email protected]>
…threshold-for-each Signed-off-by: Stanislaw <[email protected]> # Conflicts: # src/App.tsx # src/components/HoldersForm.tsx # src/dictionary/en.json # src/utils/formSchema.ts
const filterData = (responses: Balance[][], isAllConditionsRequired: boolean): Balance[] => { | ||
let data = responses.flatMap((response) => response); | ||
|
||
if (!response.ok) { | ||
throw new Error(`${dictionary.httpError} ${response.status}`); | ||
} | ||
if (isAllConditionsRequired) { | ||
return data.filter( | ||
(balance, index, self) => | ||
self.findIndex((b) => b.account === balance.account) === index && | ||
responses.every((response) => response.some((b) => b.account === balance.account)), | ||
); | ||
} else { | ||
return data.filter((balance, index, self) => self.findIndex((b) => b.account === balance.account) === index); | ||
} | ||
}; |
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.
Maybe write a unit test for it
This PR is too outdated regarding #18 |
This PR is too outdated regarding #18 |
Fixes #16