diff --git a/src/nft/utils/address.ts b/src/nft/utils/address.ts index 8c2056ec5c..54186c344a 100644 --- a/src/nft/utils/address.ts +++ b/src/nft/utils/address.ts @@ -13,7 +13,3 @@ export function shortenAddress(address: string, charsStart = 4, charsEnd?: numbe 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` -} diff --git a/src/nft/utils/claimLooks.ts b/src/nft/utils/claimLooks.ts deleted file mode 100644 index c4a13f3c81..0000000000 --- a/src/nft/utils/claimLooks.ts +++ /dev/null @@ -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) -} diff --git a/src/nft/utils/colors.ts b/src/nft/utils/colors.ts index 593572464e..33f7829e16 100644 --- a/src/nft/utils/colors.ts +++ b/src/nft/utils/colors.ts @@ -1,20 +1 @@ -export const foregrounds = ['#001FAA', '#5D31FF', '#8EC3E4', '#F10B00', '#E843D3', '#C4B5FC', '#F88DD5'] - 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)] -} diff --git a/src/nft/utils/eu-timezones.ts b/src/nft/utils/eu-timezones.ts deleted file mode 100644 index f82ad2b1fe..0000000000 --- a/src/nft/utils/eu-timezones.ts +++ /dev/null @@ -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 - } -} diff --git a/src/nft/utils/groupBy.ts b/src/nft/utils/groupBy.ts deleted file mode 100644 index 384a80f22b..0000000000 --- a/src/nft/utils/groupBy.ts +++ /dev/null @@ -1,6 +0,0 @@ -export const groupBy = (xs: T[], key: string) => { - return xs.reduce((rv: any, x: any) => { - ;(rv[x[key]] = rv[x[key]] || []).push(x) - return rv - }, {}) -} diff --git a/src/nft/utils/isAssetOwnedByUser.ts b/src/nft/utils/isAssetOwnedByUser.ts deleted file mode 100644 index 70eb858002..0000000000 --- a/src/nft/utils/isAssetOwnedByUser.ts +++ /dev/null @@ -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 -} diff --git a/src/nft/utils/isIPhoneOrSafari.ts b/src/nft/utils/isIPhoneOrSafari.ts deleted file mode 100644 index 9093d63fd7..0000000000 --- a/src/nft/utils/isIPhoneOrSafari.ts +++ /dev/null @@ -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)) - ) -} diff --git a/src/nft/utils/numbers.ts b/src/nft/utils/numbers.ts index f0c78b7fb6..def40ed87d 100644 --- a/src/nft/utils/numbers.ts +++ b/src/nft/utils/numbers.ts @@ -6,13 +6,6 @@ export const isNumber = (s: string): boolean => { 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 => { if (n === 0) return '0.00' if (!n) return '' diff --git a/src/nft/utils/rarity.ts b/src/nft/utils/rarity.ts index c5a423c371..f639192761 100644 --- a/src/nft/utils/rarity.ts +++ b/src/nft/utils/rarity.ts @@ -1,6 +1,5 @@ // change this if we change the fallback provider export const fallbackProvider = 'PopRank' -export const shouldLinkToFallbackProvider = false export const fallbackProviderLogo = '/nft/logos/poprank.png' /** diff --git a/src/nft/utils/shortenId.ts b/src/nft/utils/shortenId.ts deleted file mode 100644 index 130fbff3ff..0000000000 --- a/src/nft/utils/shortenId.ts +++ /dev/null @@ -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 -} diff --git a/src/nft/utils/uniqBy.ts b/src/nft/utils/uniqBy.ts deleted file mode 100644 index d975bc359a..0000000000 --- a/src/nft/utils/uniqBy.ts +++ /dev/null @@ -1,13 +0,0 @@ -export function uniqBy(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 - } - }) -}