Parse one country nft description links; update DC contract address

pull/264/head
artemkolodko 2 years ago
parent 90876edbbf
commit 81758f014a
  1. 3
      .env
  2. 4
      src/components/ui/Search.tsx
  3. 2
      src/config/index.ts
  4. 27
      src/pages/InventoryDetailsPage/InventoryDetailsPage.tsx
  5. 2
      src/utils/oneCountry.ts

@ -7,4 +7,5 @@ REACT_APP_EXPLORER_V1_API_URL=https://ctrver.t.hmny.io/
REACT_APP_INDEXER_IPFS_GATEWAY=https://ipfs.io/ipfs/
REACT_APP_PROD_ADDRESS=https://ws.explorer-v2-api.hmny.io
REACT_APP_CONTRACT_SHARD=0
REACT_APP_ONE_COUNTRY_CONTRACT_ADDRESS=0xeFC73fB07660464aA03A5790D011DA0512c5854f
REACT_APP_ONE_COUNTRY_CONTRACT_ADDRESS=0x547942748Cc8840FEc23daFdD01E6457379B446D
REACT_APP_ONE_COUNTRY_NFT_CONTRACT_ADDRESS=0x4cd2563118e57b19179d8dc033f2b0c5b5d69ff5

@ -17,7 +17,7 @@ import { FixedSizeList as List } from "react-window";
import AutoSizer from "react-virtualized-auto-sizer";
import { Address } from "./Address";
import { config } from "../../config";
import {getAddressByName} from "../../utils/oneCountry";
import {getAddressByName, OneCountryTLD} from "../../utils/oneCountry";
import {toaster} from "../../App";
let timeoutID: any | null = null;
@ -31,7 +31,7 @@ export interface ISearchItem {
const oneCountryPostfix = {
dotOne: '.1',
dotCountry: '.country'
dotCountry: OneCountryTLD
}
export const SearchInput = () => {

@ -27,6 +27,7 @@ const shardUrls = availableShards
const contractShardId = +(process.env.REACT_APP_CONTRACT_SHARD || '0') as ShardID
const oneCountryContractAddress = process.env.REACT_APP_ONE_COUNTRY_CONTRACT_ADDRESS || ''
const oneCountryNFTContractAddress = process.env.REACT_APP_ONE_COUNTRY_NFT_CONTRACT_ADDRESS || ''
const ipfsGateway = process.env.REACT_APP_INDEXER_IPFS_GATEWAY || ''
export const config = {
@ -34,5 +35,6 @@ export const config = {
shardUrls,
contractShardId,
oneCountryContractAddress,
oneCountryNFTContractAddress,
ipfsGateway
}

@ -15,6 +15,7 @@ import { config } from '../../config'
import {ERC1155Icon} from "../../components/ui/ERC1155Icon";
import dayjs from "dayjs";
import {CopyBtn} from "../../components/ui/CopyBtn";
import {OneCountryTLD} from "../../utils/oneCountry";
const AddressLink = styled.a`
text-decoration: none;
@ -127,6 +128,23 @@ const TextEllipsis = styled(Text)`
`
const NotAvailable = 'N/A'
const urlPattern = /([a-zA-Z0-9\-\.]+\.[a-zA-Z]{3,7})|(\n)/g;
const MetaDescription = (props: { text: string, domainParseLinks?: string }) => {
const { text, domainParseLinks: tld } = props
if(tld) {
const richText = text.replace(urlPattern, function(url) {
const link = 'https://' + url
return `<a href="${link}" style="color: #00AEE9;">${url}</a>`
})
return <div dangerouslySetInnerHTML={{ __html: richText }} />
}
return <Box>
{text}
</Box>
}
const NFTDetails = (props: NFTInfoProps) => {
const { tokenERC721, asset, isLoading } = props
@ -134,7 +152,6 @@ const NFTDetails = (props: NFTInfoProps) => {
// const token = tokenERC721 || tokenERC1155 || {}
const meta = asset.meta || {} as any
const metaImage = meta?.image ? meta?.image : ''
const EmptyValue = isLoading ? '' : NotAvailable
const tokenStandard = tokenID ? tokenERC721 ? 'ERC721' : 'ERC1155' : EmptyValue
@ -191,7 +208,13 @@ const NFTDetails = (props: NFTInfoProps) => {
<Text weight={'bold'}>Description</Text>
</Box>
<Box pad={'16px'}>
{asset.meta?.description || EmptyValue}
{asset.meta?.description
? <MetaDescription
text={asset.meta?.description}
domainParseLinks={tokenAddress === config.oneCountryNFTContractAddress ? OneCountryTLD : ''}
/>
: EmptyValue
}
</Box>
{meta.attributes &&
<Box border={{ side: 'top' }}>

@ -2,6 +2,8 @@ import { DCEns } from 'one-country-sdk'
import Web3 from "web3";
import { config } from '../config'
export const OneCountryTLD = '.country'
const { oneCountryContractAddress, shardUrls } = config
const provider = new Web3.providers.HttpProvider(shardUrls[0] || '')
const oneCountry = new DCEns({ provider, contractAddress: oneCountryContractAddress })

Loading…
Cancel
Save