-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
173 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useDojoContext } from "@/dojo/hooks"; | ||
import { Button, Menu, MenuButton, MenuList } from "@chakra-ui/react"; | ||
import { useAccount, useConnect } from "@starknet-react/core"; | ||
import { Wallet } from "../icons/archive"; | ||
import { PredeployedManagerUi } from "./ui/PredeployedManagerUi"; | ||
|
||
export const Predeployed = () => { | ||
const { predeployedManager } = useDojoContext(); | ||
const { connector, isConnected } = useConnect(); | ||
const { account } = useAccount(); | ||
|
||
if (!predeployedManager) return null; | ||
if (!account) return null; | ||
if (!connector) return null; | ||
if (connector?.id !== "dojopredeployed") return null; | ||
return ( | ||
<Menu> | ||
<MenuButton as={Button} variant="pixelated" h="48px" /*rightIcon={<Arrow direction='down' />}*/> | ||
<Wallet /> | ||
</MenuButton> | ||
<MenuList> | ||
<PredeployedManagerUi predeployedManager={predeployedManager} /> | ||
</MenuList> | ||
</Menu> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { HStack, List, ListItem, Text, VStack } from "@chakra-ui/react"; | ||
import { Predeployed, PredeployedManager } from "@dojoengine/create-burner"; | ||
import { useConnect, useDisconnect } from "@starknet-react/core"; | ||
import { observer } from "mobx-react-lite"; | ||
import { useEffect, useState } from "react"; | ||
import { frenlyAddress } from "../Connect"; | ||
|
||
export const PredeployedManagerUi = observer(({ predeployedManager }: { predeployedManager?: PredeployedManager }) => { | ||
const { connect, connector } = useConnect(); | ||
const { disconnect } = useDisconnect(); | ||
|
||
const [isDeploying, setIsDeploying] = useState(false); | ||
const [refresher, setRefresher] = useState(false); | ||
const [predeployed, setPredeployed] = useState<Predeployed[]>([]); | ||
|
||
useEffect(() => { | ||
if (!predeployedManager) return; | ||
const predeployed = predeployedManager.list(); | ||
setPredeployed(predeployed); | ||
}, [predeployedManager, predeployedManager?.chainId, refresher]); | ||
|
||
const onSelect = (burner: Predeployed) => { | ||
if (!predeployedManager) return; | ||
predeployedManager.select(burner.address); | ||
setRefresher(!refresher); | ||
|
||
// force connect active wallet | ||
disconnect(); | ||
connect({ connector }); | ||
}; | ||
|
||
|
||
if (!predeployedManager) return null; | ||
if( !connector ) return null; | ||
if( connector && connector?.id !== "dojopredeployed") return null; | ||
|
||
return ( | ||
<VStack w="full" p={3}> | ||
<> | ||
{predeployed.length === 0 && <Text>No predeployed!</Text>} | ||
{predeployed.length > 0 && ( | ||
<> | ||
<List w="full"> | ||
{predeployed.map((predeployed: Predeployed, idx: number) => { | ||
return ( | ||
<ListItem | ||
key={idx} | ||
w="full" | ||
borderBottom="solid 2px" | ||
borderBottomColor="neon.700" | ||
py={1} | ||
mb={1} | ||
_last={{ borderBottom: 0 }} | ||
> | ||
<HStack w="full" color={predeployed.active ? "yellow.400" : "neon.400"} justifyContent="space-between"> | ||
<Text textTransform="uppercase" cursor="pointer" onClick={() => onSelect(predeployed)}> | ||
{frenlyAddress(predeployed.address)} ({predeployed.name}) | ||
</Text> | ||
</HStack> | ||
</ListItem> | ||
); | ||
})} | ||
</List> | ||
</> | ||
)} | ||
|
||
</> | ||
</VStack> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters