-
Notifications
You must be signed in to change notification settings - Fork 173
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
Add getNftSales() #190
Add getNftSales() #190
Conversation
…s endpoint response
…NftSales endpoint
…k-js into nft-api-get-nft-sales
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.
Thanks so much for taking this one on! This was definitely pretty hefty, so we truly appreciate your time and effort!
src/api/nft-namespace.ts
Outdated
* @param options - The optional parameters to use for the request. | ||
* @beta | ||
*/ | ||
getNftSales(options?: GetNftSales): Promise<GetNftSalesResponse>; |
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.
Rename GetNftSales
to GetNftSalesOptions
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.
On it!
* | ||
* @public | ||
*/ | ||
export enum SortingOrder { |
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.
Can we reuse the AssetTransfersOrder
and just re-export it?
ex: export { AssetTransfersOrder as SortingOrder }
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.
Yup, I think it would be a good idea to refactor it later to have one enum representing the supported sorting orders by the API. I didn't do it in this pr to avoid a breaking change with the AssetTransfersOrder
test/unit/nft-api.test.ts
Outdated
mock.onGet().reply(400, 'fromBlock should be a non-negative integer'); | ||
|
||
await expect( | ||
alchemy.nft.summarizeNftAttributes(contractAddress) |
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.
typo: replace with getNftSales()
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.
It seems that I have been swayed by the dark powers of the copy paste 🤣
return NftTakerType.BUYER; | ||
case 'SELLER': | ||
return NftTakerType.SELLER; | ||
default: |
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.
Remove the UNKNOWN
enum since the taker is always guaranteed to be one or the other. Can you throw an error if for some reason we can't parse the enum?
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.
Thanks for the speedy turnaround 👊
Changelog
getNftSales
method in thenft
namespace.GetNftSalesResponse
andNftSale
types to describe the result of thegetNftSales
endpoint.getNftSales
method.Extra
Filtering by the
![image](https://user-images.githubusercontent.com/42520800/201451283-44cc3321-491c-4907-9bd3-172373ca6a1e.png)
taker
field doesn't seem to work correctly, when setting the param to eitherbuyer
orseller
the results from the API don't change and results with the incorrecttaker
value are returned.Filtering by
taker=seller
Filtering by
![image](https://user-images.githubusercontent.com/42520800/201451292-e40cff15-b208-4c1b-b1a1-448bdfbca75d.png)
taker=buyer
Also, the docs mention that the
![image](https://user-images.githubusercontent.com/42520800/201451439-5187d5f0-5c77-4a4c-bf7a-f06178a9d367.png)
fromBlock
andtoBlock
params should accept hex integers as valid values but when setting them as such, the API returns an error so the type in the SDK has been implemented to allow only the types that are working correctly.