project-serum / serum-dex-ui

Example implementation of a UI for the Serum DEX
Other
356 stars 538 forks source link

`getMultipleSolanaAccounts` fails when over 100 accounts are provided on the Balances page #90

Open ghost opened 3 years ago

ghost commented 3 years ago

Description

When accessing the Balances page on a heavily-traded Solana account, the following occurs and all of the rows of Balances disappear. Additionally, the "Settle All Funds" button doesn't work.

Error: failed to get info about accounts 7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU, Cpnxh12vMv9xWRxe1TnxZC34KWyftP7JHacjZFTR3dDk, MAPS41MDahZ9QdKXhVa4dWB9RuyfV4XqhyAZ8XcYepb, 8S94Ze8WWHGiFMUx28LwEviwgHpYD64FkTWVxd5kxDhu, 3GECTP7H4Tww3w8jEPJCJtXUtXxiZty31S9szs84CcwQ, (continued ...) 7ncCLJpP3MNww17LW8bRvx8odQQnubNtfNZBL5BgAEHW, 6ry4WBDvAwAnrYJVv6MCog4J8zx6S3cPgSqnTsDZ73AR, 8sxtSswmQ7Lcd2GjK6am37Z61wJZjA2SzE7Luf7yaKBB, 262cQHT3soHwzuo2oVSy5kAfHcFZ1Jjn8C1GRLcQNKA3, BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW: Too many inputs provided; max 100 at getMultipleSolanaAccounts (send.tsx:925) at async FetchLoopInternal.getAllMintInfo [as fn] (tokens.tsx:194) at async FetchLoopInternal.refresh (fetch-loop.tsx:104)

Proposed Solution

If >= 100 accounts are being looked up, break it up into chunks of 100 or less accounts to query the API. For each chunk of 100 accounts or less, query getMultipleAccounts, then collect the results into a single collection.