refactor: remove unused nft utils (#5239)

This commit is contained in:
vignesh mohankumar 2022-11-15 18:36:05 -05:00 committed by GitHub
parent 49b09148c6
commit c7f0af6902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 0 additions and 209 deletions

@ -13,7 +13,3 @@ export function shortenAddress(address: string, charsStart = 4, charsEnd?: numbe
return `${address.substring(0, charsStart + 2)}...${address.substring(42 - (charsEnd || charsStart))}` return `${address.substring(0, charsStart + 2)}...${address.substring(42 - (charsEnd || charsStart))}`
} }
export function shortenEnsName(name?: string): string | undefined {
return !name || name.length <= 12 ? name : `${name.substring(0, 6)}...eth`
}

@ -1,48 +0,0 @@
import { Signer } from '@ethersproject/abstract-signer'
import { Contract } from '@ethersproject/contracts'
import type { BaseProvider } from '@ethersproject/providers'
const looksRareContract = new Contract('0xea37093ce161f090e443f304e1bf3a8f14d7bb40', [
{
anonymous: false,
inputs: [
{ indexed: true, internalType: 'address', name: 'user', type: 'address' },
{ indexed: true, internalType: 'uint256', name: 'rewardRound', type: 'uint256' },
{ indexed: false, internalType: 'uint256', name: 'amount', type: 'uint256' },
],
name: 'RewardsClaim',
type: 'event',
},
{
inputs: [
{ internalType: 'uint256', name: 'amount', type: 'uint256' },
{ internalType: 'bytes32[]', name: 'merkleProof', type: 'bytes32[]' },
],
name: 'claim',
outputs: [],
stateMutability: 'nonpayable',
type: 'function',
},
{
inputs: [{ internalType: 'address', name: '', type: 'address' }],
name: 'amountClaimedByUser',
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
stateMutability: 'view',
type: 'function',
},
])
export const getClaimedAmount = async ({ address, provider }: { address: string; provider: BaseProvider }) =>
provider && (await looksRareContract.connect(provider).amountClaimedByUser(address))
export const claimLooks = async ({
signer,
looksTotal,
proof,
}: {
signer: Signer
looksTotal: string
proof: string[]
}) => {
await looksRareContract.connect(signer).functions.claim(looksTotal, proof)
}

@ -1,20 +1 @@
export const foregrounds = ['#001FAA', '#5D31FF', '#8EC3E4', '#F10B00', '#E843D3', '#C4B5FC', '#F88DD5']
export const backgrounds = ['#5DCCB9', '#9AFBCF', '#D1F8E7', '#73F54B', '#D3FB51', '#FCF958'] export const backgrounds = ['#5DCCB9', '#9AFBCF', '#D1F8E7', '#73F54B', '#D3FB51', '#FCF958']
export function hashCode(text: string) {
let hash = 0
if (text.length === 0) return hash
for (let i = 0; i < text.length; i++) {
const chr = text.charCodeAt(i)
hash = (hash << 3) - hash + chr
hash |= 0
}
return hash
}
export function addressToHashedColor(colors: string[], address: string | null): string | undefined {
if (address == null) return undefined
return colors[Math.abs(hashCode(address.toLowerCase()) % colors.length)]
}

@ -1,72 +0,0 @@
export function consentRequired(tz: string): boolean {
switch (tz) {
case 'Europe/Vienna':
return true
case 'Europe/Brussels':
return true
case 'Europe/Sofia':
return true
case 'Europe/Zagreb':
return true
case 'Asia/Famagusta':
return true
case 'Asia/Nicosia':
return true
case 'Europe/Prague':
return true
case 'Europe/Copenhagen':
return true
case 'Europe/Tallinn':
return true
case 'Europe/Helsinki':
return true
case 'Europe/Paris':
return true
case 'Europe/Berlin':
return true
case 'Europe/Busingen':
return true
case 'Europe/Athens':
return true
case 'Europe/Budapest':
return true
case 'Europe/Dublin':
return true
case 'Europe/Rome':
return true
case 'Europe/Riga':
return true
case 'Europe/Vilnius':
return true
case 'Europe/Luxembourg':
return true
case 'Europe/Malta':
return true
case 'Europe/Amsterdam':
return true
case 'Europe/Warsaw':
return true
case 'Atlantic/Azores':
return true
case 'Atlantic/Madeira':
return true
case 'Europe/Lisbon':
return true
case 'Europe/Bucharest':
return true
case 'Europe/Bratislava':
return true
case 'Europe/Ljubljana':
return true
case 'Africa/Ceuta':
return true
case 'Atlantic/Canary':
return true
case 'Europe/Madrid':
return true
case 'Europe/Stockholm':
return true
default:
return false
}
}

@ -1,6 +0,0 @@
export const groupBy = <T>(xs: T[], key: string) => {
return xs.reduce((rv: any, x: any) => {
;(rv[x[key]] = rv[x[key]] || []).push(x)
return rv
}, {})
}

@ -1,25 +0,0 @@
import { Provider } from '@ethersproject/abstract-provider'
import { Contract } from '@ethersproject/contracts'
import ERC721 from '../../abis/erc721.json'
import { TokenType } from '../types'
export const isAssetOwnedByUser = async ({
tokenId,
assetAddress,
userAddress,
tokenType,
provider,
}: {
tokenId: string
assetAddress: string
userAddress: string
tokenType: TokenType
provider: Provider
}) => {
if (tokenType === TokenType.ERC721) {
const c = new Contract(assetAddress, ERC721, provider)
return (await c.functions.ownerOf(tokenId)) === userAddress
} else return false
}

@ -1,11 +0,0 @@
const iOSDevices = ['iPhone', 'iPad', 'iPod', 'iPhone Simulator', 'iPod Simulator', 'iPad Simulator']
export const isIPhoneOrSafari = () => {
const uA = navigator.userAgent
const vendor = navigator.vendor
const platform = navigator.platform
return (
iOSDevices.includes(platform) || (/Safari/i.test(uA) && /Apple Computer/.test(vendor) && !/Mobi|Android/i.test(uA))
)
}

@ -6,13 +6,6 @@ export const isNumber = (s: string): boolean => {
return reg.test(s) && !isNaN(parseFloat(s)) && isFinite(parseFloat(s)) return reg.test(s) && !isNaN(parseFloat(s)) && isFinite(parseFloat(s))
} }
export const formatPercentage = (percentage: string): string => {
if (!percentage) return '-'
return `${parseFloat(percentage)
.toFixed(2)
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}%`
}
export const floorFormatter = (n: number): string => { export const floorFormatter = (n: number): string => {
if (n === 0) return '0.00' if (n === 0) return '0.00'
if (!n) return '' if (!n) return ''

@ -1,6 +1,5 @@
// change this if we change the fallback provider // change this if we change the fallback provider
export const fallbackProvider = 'PopRank' export const fallbackProvider = 'PopRank'
export const shouldLinkToFallbackProvider = false
export const fallbackProviderLogo = '/nft/logos/poprank.png' export const fallbackProviderLogo = '/nft/logos/poprank.png'
/** /**

@ -1,3 +0,0 @@
export const shortenId = (id: string, chars = 4) => {
return id.length > chars * 2 + 3 ? `${id.substring(0, chars)}...${id.substring(id.length - chars)}` : id
}

@ -1,13 +0,0 @@
export function uniqBy<T>(arr: T[], key: keyof T) {
const seen = new Set()
return arr.filter((it) => {
const val = it[key]
if (seen.has(val)) {
return false
} else {
seen.add(val)
return true
}
})
}