Skip to content

Commit

Permalink
unit tests checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
TateB committed Sep 13, 2023
1 parent cf92d2a commit 16db150
Show file tree
Hide file tree
Showing 17 changed files with 508 additions and 464 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { ScrollBox } from '@ensdomains/thorin'
import { RecordInput } from '@app/components/@molecules/RecordInput/RecordInput'
import useAdvancedEditor from '@app/hooks/useAdvancedEditor'
import { convertFormSafeKey, formSafeKey } from '@app/utils/editor'
import { validateCryptoAddress } from '@app/utils/validate'
import { validateAbi } from '@app/validators/validateAbi'
import { validateCryptoAddress } from '@app/validators/validateAddress'
import { validateContentHash } from '@app/validators/validateContentHash'

const TabContentsContainer = styled.div(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export const profileRecordsToRecordOptions = (
if (record.type === 'addr') {
return {
...options,
coinTypes: [
coins: [
...(options.coins?.filter((r) => r.coin !== recordItem.key) || []),
recordItem,
{ coin: key, value },
],
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/hooks/abilities/useAbilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,27 @@ export const DEFAULT_ABILITIES: Abilities = {
canSendManager: false,
}

export const useAbilities = (name: string) => {
type UseAbilitiesParameters = {
name: string
enabled?: boolean
}

export const useAbilities = ({ name, enabled = true }: UseAbilitiesParameters) => {
const { t } = useTranslation('profile')
const parent = name?.split('.')?.slice(1).join('.')

const { address } = useAccountSafely()

const basicNameData = useBasicName({ name, enabled: !!name && !!address })
const basicNameData = useBasicName({ name, enabled: enabled && !!name && !!address })

const resolverAuthorisation = useResolverIsAuthorised({
name,
enabled: !!name && !!address,
enabled: enabled && !!name && !!address,
})

const parentBasicNameData = useBasicName({
name: parent,
enabled: !!parent && !!address,
enabled: enabled && !!parent && !!address,
})

// useHasSubnames checks internally if name exists & if it is subname before it enables itself
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/ensjs/public/usePrimaryName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const usePrimaryName = <TParams extends UsePrimaryNameParameters>({
if (!res || !res.name || (!res.match && !allowMismatch)) return null
return {
...res,
name: res.name as string | undefined,
name: res.name as string,
beautifiedName: tryBeautify(res.name),
}
},
Expand Down
Loading

0 comments on commit 16db150

Please sign in to comment.