Skip to content

Commit

Permalink
Fix warnings (#528)
Browse files Browse the repository at this point in the history
* Fix build warnings

* pnpm format
  • Loading branch information
broody authored Jul 31, 2024
1 parent 0e40795 commit 3a4e791
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 82 deletions.
8 changes: 7 additions & 1 deletion packages/keychain/src/components/DeploymentRequired.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ export function DeploymentRequired({
setDeployHash(hash);
})
.catch((e) => setError(e));
}, [account.chainId, account.username]);
}, [
account.chainId,
account.username,
hasPrefundRequest,
isDeployed,
deployRequest,
]);

if (isDeployed) {
return <>{children}</>;
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/Execute/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function Execute() {
transaction_hash,
code: ResponseCodes.SUCCESS,
});
}, [account, calls, fees, ctx, origin, controller]);
}, [account, calls, ctx, origin, controller]);

const policies = useMemo<Policy[]>(
() =>
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/Funding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function FundingInner({ onComplete }: FundingInnerProps) {

setError(e);
}
}, [onComplete]);
}, [onComplete, deploySelf]);

const onCopy = useCallback(() => {
navigator.clipboard.writeText(controller.address);
Expand Down
13 changes: 8 additions & 5 deletions packages/keychain/src/components/connect/CreateSession.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export function CreateSession({
await controller.approve(origin, expiresAt, policies, maxFees);
onConnect(policies);
} catch (e) {
setError(e)
setIsConnecting(false)
}
setError(e);
setIsConnecting(false);
}
}, [controller, origin, expiresAt, policies, maxFees, onConnect]);

return (
Expand All @@ -52,13 +52,16 @@ export function CreateSession({

<Footer hideTxSummary>
{error && (
<ErrorAlert title="Create session failed" description={error.message} />
<ErrorAlert
title="Create session failed"
description={error.message}
/>
)}
<Button
colorScheme="colorful"
isDisabled={isConnecting}
isLoading={isConnecting}
onClick={()=> onCreateSession()}
onClick={() => onCreateSession()}
>
create session
</Button>
Expand Down
37 changes: 20 additions & 17 deletions packages/keychain/src/hooks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface DeployInterface {
}

export const useDeploy = (): DeployInterface => {
const { chainId, prefunds, controller } = useConnection();
const { chainId, controller } = useConnection();
const [isDeployed, setIsDeployed] = useState(false);
const [isDeploying, setIsDeploying] = useState(false);

Expand Down Expand Up @@ -63,27 +63,30 @@ export const useDeploy = (): DeployInterface => {
setIsDeploying(false);
}
},
[prefunds, chainId],
[chainId, isDeployed],
);

const deploySelf = useCallback(async (maxFee: string) => {
if (isDeployed) return;
const deploySelf = useCallback(
async (maxFee: string) => {
if (isDeployed) return;

try {
setIsDeploying(true);
const { transaction_hash } =
await controller.account.cartridge.deploySelf(num.toHex(maxFee));
try {
setIsDeploying(true);
const { transaction_hash } =
await controller.account.cartridge.deploySelf(num.toHex(maxFee));

setIsDeployed(true);
return transaction_hash;
} catch (e) {
if (!e.message.includes("account already deployed")) {
throw e;
setIsDeployed(true);
return transaction_hash;
} catch (e) {
if (!e.message.includes("account already deployed")) {
throw e;
}
} finally {
setIsDeploying(false);
}
} finally {
setIsDeploying(false);
}
}, []);
},
[controller.account, isDeployed],
);

return {
deployRequest,
Expand Down
9 changes: 2 additions & 7 deletions packages/keychain/src/pages/slot/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function CreateSession() {
router.replace(`/slot/auth/failure`);
});
},
[router, queries.callback_uri],
[router, queries.callback_uri, controller.username, deployRequest],
);

// Handler when user clicks the Create button
Expand Down Expand Up @@ -117,12 +117,7 @@ function CreateSession() {
})
.catch((e) => console.error(e))
.finally(() => setIsFetching(false));
}, [
rpcUrl,
chainId,
setController,
queries.username,
]);
}, [rpcUrl, chainId, setController, queries.username]);

// Once the controller is created upon start, check if a session already exists.
// If yes, check if the policies of the session are the same as the ones that are
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-next/src/components/primitives/command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Command = React.forwardRef<
));
Command.displayName = CommandPrimitive.displayName;

interface CommandDialogProps extends DialogProps { }
interface CommandDialogProps extends DialogProps {}

const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/ui-next/src/components/primitives/toggle-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const ToggleGroupContext = React.createContext<
const ToggleGroup = React.forwardRef<
React.ElementRef<typeof ToggleGroupPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Root> &
VariantProps<typeof toggleVariants>
VariantProps<typeof toggleVariants>
>(({ className, variant, size, children, ...props }, ref) => (
<ToggleGroupPrimitive.Root
ref={ref}
Expand All @@ -35,7 +35,7 @@ ToggleGroup.displayName = ToggleGroupPrimitive.Root.displayName;
const ToggleGroupItem = React.forwardRef<
React.ElementRef<typeof ToggleGroupPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof ToggleGroupPrimitive.Item> &
VariantProps<typeof toggleVariants>
VariantProps<typeof toggleVariants>
>(({ className, children, variant, size, ...props }, ref) => {
const context = React.useContext(ToggleGroupContext);

Expand Down
46 changes: 23 additions & 23 deletions packages/ui-next/src/themes/dark.css
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
@layer base {
.dark {
--background: 135 8% 9%; /* bg */
--foreground: 0 0% 100%; /* text.primary */
.dark {
--background: 135 8% 9%; /* bg */
--foreground: 0 0% 100%; /* text.primary */

--card: 135 8% 9%; /* bg */
--card-foreground: 0 0% 100%; /* text.primary */
--card: 135 8% 9%; /* bg */
--card-foreground: 0 0% 100%; /* text.primary */

--popover: 135 8% 9%; /* bg */
--popover-foreground: 0 0% 100%; /* text.primary */
--popover: 135 8% 9%; /* bg */
--popover-foreground: 0 0% 100%; /* text.primary */

--primary: 44 96% 61%; /* brand.primary */
--primary-foreground: 135 8% 9%; /* bg */
--primary: 44 96% 61%; /* brand.primary */
--primary-foreground: 135 8% 9%; /* bg */

--secondary: 136 6% 13%; /* solid.primary */
--secondary-foreground: 0 0% 100%; /* text.primary */
--secondary: 136 6% 13%; /* solid.primary */
--secondary-foreground: 0 0% 100%; /* text.primary */

--tertiary: 120 57% 78%;
--tertiary-foreground: 0 0% 0%;
--tertiary: 120 57% 78%;
--tertiary-foreground: 0 0% 0%;

--muted: 132 4% 23%; /* solid.accent */
--muted-foreground: 0 0% 50%; /* text.secondary */
--muted: 132 4% 23%; /* solid.accent */
--muted-foreground: 0 0% 50%; /* text.secondary */

--accent: 132 4% 23%; /* solid.accent */
--accent-foreground: 210 40% 98%; /* text.secondaryAccent */
--accent: 132 4% 23%; /* solid.accent */
--accent-foreground: 210 40% 98%; /* text.secondaryAccent */

--destructive: 7 72% 65%; /* text.error */
--destructive-foreground: 7 72% 65%; /* text.error */
--destructive: 7 72% 65%; /* text.error */
--destructive-foreground: 7 72% 65%; /* text.error */

--border: 0 100% 100%; /* black */
--input: 0 100% 100%; /* black */
--ring: 0 0% 100%; /* text.primary */
}
--border: 0 100% 100%; /* black */
--input: 0 100% 100%; /* black */
--ring: 0 0% 100%; /* text.primary */
}
}
48 changes: 24 additions & 24 deletions packages/ui-next/src/themes/default.css
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
@layer base {
:root {
--background: 220 60% 99%;
--foreground: 0 0% 0%;
:root {
--background: 220 60% 99%;
--foreground: 0 0% 0%;

--card: 220 60% 99%;
--card-foreground: 0 0% 0%;
--card: 220 60% 99%;
--card-foreground: 0 0% 0%;

--popover: 220 60% 99%;
--popover-foreground: 0 0% 0%;
--popover: 220 60% 99%;
--popover-foreground: 0 0% 0%;

--primary: 255 73% 61%;
--primary-foreground: 220 60% 99%;
--primary: 255 73% 61%;
--primary-foreground: 220 60% 99%;

--secondary: 210 22% 96%;
--secondary-foreground: 0 0% 0%;
--secondary: 210 22% 96%;
--secondary-foreground: 0 0% 0%;

--tertiary: 255 73% 61%;
--tertiary-foreground: 220 60% 99%;
--tertiary: 255 73% 61%;
--tertiary-foreground: 220 60% 99%;

--muted: 207 15% 85%;
--muted-foreground: 0 0% 50%;
--muted: 207 15% 85%;
--muted-foreground: 0 0% 50%;

--accent: 207 15% 85%;
--accent-foreground: 222.2 47.4% 11.2%;
--accent: 207 15% 85%;
--accent-foreground: 222.2 47.4% 11.2%;

--destructive: 7 72% 65%;
--destructive-foreground: 7 72% 65%;
--destructive: 7 72% 65%;
--destructive-foreground: 7 72% 65%;

--border: 0 0% 0%;
--input: 0 0% 0%;
--ring: 0 0% 0%;
--border: 0 0% 0%;
--input: 0 0% 0%;
--ring: 0 0% 0%;

--radius: 0.5rem;
}
--radius: 0.5rem;
}
}

0 comments on commit 3a4e791

Please sign in to comment.