typescript-sdk
typescript-sdk copied to clipboard
[Bug]: `marketplace.getAllListings()` is cripplingly slow.
Prerequisites
- [x] I have checked that
@thirdweb-dev/sdk
is on the latest stable version and the bug still exists. - [x] I have checked existing issues and I was unable to find a duplicate of this.
Optional
- [ ] I am willing to contribute a PR that fixes the problem with some guidance.
Describe the bug I have a marketplace contract created with ThirdWeb. I have 2 direct listings on my marketplace. When i retrieve listings from the marketplace with the ThirdWeb SDK, it takes up to 10 seconds, even when using Alchemy provider. This results in page loads up to 10 seconds, which is simply unacceptable from an end-users perspective.
Expected behavior Getting marketplace listings should be a fast operation, so that user's don't need to wait ages for listings to load.
Screenshots If applicable, add screenshots to help explain your problem.
Package versions (please complete the following information):
-
@thirdweb-dev/sdk
: [^2.3.11] -
node
: [v16.13.0] -
typescript
(if applicable): [~4.6.2] - Any other build tools (
react
,next
,angular
,vue
, etc.): [vite]
Reproduction link If you have a reproducible project on CodeSandbox, Replit, or GitHub, link it here. (This will make it much easier for us to reproduce and fix your issue.)
Additional context Add any other context about the problem here.
Hey @skoshx ! Sorry for the late reply on this. There's a few things that we fetch for each listing: the info from the marketplace contract, the info from the listed NFT (including the metadata from ipfs) and the info from the ERC20 currency if any. All of that happens in parallel so it should be pretty decent performance.
One thing we could do is provide a minimal getAll call that only retrieves the raw information from the marketplace contract, and let the user fetch additional information lazily. Would that help in your case?
@joaquim-verges Hello, sorry for my cripplingly slow answer, I have been really busy! Anyways, yeah I think either another function that only gets raw information like you mentioned or add an option of something like includeMetadata
to the filter
object of marketplace.getAllListings()
.