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

Feat: Multiple tokens form #17

Conversation

StanislawMazowieckiAriane
Copy link
Contributor

Fixes #16

src/App.tsx Outdated
Comment on lines 80 to 84
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);
Copy link
Collaborator

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

Copy link
Contributor Author

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
Comment on lines +58 to +70
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);
}
};

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

@StanislawMazowieckiAriane
Copy link
Contributor Author

This PR is too outdated regarding #18
It contains several bugs etc which are fixed in the new PR.
Closing

@StanislawMazowieckiAriane
Copy link
Contributor Author

This PR is too outdated regarding #18
It contains several bugs etc which are fixed in the new PR.
Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[THL] Ability to add multiple tokens and a threshold for each
3 participants