From 4d1e29a4a4020f5da077a9682ac9848d3652bd5c Mon Sep 17 00:00:00 2001 From: Philipp Giese <187786+frontendphil@users.noreply.github.com> Date: Thu, 9 Jan 2025 16:10:30 +0100 Subject: [PATCH] feat: show chain select in companion app (#501) * pull in chain select and add failing test * update ser-kit * shim process.env * make chainSelect semi-controllable * adjust spec --- .../app/app/components/ChainSelect.tsx | 40 ++++++++++++++++ deployables/app/app/components/index.ts | 1 + deployables/app/app/routes/edit-route.spec.ts | 48 +++++++++++++++---- deployables/app/app/routes/edit-route.tsx | 12 ++++- deployables/app/package.json | 2 + deployables/app/tsconfig.cloudflare.json | 4 +- deployables/app/tsconfig.json | 3 +- deployables/app/vite.config.ts | 16 ++----- deployables/app/vitest.setup.ts | 9 ++++ deployables/extension/package.json | 2 +- .../routes/edit.$routeId/ChainSelect.tsx | 2 +- packages/chains/package.json | 4 +- packages/schema/package.json | 2 +- packages/test-utils/package.json | 4 +- pnpm-lock.yaml | 33 ++++++++----- 15 files changed, 135 insertions(+), 47 deletions(-) create mode 100644 deployables/app/app/components/ChainSelect.tsx create mode 100644 deployables/app/app/components/index.ts diff --git a/deployables/app/app/components/ChainSelect.tsx b/deployables/app/app/components/ChainSelect.tsx new file mode 100644 index 00000000..c56f0853 --- /dev/null +++ b/deployables/app/app/components/ChainSelect.tsx @@ -0,0 +1,40 @@ +import { invariant } from '@epic-web/invariant' +import { CHAIN_NAME } from '@zodiac/chains' +import { Select } from '@zodiac/ui' +import type { ChainId } from 'ser-kit' + +export interface Props { + value: ChainId | null | undefined + onChange(chainId: ChainId): void +} + +interface Option { + value: ChainId + label: string +} + +const options = Object.entries(CHAIN_NAME).map(([chainId, name]) => ({ + value: parseInt(chainId) as ChainId, + label: name, +})) + +export const ChainSelect = ({ value, onChange }: Props) => ( +