-
Notifications
You must be signed in to change notification settings - Fork 462
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolve circular dependencies (#1414)
* fix(dcd): remove SelectRolePanel * fix(dcd): extract constant and update import * fix(dcd): refactor and pull useSubmit hook apart * chore: prevent barrel file import * chore: isolate more util functions * Revert "fix(dcd): remove SelectRolePanel" This reverts commit 960fb06. * refactor: move fuelSign into utils * fix(dcd): pull apart ToolbarPlugin * fix: update imports * fix: rename imports * fix(dcd): pull apart EditGuildDrawerContext * fix: update EditGuildProvider import
- Loading branch information
1 parent
412e241
commit cf25a5d
Showing
29 changed files
with
302 additions
and
302 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
src/components/[guild]/AccessHub/hooks/useRemoveGuildPlatform.ts
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
29 changes: 3 additions & 26 deletions
29
src/components/[guild]/EditGuild/EditGuildDrawerContext.tsx
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 |
---|---|---|
@@ -1,34 +1,11 @@ | ||
import { useDisclosure } from "@chakra-ui/react" | ||
import dynamic from "next/dynamic" | ||
import { PropsWithChildren, createContext, useContext } from "react" | ||
import useGuild from "../hooks/useGuild" | ||
import useGuildPermission from "../hooks/useGuildPermission" | ||
import { createContext, useContext } from "react" | ||
|
||
const EditGuildDrawerContext = createContext<{ | ||
export const EditGuildDrawerContext = createContext<{ | ||
isOpen: boolean | ||
onOpen: () => void | ||
onClose: () => void | ||
}>(undefined) | ||
|
||
const DynamicEditGuildDrawer = dynamic(() => import("./EditGuildDrawer")) | ||
|
||
const EditGuildDrawerProvider = ({ | ||
children, | ||
}: PropsWithChildren<unknown>): JSX.Element => { | ||
const { isDetailed } = useGuild() | ||
const { isAdmin } = useGuildPermission() | ||
const { isOpen, onOpen, onClose } = useDisclosure() | ||
|
||
return ( | ||
<EditGuildDrawerContext.Provider value={{ isOpen, onOpen, onClose }}> | ||
{children} | ||
{isAdmin && isDetailed && ( | ||
<DynamicEditGuildDrawer isOpen={isOpen} onClose={onClose} /> | ||
)} | ||
</EditGuildDrawerContext.Provider> | ||
) | ||
} | ||
|
||
const useEditGuildDrawer = () => useContext(EditGuildDrawerContext) | ||
|
||
export { EditGuildDrawerProvider, useEditGuildDrawer } | ||
export { useEditGuildDrawer } |
24 changes: 24 additions & 0 deletions
24
src/components/[guild]/EditGuild/EditGuildDrawerProvider.tsx
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,24 @@ | ||
import { useDisclosure } from "@chakra-ui/react" | ||
import dynamic from "next/dynamic" | ||
import { PropsWithChildren } from "react" | ||
import useGuild from "../hooks/useGuild" | ||
import useGuildPermission from "../hooks/useGuildPermission" | ||
import { EditGuildDrawerContext } from "./EditGuildDrawerContext" | ||
|
||
const DynamicEditGuildDrawer = dynamic(() => import("./EditGuildDrawer")) | ||
export const EditGuildDrawerProvider = ({ | ||
children, | ||
}: PropsWithChildren<unknown>): JSX.Element => { | ||
const { isDetailed } = useGuild() | ||
const { isAdmin } = useGuildPermission() | ||
const { isOpen, onOpen, onClose } = useDisclosure() | ||
|
||
return ( | ||
<EditGuildDrawerContext.Provider value={{ isOpen, onOpen, onClose }}> | ||
{children} | ||
{isAdmin && isDetailed && ( | ||
<DynamicEditGuildDrawer isOpen={isOpen} onClose={onClose} /> | ||
)} | ||
</EditGuildDrawerContext.Provider> | ||
) | ||
} |
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 was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
src/components/[guild]/EditGuild/components/TransferOwnership/index.ts
This file was deleted.
Oops, something went wrong.
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
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
1 change: 1 addition & 0 deletions
1
src/components/[guild]/Requirements/components/GuildCheckout/MintGuildPin/constants.ts
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 @@ | ||
export const GUILD_PIN_MAINTENANCE = false |
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 @@ | ||
export const LOW_PRIORITY = 1 |
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,20 @@ | ||
import { $isAtNodeEnd } from "@lexical/selection" | ||
|
||
export const getSelectedNode = (selection) => { | ||
const anchor = selection.anchor | ||
const focus = selection.focus | ||
const anchorNode = selection.anchor.getNode() | ||
const focusNode = selection.focus.getNode() | ||
|
||
if (anchorNode === focusNode) { | ||
return anchorNode | ||
} | ||
|
||
const isBackward = selection.isBackward() | ||
|
||
if (isBackward) { | ||
return $isAtNodeEnd(focus) ? anchorNode : focusNode | ||
} else { | ||
return $isAtNodeEnd(anchor) ? focusNode : anchorNode | ||
} | ||
} |
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,2 @@ | ||
export const DEFAULT_MESSAGE = "Please sign this message" | ||
export const DEFAULT_SIGN_LOADING_TEXT = "Check your wallet" |
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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { default, sign, useSubmitWithSign } from "./useSubmit" | ||
export type { SignedValidation, Validation } from "./useSubmit" | ||
export { default, useSubmitWithSign } from "./useSubmit" | ||
export type { SignedValidation, Validation } from "./types" |
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,46 @@ | ||
import { Account } from "fuels" | ||
import { ValidationMethod } from "types" | ||
import { PublicClient, WalletClient } from "viem" | ||
|
||
type SignBaseProps = { | ||
address: `0x${string}` | ||
payload: string | ||
chainId?: string | ||
forcePrompt: boolean | ||
keyPair?: CryptoKeyPair | ||
msg?: string | ||
ts?: number | ||
getMessageToSign?: (params: MessageParams) => string | ||
} | ||
|
||
export type SignProps = SignBaseProps & { | ||
publicClient: PublicClient | ||
walletClient: WalletClient | ||
} | ||
|
||
export type FuelSignProps = SignBaseProps & { wallet: Account } | ||
|
||
export type SignedValidation = { signedPayload: string; validation: Validation } | ||
|
||
export type Validation = { | ||
params: MessageParams | ||
sig: string | ||
} | ||
|
||
export type MessageParams = { | ||
msg: string | ||
addr: string | ||
method: ValidationMethod | ||
chainId?: string | ||
hash?: string | ||
nonce: string | ||
ts: string | ||
} | ||
|
||
export type UseSubmitOptions<ResponseType = void> = { | ||
onSuccess?: (response: ResponseType) => void | ||
onError?: (error: any) => void | ||
|
||
// Use catefully! If this is set to true, a .onSubmit() call can reject! | ||
allowThrow?: boolean | ||
} |
Oops, something went wrong.