-
Notifications
You must be signed in to change notification settings - Fork 635
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
NFTs: filter instead of throw error when NFT has invalid network #5537
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
945df0b
fix + cleanup
benisgold d1f82ff
improvement
benisgold e665852
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 55c6fbb
add simplehash networks
benisgold cda5b76
cleanup
benisgold 86ce768
rm simplehashchain type
benisgold 80af738
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold 372e0a9
log
benisgold c660d07
fix
benisgold 4adc721
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { NFT_API_KEY, NFT_API_URL } from 'react-native-dotenv'; | ||
import { RainbowFetchClient } from '@/rainbow-fetch'; | ||
import { Network } from '@/helpers'; | ||
import { getSimpleHashChainFromNetwork } from '@/resources/nfts/simplehash/utils'; | ||
import { SimpleHashChain, SimpleHashListing, SimpleHashNFT, SimpleHashMarketplaceId } from '@/resources/nfts/simplehash/types'; | ||
import { RainbowNetworks } from '@/networks'; | ||
import { SimpleHashListing, SimpleHashNFT, SimpleHashMarketplaceId } from '@/resources/nfts/simplehash/types'; | ||
import { RainbowNetworks, getNetworkObj } from '@/networks'; | ||
import { UniqueAsset } from '@/entities'; | ||
import { RainbowError, logger } from '@/logger'; | ||
import { getGnosisNetworkObject } from '@/networks/gnosis'; | ||
|
||
export const START_CURSOR = 'start'; | ||
|
||
|
@@ -20,10 +20,11 @@ export async function fetchSimpleHashNFT( | |
tokenId: string, | ||
network: Omit<Network, Network.goerli> = Network.mainnet | ||
): Promise<SimpleHashNFT | undefined> { | ||
const chain = getSimpleHashChainFromNetwork(network); | ||
const chain = getNetworkObj(network as Network).nfts.simplehashNetwork; | ||
|
||
if (!chain) { | ||
throw new Error(`fetchSimpleHashNFT: no SimpleHash chain for network: ${network}`); | ||
logger.error(new RainbowError(`fetchSimpleHashNFT: no SimpleHash chain for network: ${network}`)); | ||
return; | ||
} | ||
|
||
const response = await nftApi.get(`/nfts/${chain}/${contractAddress}/${tokenId}`, { | ||
|
@@ -41,8 +42,9 @@ export async function fetchSimpleHashNFTs( | |
cursor: string = START_CURSOR | ||
): Promise<{ data: SimpleHashNFT[]; nextCursor: string | null }> { | ||
const chainsParam = RainbowNetworks.filter(network => network.features.nfts) | ||
.map(network => network.nfts?.simplehashNetwork || network.value) | ||
.map(network => network.nfts.simplehashNetwork || network.value) | ||
.join(','); | ||
console.log(chainsParam); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. log |
||
const cursorSuffix = createCursorSuffix(cursor); | ||
const response = await nftApi.get(`/nfts/owners?chains=${chainsParam}&wallet_addresses=${walletAddress}${cursorSuffix}`, { | ||
headers: { | ||
|
@@ -65,7 +67,12 @@ export async function fetchSimpleHashNFTListing( | |
// array of all eth listings on OpenSea for this token | ||
let listings: SimpleHashListing[] = []; | ||
let cursor = START_CURSOR; | ||
const chain = getSimpleHashChainFromNetwork(network); | ||
const chain = getNetworkObj(network as Network).nfts.simplehashNetwork; | ||
|
||
if (!chain) { | ||
logger.error(new RainbowError(`fetchSimpleHashNFTListing: no SimpleHash chain for network: ${network}`)); | ||
return; | ||
} | ||
|
||
while (cursor) { | ||
const cursorSuffix = createCursorSuffix(cursor); | ||
|
@@ -99,10 +106,11 @@ export async function fetchSimpleHashNFTListing( | |
* @param nft | ||
*/ | ||
export async function refreshNFTContractMetadata(nft: UniqueAsset) { | ||
const chain = nft.isPoap ? SimpleHashChain.Gnosis : getSimpleHashChainFromNetwork(nft.network); | ||
const chain = (nft.isPoap ? getGnosisNetworkObject() : getNetworkObj(nft.network)).nfts.simplehashNetwork; | ||
|
||
if (!chain) { | ||
logger.error(new RainbowError(`refreshNFTContractMetadata: no SimpleHash chain for network: ${nft.network}`)); | ||
return; | ||
} | ||
|
||
try { | ||
|
@@ -150,10 +158,11 @@ export async function refreshNFTContractMetadata(nft: UniqueAsset) { | |
* @param nft | ||
*/ | ||
export async function reportNFT(nft: UniqueAsset) { | ||
const chain = nft.isPoap ? SimpleHashChain.Gnosis : getSimpleHashChainFromNetwork(nft.network); | ||
const chain = (nft.isPoap ? getGnosisNetworkObject() : getNetworkObj(nft.network)).nfts.simplehashNetwork; | ||
|
||
if (!chain) { | ||
logger.error(new RainbowError(`reportNFT: no SimpleHash chain for network: ${nft.network}`)); | ||
return; | ||
} | ||
|
||
try { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
dont need the fallback anymore yeah? the null type may end up causing issues here tho 🤔
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.
trueeee