From 1ee4c37d81c9f0d04a6c6820f0edd8a79daec2b7 Mon Sep 17 00:00:00 2001 From: yawn <69970183+yawn-c111@users.noreply.github.com> Date: Mon, 16 Dec 2024 21:14:37 +0900 Subject: [PATCH 01/14] wip: tree id --- pkgs/frontend/.env.example | 6 +- pkgs/frontend/abi/bigbang.ts | 240 +++++++++++++++--- pkgs/frontend/app/components/Header.tsx | 7 +- .../app/components/common/CommonIcon.tsx | 6 +- .../app/components/common/CommonInput.tsx | 5 + .../app/components/common/CommonTextarea.tsx | 21 +- .../app/components/icon/WorkspaceIcon.tsx | 1 + pkgs/frontend/app/root.tsx | 2 +- pkgs/frontend/app/routes/$treeId.tsx | 17 ++ pkgs/frontend/app/routes/workspace._index.tsx | 115 +++++++++ pkgs/frontend/app/routes/workspace.new.tsx | 182 +++++++++++++ pkgs/frontend/app/routes/workspace.tsx | 7 - pkgs/frontend/hooks/useBigBang.ts | 52 ++-- pkgs/frontend/hooks/useHats.ts | 30 +-- pkgs/frontend/hooks/useWallet.ts | 73 +++++- 15 files changed, 664 insertions(+), 100 deletions(-) create mode 100644 pkgs/frontend/app/routes/$treeId.tsx create mode 100644 pkgs/frontend/app/routes/workspace._index.tsx create mode 100644 pkgs/frontend/app/routes/workspace.new.tsx delete mode 100644 pkgs/frontend/app/routes/workspace.tsx diff --git a/pkgs/frontend/.env.example b/pkgs/frontend/.env.example index 86c625b..4b9cfab 100644 --- a/pkgs/frontend/.env.example +++ b/pkgs/frontend/.env.example @@ -2,13 +2,13 @@ VITE_CHAIN_ID=11155111 VITE_PRIVY_APP_ID= -VITE_BIGBANG_ADDRESS=0x5d7a64Cc808294C516076d371685ed4E6aDd6337 +VITE_BIGBANG_ADDRESS=0x08B4c53b98f46B14E2AD00189C2Aa3b9F3d0c8f3 VITE_HATS_ADDRESS=0x3bc1A0Ad72417f2d411118085256fC53CBdDd137 -VITE_FRACTION_TOKEN_ADDRESS=0xb8f7ca7a5b1e457b8735884419e114f90d53e1d5 +VITE_FRACTION_TOKEN_ADDRESS=0xd921517fdF141d97C289bDb9686f51A1375dCc69 -VITE_SPLITS_CREATOR_ADDRESS=0x9c3648df4bb82fdf067a9b083900a986f9b27e9a +VITE_SPLITS_CREATOR_ADDRESS=0x6b5d2e27ff74e9adf4d23aebb9efb52867823583 VITE_PIMLICO_API_KEY= diff --git a/pkgs/frontend/abi/bigbang.ts b/pkgs/frontend/abi/bigbang.ts index 96fde08..0c494e1 100644 --- a/pkgs/frontend/abi/bigbang.ts +++ b/pkgs/frontend/abi/bigbang.ts @@ -1,44 +1,85 @@ export const BIGBANG_ABI = [ + { + inputs: [], + name: "InvalidInitialization", + type: "error", + }, + { + inputs: [], + name: "NotInitializing", + type: "error", + }, { inputs: [ { internalType: "address", - name: "_trustedForwarder", + name: "owner", type: "address", }, + ], + name: "OwnableInvalidOwner", + type: "error", + }, + { + inputs: [ { internalType: "address", - name: "_hatsAddress", + name: "account", type: "address", }, + ], + name: "OwnableUnauthorizedAccount", + type: "error", + }, + { + anonymous: false, + inputs: [ { + indexed: true, internalType: "address", - name: "_hatsModuleFactory", + name: "owner", type: "address", }, { - internalType: "address", - name: "_hatsTimeFrameModule_IMPL", - type: "address", + indexed: true, + internalType: "uint256", + name: "topHatId", + type: "uint256", }, { - internalType: "address", - name: "_splitsCreatorFactory", - type: "address", + indexed: true, + internalType: "uint256", + name: "hatterHatId", + type: "uint256", }, { + indexed: false, internalType: "address", - name: "_splitFactoryV2", + name: "hatsTimeFrameModule", type: "address", }, { + indexed: false, internalType: "address", - name: "_fractionToken", + name: "splitCreator", type: "address", }, ], - stateMutability: "nonpayable", - type: "constructor", + name: "Executed", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint64", + name: "version", + type: "uint64", + }, + ], + name: "Initialized", + type: "event", }, { anonymous: false, @@ -46,30 +87,31 @@ export const BIGBANG_ABI = [ { indexed: true, internalType: "address", - name: "owner", + name: "previousOwner", type: "address", }, { indexed: true, - internalType: "uint256", - name: "topHatId", - type: "uint256", - }, - { - indexed: false, internalType: "address", - name: "hatsTimeFrameModule", + name: "newOwner", type: "address", }, + ], + name: "OwnershipTransferred", + type: "event", + }, + { + inputs: [], + name: "FractionToken", + outputs: [ { - indexed: false, internalType: "address", - name: "splitCreator", + name: "", type: "address", }, ], - name: "Executed", - type: "event", + stateMutability: "view", + type: "function", }, { inputs: [], @@ -123,6 +165,19 @@ export const BIGBANG_ABI = [ stateMutability: "view", type: "function", }, + { + inputs: [], + name: "SplitsFactoryV2", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, { inputs: [ { @@ -168,16 +223,46 @@ export const BIGBANG_ABI = [ type: "function", }, { - inputs: [], - name: "fractionToken", - outputs: [ + inputs: [ { internalType: "address", - name: "", + name: "_trustedForwarder", + type: "address", + }, + { + internalType: "address", + name: "_hatsAddress", + type: "address", + }, + { + internalType: "address", + name: "_hatsModuleFactory", + type: "address", + }, + { + internalType: "address", + name: "_hatsTimeFrameModule_IMPL", + type: "address", + }, + { + internalType: "address", + name: "_splitsCreatorFactory", + type: "address", + }, + { + internalType: "address", + name: "_splitFactoryV2", + type: "address", + }, + { + internalType: "address", + name: "_fractionToken", type: "address", }, ], - stateMutability: "view", + name: "initialize", + outputs: [], + stateMutability: "nonpayable", type: "function", }, { @@ -201,7 +286,7 @@ export const BIGBANG_ABI = [ }, { inputs: [], - name: "splitFactoryV2", + name: "owner", outputs: [ { internalType: "address", @@ -214,15 +299,100 @@ export const BIGBANG_ABI = [ }, { inputs: [], - name: "trustedForwarder", - outputs: [ + name: "renounceOwnership", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ { internalType: "address", - name: "", + name: "_fractionToken", type: "address", }, ], - stateMutability: "view", + name: "setFractionToken", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_hats", + type: "address", + }, + ], + name: "setHats", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_hatsModuleFactory", + type: "address", + }, + ], + name: "setHatsModuleFactory", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_hatsTimeFrameModuleImpl", + type: "address", + }, + ], + name: "setHatsTimeFrameModuleImpl", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_splitsCreatorFactory", + type: "address", + }, + ], + name: "setSplitsCreatorFactory", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "_splitsFactoryV2", + type: "address", + }, + ], + name: "setSplitsFactoryV2", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "address", + name: "newOwner", + type: "address", + }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "nonpayable", type: "function", }, ] as const; diff --git a/pkgs/frontend/app/components/Header.tsx b/pkgs/frontend/app/components/Header.tsx index 9009c5c..3063141 100644 --- a/pkgs/frontend/app/components/Header.tsx +++ b/pkgs/frontend/app/components/Header.tsx @@ -5,7 +5,7 @@ import { UserIcon } from "./icon/UserIcon"; import { useLocation } from "@remix-run/react"; const NO_HEADER_PATHS: string[] = ["/login", "/signup"]; // 適宜ヘッダーが不要なページのパスを追加 -const WORKSPACES_PATHS: string[] = ["/workspaces"]; // 適宜ワークスペースが未選択な状態のページのパスを追加 +const WORKSPACES_PATHS: string[] = ["/workspace", "/workspace/new"]; // 適宜ワークスペースが未選択な状態のページのパスを追加 const HEADER_SIZE: number = 12; // 偶数のnumberだとアイコンが対応しているため望ましい const headerTextStyle = { @@ -22,6 +22,8 @@ enum HeaderType { } export const Header = () => { + console.log("=== Header render ==="); + const [headerType, setHeaderType] = useState( HeaderType.NonHeader ); @@ -31,7 +33,7 @@ export const Header = () => { // ToDo: ページのパスや hooks で柔軟にロジックを実装する(切り替えてテストできます) const isWalletConnected = true; const isUserTobanEnsFound = true; - const isWorkspaceSelected = true; + const isWorkspaceSelected = false; // ToDo: ユーザーやワークスペースごとの各種データを取得するロジックを実装する const userImageUrl: string | undefined = undefined; @@ -40,6 +42,7 @@ export const Header = () => { useEffect(() => { const determineHeaderType = () => { + console.log("pathname", pathname); if ( !NO_HEADER_PATHS.includes(pathname) && isWalletConnected && diff --git a/pkgs/frontend/app/components/common/CommonIcon.tsx b/pkgs/frontend/app/components/common/CommonIcon.tsx index ed32b50..6c9197a 100644 --- a/pkgs/frontend/app/components/common/CommonIcon.tsx +++ b/pkgs/frontend/app/components/common/CommonIcon.tsx @@ -4,6 +4,7 @@ import { Box, Image } from "@chakra-ui/react"; interface CommonIconProps { imageUrl: string | undefined; size: number | "full"; + borderRadius?: string; fallbackIconComponent?: ReactNode; } @@ -11,6 +12,7 @@ export const CommonIcon = ({ size, imageUrl, fallbackIconComponent, + borderRadius, }: CommonIconProps) => { const [showFallbackIcon, setShowFallbackIcon] = useState(!imageUrl); @@ -26,7 +28,7 @@ export const CommonIcon = ({ alignItems="center" justifyContent="center" my="auto" - borderRadius="full" + borderRadius={borderRadius} flexShrink={0} overflow="hidden" > @@ -36,7 +38,7 @@ export const CommonIcon = ({ width="100%" height="100%" objectFit="cover" - borderRadius="full" + borderRadius={borderRadius} onError={() => setShowFallbackIcon(true)} /> ) : ( diff --git a/pkgs/frontend/app/components/common/CommonInput.tsx b/pkgs/frontend/app/components/common/CommonInput.tsx index b052289..edfdba9 100644 --- a/pkgs/frontend/app/components/common/CommonInput.tsx +++ b/pkgs/frontend/app/components/common/CommonInput.tsx @@ -1,11 +1,13 @@ import { Input, InputProps } from "@chakra-ui/react"; interface CommonInputProps extends Omit { + minHeight?: string; value: string | number; onChange: (event: React.ChangeEvent) => void; } export const CommonInput = ({ + minHeight, value, placeholder, onChange, @@ -15,8 +17,11 @@ export const CommonInput = ({ value={value} placeholder={placeholder} width="100%" + minHeight={minHeight} onChange={onChange} borderColor="gray.800" + borderRadius="xl" + backgroundColor="white" /> ); }; diff --git a/pkgs/frontend/app/components/common/CommonTextarea.tsx b/pkgs/frontend/app/components/common/CommonTextarea.tsx index 6691c6c..ac9cba5 100644 --- a/pkgs/frontend/app/components/common/CommonTextarea.tsx +++ b/pkgs/frontend/app/components/common/CommonTextarea.tsx @@ -1,10 +1,27 @@ import { Textarea, TextareaProps } from "@chakra-ui/react"; interface CommonTextAreaProps extends Omit { + minHeight?: string; value: string; onChange: (event: React.ChangeEvent) => void; } -export const CommonTextArea = ({ value, onChange }: CommonTextAreaProps) => { - return