Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const useStyles = makeStyles()((theme) => ({
backgroundColor: theme.palette.mode === 'dark' ? 'rgba(250, 250, 250, 0.2)' : 'rgba(0, 0, 0, 0.2)',
backgroundClip: 'padding-box',
},
overflow: 'hidden',
},
}))
enum CreateNFTAvatarStep {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ export function NFTListDialog(props: NFTListDialogProps) {
const { classes } = useStyles()
const currentPluginId = useCurrentWeb3NetworkPluginID()
const account = useAccount(currentPluginId)
const currentChainId = useChainId<'all'>(currentPluginId)
const [chainId, setChainId] = useState<ChainId>(currentChainId as ChainId)
const currentChainId = useChainId(currentPluginId)
const [chainId, setChainId] = useState<ChainId>((currentChainId ?? ChainId.Mainnet) as ChainId)
const [open_, setOpen_] = useState(false)
const [selectedAccount, setSelectedAccount] = useState(account ?? wallets?.[0]?.identity ?? '')
const [selectedPluginId, setSelectedPluginId] = useState(currentPluginId)
const [selectedPluginId, setSelectedPluginId] = useState(currentPluginId ?? NetworkPluginID.PLUGIN_EVM)
const [selectedToken, setSelectedToken] = useState<AllChainsNonFungibleToken | undefined>(tokenInfo)
const [disabled, setDisabled] = useState(false)
const t = useI18N()
Expand Down Expand Up @@ -237,7 +237,7 @@ export function NFTListDialog(props: NFTListDialogProps) {
selectedPluginId === NetworkPluginID.PLUGIN_SOLANA
? (x) => x.tokenId
: (x) => x.contract?.address.toLowerCase() + x.tokenId,
)
).filter((x) => x.chainId === chainId)

const NoNFTList = () => {
if (!collectibles.length && !loadFinish && !loadError) {
Expand Down
6 changes: 3 additions & 3 deletions packages/mask/src/plugins/Avatar/SNSAdaptor/NFTImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import type { AllChainsNonFungibleToken } from '../types'
const useStyles = makeStyles()((theme) => ({
imgBackground: {
position: 'relative',
padding: 4,
padding: 6,
borderRadius: '100%',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
},
icon: {
position: 'absolute',
top: 2,
right: 2,
top: 8,
right: 13,
width: 20,
height: 20,
color: theme.palette.primary.main,
Expand Down
1 change: 0 additions & 1 deletion packages/mask/src/plugins/Avatar/Services/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export async function saveAvatar(account: string, network: EnhanceableSite, avat
await setAddress(network, avatar.userId, avatar.pluginId ?? NetworkPluginID.PLUGIN_EVM, account)
await NFTAvatarStorage(network).set(avatar.userId, {
...avatar,
address: avatar.pluginId === NetworkPluginID.PLUGIN_SOLANA ? avatar.tokenId : avatar.address,
sign,
})

Expand Down
3 changes: 1 addition & 2 deletions packages/mask/src/plugins/Avatar/hooks/save/useSave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ export function useSave(pluginId: NetworkPluginID, chainId: ChainId) {
persona: ECKeyIdentifier,
proof: BindingProof,
) => {
if (pluginId === NetworkPluginID.PLUGIN_SOLANA && !token.tokenId) return
if (pluginId !== NetworkPluginID.PLUGIN_SOLANA && (!token.contract?.address || !token.tokenId)) return
if (!token.contract?.address || !token.tokenId) return
const info: NextIDAvatarMeta = {
pluginId,
nickname: data.nickname,
Expand Down
4 changes: 2 additions & 2 deletions packages/mask/src/plugins/Avatar/hooks/useNFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export function useNFT(
chainId,
})
return {
amount: asset?.price?.[CurrencyType.NATIVE] ?? '0',
amount: asset?.price?.[CurrencyType.USD] ?? '0',
name: asset?.contract?.name ?? '',
symbol: asset?.contract?.symbol ?? 'ETH',
symbol: asset?.payment_tokens?.[0].symbol ?? 'ETH',
image: asset?.metadata?.imageURL ?? '',
owner: asset?.owner?.address ?? asset?.ownerId ?? '',
slug: asset?.collection?.slug ?? '',
Expand Down
8 changes: 3 additions & 5 deletions packages/mask/src/plugins/Avatar/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ export function formatPrice(amount: string, symbol: string) {

export function formatText(name: string, tokenId: string) {
const _name = name.replace(/#\d*/, '').trim()
let token = tokenId
if (tokenId.length > 10) {
token = tokenId.slice(0, 6) + '...' + tokenId.slice(-4)
}
return `${_name} #${token}`
const __name = `${_name} #${tokenId}`
if (__name.length > 35) return `${__name.slice(0, 35)}...`
return __name
}

export function formatTokenId(symbol: string, tokenId: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ const useInjectedDialogClassesOverwriteTwitter = makeStyles()((theme) => {
display: 'block !important',
margin: 12,
},
'&::-webkit-scrollbar': {
display: 'none',
},
},
dialogTitle: {
display: 'grid',
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-infra/src/web3-helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ export declare namespace Web3Helper {
export type Web3HubAll = Hub<
Definition[NetworkPluginID]['ChainId'],
Definition[NetworkPluginID]['SchemaType'],
Definition[NetworkPluginID]['GasOption'],
Definition[NetworkPluginID]['Transaction']
Definition[NetworkPluginID]['GasOption']
>

export type Web3StateAll = Web3Plugin.ObjectCapabilities.Capabilities<
Expand Down
4 changes: 3 additions & 1 deletion packages/plugins/EVM/src/state/Hub/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ class Hub implements EVM_Hub {
[SourceType.Alchemy_EVM]: Alchemy_EVM,
}
const predicate = createPredicate(Object.keys(providers) as Array<keyof typeof providers>)
const filteredProviders = predicate(sourceType) ? [providers[sourceType]] : [Alchemy_EVM, OpenSea, Rarible]
const defaultProviders =
options?.chainId === ChainId.Mainnet ? [OpenSea, Alchemy_EVM, Rarible] : [Alchemy_EVM, OpenSea, Rarible]
const filteredProviders = predicate(sourceType) ? [providers[sourceType]] : defaultProviders
return attemptUntil(
filteredProviders.map((x) => () => x.getAsset(address, tokenId, options)),
undefined,
Expand Down
6 changes: 1 addition & 5 deletions packages/web3-providers/src/alchemy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,7 @@ function createNFTAsset_EVM(
slug: '',
description: metaDataResponse.description,
},
link: resolveOpenSeaLink(
metaDataResponse?.contract?.address,
Number.parseInt(metaDataResponse.id?.tokenId, 16).toString(),
chainId,
),
link: resolveOpenSeaLink(metaDataResponse?.contract?.address, metaDataResponse.id?.tokenId, chainId),
owner: {
address: first(ownersResponse?.owners),
},
Expand Down
11 changes: 9 additions & 2 deletions packages/web3-providers/src/opensea/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type {
OpenSeaCustomAccount,
OpenSeaResponse,
} from './types'
import { getOrderUSDPrice, toImage } from './utils'
import { getOrderUnitPrice, getOrderUSDPrice, toImage } from './utils'
import { OPENSEA_ACCOUNT_URL, OPENSEA_API_URL } from './constants'

async function fetchFromOpenSea<T>(url: string, chainId: ChainId, apiKey?: string) {
Expand Down Expand Up @@ -123,7 +123,7 @@ function createNFTAsset(chainId: ChainId, asset: OpenSeaResponse): NonFungibleAs
)
return {
...createNFTToken(chainId, asset),
link: asset.opensea_link,
link: asset.opensea_link ?? asset.permalink,
payment_tokens: orderTokens.concat(offerTokens),
auction: isAfter(Date.parse(`${asset.endTime ?? ''}Z`), Date.now())
? {
Expand All @@ -148,6 +148,13 @@ function createNFTAsset(chainId: ChainId, asset: OpenSeaResponse): NonFungibleAs
type: x.trait_type,
value: x.value,
})),
price: {
[CurrencyType.USD]: getOrderUnitPrice(
asset.last_sale?.total_price,
asset.last_sale?.payment_token.decimals,
asset.last_sale?.quantity ?? '1',
)?.toString(),
},
orders: asset.orders
?.sort((a, z) =>
new BigNumber(getOrderUSDPrice(z.current_price, z.payment_token_contract?.usd_price) ?? 0)
Expand Down
2 changes: 2 additions & 0 deletions packages/web3-providers/src/opensea/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface AssetEvent {
payment_token: {
decimals: number
}
quantity: string
}

export interface OpenSeaAssetContract extends OpenSeaFees {
Expand Down Expand Up @@ -166,6 +167,7 @@ export interface OpenSeaResponse extends Asset {
}>
creator: OpenSeaCustomAccount
endTime: string
permalink: string
}

interface Transaction {
Expand Down