From dded2e64ecab2e6ef6f6738feafc104b9d678b78 Mon Sep 17 00:00:00 2001 From: JunichiSugiura Date: Tue, 19 Nov 2024 17:24:39 +0100 Subject: [PATCH 1/2] Show settings button on top bar in Keychain --- .../src/components/Settings/index.tsx | 114 ++++++++---------- .../layout/Container/Header/TopBar.tsx | 11 +- .../layout/Container/Header/index.tsx | 13 +- .../src/components/layout/Container/index.tsx | 2 - packages/keychain/src/hooks/connection.ts | 2 +- packages/keychain/src/pages/index.tsx | 2 +- 6 files changed, 63 insertions(+), 81 deletions(-) diff --git a/packages/keychain/src/components/Settings/index.tsx b/packages/keychain/src/components/Settings/index.tsx index 405add0fc..a3554cc7d 100644 --- a/packages/keychain/src/components/Settings/index.tsx +++ b/packages/keychain/src/components/Settings/index.tsx @@ -1,21 +1,9 @@ -import { - Button, - VStack, - Text, - HStack, - UnorderedList, - ListItem, -} from "@chakra-ui/react"; -import { Container, Content, Footer } from "components/layout"; -import { GearIcon, TrashIcon } from "@cartridge/ui"; -import { useConnection } from "hooks/connection"; -import { useCallback, useEffect, useState } from "react"; -import { useExternalOwners } from "hooks/external"; -import { formatAddress } from "@cartridge/utils"; +import { Button } from "@chakra-ui/react"; +import { GearIcon } from "@cartridge/ui"; +import { useState } from "react"; +import { Container, Footer } from "components/layout"; import { Recovery } from "./Recovery"; import { Delegate } from "./Delegate"; -import { CallData } from "starknet"; -import { ExecuteCtx } from "utils/connection"; enum State { SETTINGS, @@ -24,54 +12,54 @@ enum State { } export function Settings({ onLogout }: { onLogout: () => void }) { - const { controller, context, setContext } = useConnection(); + // const { controller, context, setContext } = useConnection(); const [state, setState] = useState(State.SETTINGS); - const [delegateAccount, setDelegateAccount] = useState(""); + // const [delegateAccount, setDelegateAccount] = useState(""); - useEffect(() => { - const init = async () => { - const delegate = await controller.delegateAccount(); - setDelegateAccount(delegate); - }; - init(); - }, [controller]); + // useEffect(() => { + // const init = async () => { + // const delegate = await controller.delegateAccount(); + // setDelegateAccount(delegate); + // }; + // init(); + // }, [controller]); - const { externalOwners } = useExternalOwners(); + // const { externalOwners } = useExternalOwners(); - const onRemoveExternalOwner = useCallback( - (externalOwnerAddress: string) => { - setContext({ - origin: context.origin, - transactions: [ - { - contractAddress: controller.address, - entrypoint: "remove_external_owner", - calldata: CallData.compile([externalOwnerAddress]), - }, - ], - type: "execute", - resolve: context.resolve, - reject: context.reject, - } as ExecuteCtx); - }, - [controller, context, setContext], - ); + // const onRemoveExternalOwner = useCallback( + // (externalOwnerAddress: string) => { + // setContext({ + // origin: context.origin, + // transactions: [ + // { + // contractAddress: controller.address, + // entrypoint: "remove_external_owner", + // calldata: CallData.compile([externalOwnerAddress]), + // }, + // ], + // type: "execute", + // resolve: context.resolve, + // reject: context.reject, + // } as ExecuteCtx); + // }, + // [controller, context, setContext], + // ); - const onRemoveDelegate = useCallback(() => { - setContext({ - origin: context.origin, - transactions: [ - { - contractAddress: controller.address, - entrypoint: "set_delegate_account", - calldata: CallData.compile(["0x0"]), - }, - ], - type: "execute", - resolve: context.resolve, - reject: context.reject, - } as ExecuteCtx); - }, [controller, context, setContext]); + // const onRemoveDelegate = useCallback(() => { + // setContext({ + // origin: context.origin, + // transactions: [ + // { + // contractAddress: controller.address, + // entrypoint: "set_delegate_account", + // calldata: CallData.compile(["0x0"]), + // }, + // ], + // type: "execute", + // resolve: context.resolve, + // reject: context.reject, + // } as ExecuteCtx); + // }, [controller, context, setContext]); if (state === State.RECOVERY) { return setState(State.SETTINGS)} />; @@ -83,9 +71,9 @@ export function Settings({ onLogout }: { onLogout: () => void }) { return ( - + {/* - {/* + {controller.cartridge.hasSession( controller.cartridge.session(), ) ? ( @@ -101,7 +89,7 @@ export function Settings({ onLogout }: { onLogout: () => void }) { > Clear Session - */} + @@ -169,7 +157,7 @@ export function Settings({ onLogout }: { onLogout: () => void }) { )} - + */}