Skip to content

Commit

Permalink
update ensjs + tweak misc
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Jan 21, 2024
1 parent 353b511 commit daac13d
Show file tree
Hide file tree
Showing 37 changed files with 232 additions and 272 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
"subgraph:update": "ens-test-env subgraph --var NEXT_PUBLIC_DEPLOYMENT_ADDRESSES"
},
"dependencies": {
"@ensdomains/address-encoder": "^0.2.21",
"@ensdomains/address-encoder": "^1.0.0-rc.3",
"@ensdomains/content-hash": "^3.0.0-beta.5",
"@ensdomains/ens-contracts": "1.0.0",
"@ensdomains/ensjs": "3.0.1",
"@ensdomains/ensjs": "3.1.0",
"@ensdomains/thorin": "0.6.44",
"@metamask/inpage-provider": "^8.1.0",
"@metamask/mobile-provider": "^2.1.0",
Expand Down Expand Up @@ -211,4 +211,4 @@
"[email protected]": "patches/[email protected]"
}
}
}
}
53 changes: 15 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/components/@molecules/AdvancedEditor/textOptions.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled, { css } from 'styled-components'

import supportedTexts from '@app/constants/supportedSocialRecordKeys.json'
import textRecords from '@app/constants/textRecords.json'
import { supportedSocialRecordKeys } from '@app/constants/supportedSocialRecordKeys'
import { textRecords } from '@app/constants/textRecords'
import { formSafeKey } from '@app/utils/editor'

const LabelWrapper = styled.div(
Expand All @@ -10,7 +10,7 @@ const LabelWrapper = styled.div(
`,
)

export const textOptions = [...textRecords, ...supportedTexts].map((key) => ({
export const textOptions = [...textRecords, ...supportedSocialRecordKeys].map((key) => ({
value: formSafeKey(key),
label: key,
node: <LabelWrapper>{key}</LabelWrapper>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled, { css } from 'styled-components'
import { Select } from '@ensdomains/thorin'

import { DynamicSocialIcon, socialIconTypes } from '@app/assets/social/DynamicSocialIcon'
import supportedTexts from '@app/constants/supportedSocialRecordKeys.json'
import { supportedSocialRecordKeys } from '@app/constants/supportedSocialRecordKeys'
import { formSafeKey } from '@app/utils/editor'
import { getSocialData } from '@app/utils/getSocialData'

Expand All @@ -16,7 +16,7 @@ const IconWrapper = styled.div(
`,
)

const accountsOptions = supportedTexts.reduce(
const accountsOptions = supportedSocialRecordKeys.reduce(
(list, account) => {
const socialData = getSocialData(account, '')
if (!socialData) return list
Expand Down
10 changes: 5 additions & 5 deletions src/components/@molecules/ProfileEditor/options/otherOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import { ComponentProps } from 'react'

import { Select } from '@ensdomains/thorin'

import supportedProfileItems from '@app/constants/supportedGeneralRecordKeys.json'
import supportedTexts from '@app/constants/supportedSocialRecordKeys.json'
import textRecords from '@app/constants/textRecords.json'
import { supportedGeneralRecordKeys } from '@app/constants/supportedGeneralRecordKeys'
import { supportedSocialRecordKeys } from '@app/constants/supportedSocialRecordKeys'
import { textRecords } from '@app/constants/textRecords'
import { formSafeKey } from '@app/utils/editor'

const excludedKeys = ['avatar', 'banner']

const otherOptions = textRecords
.filter(
(record) =>
!supportedTexts.includes(record) &&
!supportedProfileItems.includes(record) &&
!supportedGeneralRecordKeys.includes(record as (typeof supportedGeneralRecordKeys)[number]) &&
!supportedSocialRecordKeys.includes(record as (typeof supportedSocialRecordKeys)[number]) &&
!excludedKeys.includes(record),
)
.map((key) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import styled, { css } from 'styled-components'

import {
ContentHashIconType,
DynamicContentHashIcon,
} from '@app/assets/contentHash/DynamicContentHashIcon'
import supportedContentHashKeys from '@app/constants/supportedContentHashKeys.json'
import { DynamicContentHashIcon } from '@app/assets/contentHash/DynamicContentHashIcon'
import { supportedContentHashKeys } from '@app/constants/supportedContentHashKeys'
import { formSafeKey } from '@app/utils/editor'

const IconWrapper = styled.div(
Expand All @@ -21,7 +18,7 @@ const LabelWrapper = styled.div(
`,
)

export default (supportedContentHashKeys as ContentHashIconType[]).map((value) => ({
export default supportedContentHashKeys.map((value) => ({
value: formSafeKey(value),
label: value.toUpperCase(),
node: <LabelWrapper>{value.toUpperCase()}</LabelWrapper>,
Expand Down
18 changes: 13 additions & 5 deletions src/components/pages/profile/ProfileDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Button, Helper, mq, Typography } from '@ensdomains/thorin'
import { CacheableComponent } from '@app/components/@atoms/CacheableComponent'
import { DisabledButtonWithTooltip } from '@app/components/@molecules/DisabledButtonWithTooltip'
import coinsWithIcons from '@app/constants/coinsWithIcons.json'
import supportedProfileItems from '@app/constants/supportedGeneralRecordKeys.json'
import supportedTexts from '@app/constants/supportedSocialRecordKeys.json'
import { supportedGeneralRecordKeys } from '@app/constants/supportedGeneralRecordKeys'
import { supportedSocialRecordKeys } from '@app/constants/supportedSocialRecordKeys'
import { useOwners } from '@app/hooks/useOwners'
import { useProfileActions } from '@app/hooks/useProfileActions'
import { useBreakpoint } from '@app/utils/BreakpointProvider'
Expand Down Expand Up @@ -309,8 +309,12 @@ export const ProfileDetails = ({
...textRecords
.filter(
(x) =>
!supportedTexts.includes(x.key.toLowerCase()) &&
!supportedProfileItems.includes(x.key.toLowerCase()),
!supportedSocialRecordKeys.includes(
x.key.toLowerCase() as (typeof supportedSocialRecordKeys)[number],
) &&
!supportedGeneralRecordKeys.includes(
x.key.toLowerCase() as (typeof supportedGeneralRecordKeys)[number],
),
)
.map((x) => ({ ...x, type: 'text' })),
...(_contentHash ? [{ key: 'contenthash', type: 'contenthash', value: _contentHash }] : []),
Expand All @@ -331,7 +335,11 @@ export const ProfileDetails = ({
label="accounts"
condition={
textRecords &&
textRecords.filter((x) => supportedTexts.includes(x.key.toLowerCase())).length > 0
textRecords.filter((x) =>
supportedSocialRecordKeys.includes(
x.key.toLowerCase() as (typeof supportedSocialRecordKeys)[number],
),
).length > 0
}
array={textRecords}
button={SocialProfileButton}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { stringToHex } from 'viem'
import { getProtocolType, RecordOptions } from '@ensdomains/ensjs/utils'

import { ProfileRecord, ProfileRecordGroup, sortValues } from '@app/constants/profileRecordOptions'
import supportedGeneralRecordKeys from '@app/constants/supportedGeneralRecordKeys.json'
import supportedAccounts from '@app/constants/supportedSocialRecordKeys.json'
import { supportedGeneralRecordKeys } from '@app/constants/supportedGeneralRecordKeys'
import { supportedSocialRecordKeys } from '@app/constants/supportedSocialRecordKeys'
import type { ProfileEditorForm } from '@app/hooks/useProfileEditorForm'
import { Profile } from '@app/types'
import { contentHashToString, getContentHashProvider } from '@app/utils/contenthash'
Expand Down Expand Up @@ -146,9 +146,11 @@ export const profileToProfileRecords = (profile?: Profile): ProfileRecord[] => {
}
}
/* eslint-disable no-nested-ternary */
const group: ProfileRecordGroup = supportedGeneralRecordKeys.includes(key as string)
const group: ProfileRecordGroup = supportedGeneralRecordKeys.includes(
key as (typeof supportedGeneralRecordKeys)[number],
)
? 'general'
: supportedAccounts.includes(key as string)
: supportedSocialRecordKeys.includes(key as (typeof supportedSocialRecordKeys)[number])
? 'social'
: 'custom'
/* eslint-enable no-nested-ternary */
Expand Down
4 changes: 0 additions & 4 deletions src/constants/coinList.ts

This file was deleted.

13 changes: 6 additions & 7 deletions src/constants/constants.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import * as coins from '@ensdomains/address-encoder/coins'

import coinsWithIcons from '@app/constants/coinsWithIcons.json'
import coinsWithoutIcons from '@app/constants/coinsWithoutIcons.json'

import COIN_LIST from './coinList'
const COIN_LIST = Object.keys(coins).filter((x) => !x.endsWith('Legacy'))

describe('coins', () => {
it('coins with and without icons should cover all the coins in coinlist', () => {
const isIncluded = COIN_LIST.every((coin) => {
const coinName = coin.toLowerCase()
return coinsWithIcons.includes(coinName) || coinsWithoutIcons.includes(coinName)
})
describe('coins with and without icons should cover all coins in coinlist', () => {
it.each(COIN_LIST)('coin %s should be in coinlist', (coinName) => {
const isIncluded = coinsWithIcons.includes(coinName) || coinsWithoutIcons.includes(coinName)
expect(isIncluded).toBe(true)
})
})
8 changes: 4 additions & 4 deletions src/constants/profileRecordOptions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import coinsWithIcons from '@app/constants/coinsWithIcons.json'
import coinsWithoutIcons from '@app/constants/coinsWithoutIcons.json'
import supportedContentHashKeys from '@app/constants/supportedContentHashKeys.json'
import supportedGeneralRecordKeys from '@app/constants/supportedGeneralRecordKeys.json'
import supportedOtherRecordKeys from '@app/constants/supportedOtherRecordKeys.json'
import supportedSocialRecordKeys from '@app/constants/supportedSocialRecordKeys.json'
import { supportedContentHashKeys } from '@app/constants/supportedContentHashKeys'
import { supportedGeneralRecordKeys } from '@app/constants/supportedGeneralRecordKeys'
import { supportedOtherRecordKeys } from '@app/constants/supportedOtherRecordKeys'
import { supportedSocialRecordKeys } from '@app/constants/supportedSocialRecordKeys'

export type ProfileRecordGroup =
| 'general'
Expand Down
1 change: 0 additions & 1 deletion src/constants/supportedAddresses.json

This file was deleted.

1 change: 1 addition & 0 deletions src/constants/supportedAddresses.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const supportedAddresses = ['eth', 'btc', 'bnb', 'doge', 'ltc', 'dot', 'sol'] as const
1 change: 0 additions & 1 deletion src/constants/supportedContentHashKeys.json

This file was deleted.

1 change: 1 addition & 0 deletions src/constants/supportedContentHashKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const supportedContentHashKeys = ['ipfs', 'swarm', 'onion', 'skynet', 'arweave'] as const
1 change: 0 additions & 1 deletion src/constants/supportedGeneralRecordKeys.json

This file was deleted.

1 change: 1 addition & 0 deletions src/constants/supportedGeneralRecordKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const supportedGeneralRecordKeys = ['name', 'description', 'url', 'location'] as const
1 change: 0 additions & 1 deletion src/constants/supportedOtherRecordKeys.json

This file was deleted.

1 change: 1 addition & 0 deletions src/constants/supportedOtherRecordKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const supportedOtherRecordKeys = ['abi'] as const
1 change: 0 additions & 1 deletion src/constants/supportedSocialRecordKeys.json

This file was deleted.

Loading

0 comments on commit daac13d

Please sign in to comment.