Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup some stuff #1143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions packages/keychain/src/components/DeployController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Fees } from "./Fees";
import { ControllerError } from "utils/connection";
import { Policies } from "components/Policies";
import { ETH_CONTRACT_ADDRESS, useERC20Balance } from "@cartridge/utils";
import { useExplorer } from "@starknet-react/core";

export function DeployController({
onClose,
Expand Down Expand Up @@ -236,6 +237,8 @@ function ExplorerLink({
txHash: string;
chainId: string;
}) {
const explorer = useExplorer();

if (
![
constants.StarknetChainId.SN_SEPOLIA,
Expand All @@ -246,12 +249,7 @@ function ExplorerLink({
}

return (
<Link
href={`https://${
chainId === constants.StarknetChainId.SN_SEPOLIA ? "sepolia." : ""
}starkscan.co/tx/${txHash}`}
isExternal
>
<Link href={explorer.transaction(txHash)} isExternal>
<Button
variant="goast"
mt={10}
Expand All @@ -261,7 +259,7 @@ function ExplorerLink({
fontSize="sm"
fontFamily="Inter"
>
View on Starkscan
View on Explorer
</Button>
</Link>
);
Expand Down
22 changes: 7 additions & 15 deletions packages/keychain/src/components/ErrorAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { useConnection } from "hooks/connection";
import { constants } from "starknet";
import { parseExecutionError, parseValidationError } from "utils/errors";
import { formatAddress } from "@cartridge/utils";
import { useExplorer } from "@starknet-react/core";

export function ErrorAlert({
title,
Expand Down Expand Up @@ -336,17 +337,7 @@ function StackTraceDisplay({
stackTrace: ReturnType<typeof parseExecutionError>["stack"];
}) {
const { chainId } = useConnection();

const getExplorerUrl = (type: "contract" | "class", value: string) => {
if (!chainId) return;

const baseUrl = {
[constants.StarknetChainId.SN_SEPOLIA]: "https://sepolia.starkscan.co",
[constants.StarknetChainId.SN_MAIN]: "https://starkscan.co",
}[chainId];

return baseUrl ? `${baseUrl}/${type}/${value}` : undefined;
};
const explorer = useExplorer();

const isExternalLink = [
constants.StarknetChainId.SN_SEPOLIA,
Expand Down Expand Up @@ -377,10 +368,11 @@ function StackTraceDisplay({
</Text>
{key === "address" || key === "class" ? (
<Link
href={getExplorerUrl(
key === "address" ? "contract" : "class",
value as string,
)}
href={
key === "address"
? explorer.contract(value as string)
: explorer.class(value as string)
}
isExternal={isExternalLink}
wordBreak="break-all"
textAlign="left"
Expand Down
5 changes: 3 additions & 2 deletions packages/keychain/src/components/Transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { constants } from "starknet";
import { CheckIcon, ExternalIcon, StarknetIcon } from "@cartridge/ui";
import { useController } from "hooks/controller";
import { useChainName } from "hooks/chain";
import { StarkscanUrl } from "@cartridge/utils";
import { useExplorer } from "@starknet-react/core";

export type TransactionState = "pending" | "success" | "error";

Expand All @@ -30,6 +30,7 @@ export function Transaction({
hash,
finalized,
}: TransactionProps) {
const explorer = useExplorer();
const [state, setState] = useState<TransactionState>("pending");
const { color, icon } = useMemo(() => getColorIcon(state), [state]);
const { controller } = useController();
Expand Down Expand Up @@ -78,7 +79,7 @@ export function Transaction({
</Text>
</HStack>
<Divider orientation="vertical" bgColor="solid.accent" h="30px" />
<Link href={StarkscanUrl(chainId).transaction(hash)} isExternal>
<Link href={explorer.transaction(hash)} isExternal>
<ExternalIcon boxSize="12px" color="link.blue" />
</Link>
</HStack>
Expand Down
2 changes: 0 additions & 2 deletions packages/keychain/src/hooks/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
toSessionPolicies,
} from "@cartridge/controller";
import { mergeDefaultETHPrefund } from "utils/token";
import { setIsSignedUp } from "utils/cookie";
import {
ConnectionContext,
ConnectionContextValue,
Expand Down Expand Up @@ -98,7 +97,6 @@ export function useConnectionValue() {
}

setControllerRaw(controller);
setIsSignedUp();
}, []);

useEffect(() => {
Expand Down
11 changes: 0 additions & 11 deletions packages/keychain/src/utils/cookie.ts

This file was deleted.

Loading