Skip to content

Commit

Permalink
remove legacy route migration from extension
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil committed Jan 22, 2025
1 parent 53dafa4 commit ebfe121
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 496 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import { useCompanionAppUrl } from '@/companion'
import { useExecutionRoute } from '@/execution-routes'
import { Transition } from '@headlessui/react'
import {
getPilotAddress,
getRolesWaypoint,
getStartingWaypoint,
} from '@zodiac/modules'
import type { HexAddress } from '@zodiac/schema'
import { Blockie } from '@zodiac/ui'
import { AlignJustify, Cog } from 'lucide-react'
import { useState } from 'react'
import { Link } from 'react-router'
import Stick from 'react-stick'
import { parsePrefixedAddress } from 'ser-kit'
import { ConnectionStack } from '../../../ConnectionStack'
import { asLegacyConnection } from '../../../legacyConnectionMigrations'

export const RouteBubble = () => {
const route = useExecutionRoute()
const connection = asLegacyConnection(route)
const [hover, setHover] = useState(false)

const pilotAddress = getPilotAddress([getStartingWaypoint(route.waypoints)])
const rolesWaypoint = getRolesWaypoint(route)

return (
<Stick
sameWidth
Expand All @@ -33,21 +41,23 @@ export const RouteBubble = () => {
>
<div className="isolate z-10 pt-2">
<div className="rounded-md border border-zinc-200/80 bg-zinc-100/80 px-4 py-2 shadow-lg backdrop-blur-sm dark:border-zinc-500/80 dark:bg-zinc-900/80">
<ConnectionStack connection={connection} />
<ConnectionStack route={route} />
</div>
</div>
</Transition>
}
>
<div className="flex items-center gap-2 overflow-hidden">
<Blockies
avatarAddress={connection.avatarAddress}
moduleAddress={connection.moduleAddress}
pilotAddress={connection.pilotAddress}
avatarAddress={parsePrefixedAddress(route.avatar)}
moduleAddress={
rolesWaypoint == null ? undefined : rolesWaypoint.account.address
}
pilotAddress={pilotAddress}
/>

<p className="overflow-hidden text-ellipsis whitespace-nowrap">
{connection.label || <span className="italic">Unnamed route</span>}
{route.label || <span className="italic">Unnamed route</span>}
</p>
</div>

Expand Down Expand Up @@ -75,9 +85,9 @@ export const RouteBubble = () => {
}

type BlockiesProps = {
avatarAddress: string
pilotAddress?: string
moduleAddress?: string
avatarAddress: HexAddress
pilotAddress?: HexAddress
moduleAddress?: HexAddress
}

const Blockies = ({
Expand Down
28 changes: 20 additions & 8 deletions deployables/extension/src/panel/pages/ConnectionStack/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import type { LegacyConnection } from '@/types'
import { ZODIAC_MODULE_NAMES } from '@zodiac/modules'
import type { ExecutionRoute } from '@/types'
import { invariant } from '@epic-web/invariant'
import {
getModuleName,
getPilotAddress,
getRolesWaypoint,
} from '@zodiac/modules'
import { parsePrefixedAddress } from 'ser-kit'
import { Address } from './Address'

interface Props {
connection: LegacyConnection
route: ExecutionRoute
}

export const ConnectionStack = ({ connection }: Props) => {
const { avatarAddress, moduleAddress, pilotAddress, moduleType } = connection
export const ConnectionStack = ({ route }: Props) => {
invariant(route.waypoints != null, 'Cannot render route without waypoints')

const pilotAddress = getPilotAddress(route.waypoints)
const avatarAddress = parsePrefixedAddress(route.avatar)

const rolesWaypoint = getRolesWaypoint(route)

return (
<div className="flex flex-col gap-2">
<div className="flex items-center justify-between">
Expand All @@ -16,13 +28,13 @@ export const ConnectionStack = ({ connection }: Props) => {
<Address address={pilotAddress} />
</div>

{moduleAddress && (
{rolesWaypoint != null && (
<div className="flex items-center justify-between">
<div className="text-sm">
{(moduleType && ZODIAC_MODULE_NAMES[moduleType]) || 'Zodiac'} Mod
{getModuleName(rolesWaypoint.account)} Mod
</div>

<Address address={moduleAddress} />
<Address address={rolesWaypoint.account.address} />
</div>
)}

Expand Down

This file was deleted.

Loading

0 comments on commit ebfe121

Please sign in to comment.