Skip to content

Commit

Permalink
increase type-safety
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil committed Jan 22, 2025
1 parent c37366b commit 3fc3eee
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions deployables/app/app/components/ModSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Option {

interface Props<Option = unknown, Multi extends boolean = boolean>
extends SelectProps<false, Option, Multi> {
avatarAddress: string
avatarAddress: HexAddress
}

export function ModSelect<Multi extends boolean = boolean>({
Expand Down Expand Up @@ -47,7 +47,7 @@ export function ModSelect<Multi extends boolean = boolean>({

type ValueProps = PropsWithChildren<{
label: string
address: string
address: HexAddress
}>

const Value = ({ label, address, children }: ValueProps) => (
Expand Down
2 changes: 1 addition & 1 deletion deployables/app/app/components/ZodiacMod.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const ZodiacMod = ({
}
isDisabled={disabled || isLoading}
placeholder={isLoading ? 'Loading modules...' : 'Select a module'}
avatarAddress={avatar}
avatarAddress={parsePrefixedAddress(avatar)}
/>

{selectedModule?.type === SupportedZodiacModuleType.ROLES_V1 && (
Expand Down
2 changes: 1 addition & 1 deletion deployables/app/app/components/wallet/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type AccountProps = {
}

export const Account = ({ children, type }: AccountProps) => {
const address = validateAddress(children) ?? ''
const address = validateAddress(children)

return (
<AddressInput
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EXPLORER_URL } from '@zodiac/chains'
import type { HexAddress } from '@zodiac/schema'
import { AddressInput, GhostLinkButton } from '@zodiac/ui'
import { getAddress } from 'ethers'
import { SquareArrowOutUpRight } from 'lucide-react'
Expand All @@ -7,7 +8,7 @@ import type { ContractInfo } from '../../../../utils/abi'

interface Props {
chainId: ChainId
address: string
address: HexAddress
contractInfo?: ContractInfo
}

Expand All @@ -21,7 +22,7 @@ export const ContractAddress = ({ chainId, address, contractInfo }: Props) => {
readOnly
label="Contract"
description={contractInfo?.name}
value={checksumAddress}
value={checksumAddress as HexAddress}
action={
<GhostLinkButton
openInNewWindow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { shortenAddress, validateAddress } from '@/utils'
import type { HexAddress } from '@zodiac/schema'
import { Address as BaseAddress, Blockie, Tag } from '@zodiac/ui'
import { Unlink } from 'lucide-react'

interface Props {
address: string
address: HexAddress
}

export const Address = ({ address }: Props) => {
Expand Down
4 changes: 0 additions & 4 deletions packages/modules/src/updateChainId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,5 @@ const updateWaypoint = (
connection: updateConnection(connection, { chainId }),
})
}

default: {
throw new Error(`Cannot update waypoint of type "${account.type}"`)
}
}
}
1 change: 1 addition & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"dependencies": {
"@epic-web/invariant": "^1.0.0",
"@headlessui/react": "^2.2.0",
"@zodiac/chains": "workspace:*",
"@zodiac/schema": "workspace:*",
"classnames": "2.5.1",
"ethereum-blockies-base64": "1.0.2",
Expand Down
8 changes: 6 additions & 2 deletions packages/ui/src/inputs/AddressInput.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { ZERO_ADDRESS } from '@zodiac/chains'
import type { HexAddress } from '@zodiac/schema'
import type { ComponentPropsWithoutRef, ReactNode } from 'react'
import { Blockie } from '../Blockie'
import { type ComposableInputProps, Input } from './Input'
Expand All @@ -7,7 +9,7 @@ type AddressInputProps = Omit<
'id' | 'type' | 'className' | 'value'
> &
ComposableInputProps & {
value?: string
value?: HexAddress | null
action?: ReactNode
}

Expand All @@ -17,6 +19,7 @@ export const AddressInput = ({
error,
action,
disabled,
value,
...props
}: AddressInputProps) => (
<Input
Expand All @@ -27,7 +30,7 @@ export const AddressInput = ({
after={action && <div className="mr-2">{action}</div>}
before={
<Blockie
address={props.value || '0x0000000000000000000000000000000000000000'}
address={value || ZERO_ADDRESS}
className="ml-4 size-5 shrink-0"
/>
}
Expand All @@ -37,6 +40,7 @@ export const AddressInput = ({
{...props}
id={inputId}
disabled={disabled}
value={value ?? ''}
aria-describedby={descriptionId}
aria-errormessage={error ?? undefined}
className="w-full border-none bg-transparent px-4 py-2 font-mono text-sm outline-none"
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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

0 comments on commit 3fc3eee

Please sign in to comment.