Skip to content

Commit

Permalink
Cleanup token util
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura committed Dec 23, 2024
1 parent c26d8f8 commit 07216e9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 143 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react";

import { ConfirmTransaction } from "./ConfirmTransaction";
import { ETH_CONTRACT_ADDRESS } from "../utils/token";
import { ETH_CONTRACT_ADDRESS } from "@cartridge/utils";

const meta = {
component: ConfirmTransaction,
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/Funding/DepositEth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import {
} from "@cartridge/ui-next";
import { useConnection } from "@/hooks/connection";
import { useToast } from "@/hooks/toast";
import { ETH_CONTRACT_ADDRESS } from "@/utils/token";
import { ErrorAlert } from "../ErrorAlert";
import { CopyAddress } from "@/components/CopyAddress";
import { parseEther } from "viem";
import { AmountSelection, DEFAULT_AMOUNT } from "./AmountSelection";
import { Balance } from "./Balance";
import { TokenPair, usePriceQuery } from "@cartridge/utils/api/cartridge";
import { ETH_CONTRACT_ADDRESS } from "@cartridge/utils";

type DepositEthProps = {
onComplete?: (deployHash?: string) => void;
Expand Down
18 changes: 14 additions & 4 deletions packages/keychain/src/hooks/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import {
ConnectionCtx,
OpenSettingsCtx,
} from "@/utils/connection";
import { getChainName, isIframe } from "@cartridge/utils";
import { RpcProvider } from "starknet";
import { ETH_CONTRACT_ADDRESS, getChainName, isIframe } from "@cartridge/utils";
import { getChecksumAddress, RpcProvider } from "starknet";
import {
Prefund,
ResponseCodes,
toSessionPolicies,
} from "@cartridge/controller";
import { mergeDefaultETHPrefund } from "@/utils/token";
import { setIsSignedUp } from "@/utils/cookie";
import {
ConnectionContext,
Expand Down Expand Up @@ -122,7 +121,18 @@ export function useConnectionValue() {
? JSON.parse(decodeURIComponent(prefundParam))
: [];
setHasPrefundRequest(!!prefundParam);
setPrefunds(mergeDefaultETHPrefund(prefunds));
setPrefunds(
prefunds.find(
(p) =>
getChecksumAddress(p.address) ===
getChecksumAddress(ETH_CONTRACT_ADDRESS),
)
? prefunds
: [
{ address: ETH_CONTRACT_ADDRESS, min: "100000000000000" },
...prefunds,
],
);

// Handle theme and policies
const policiesParam = urlParams.get("policies");
Expand Down
137 changes: 0 additions & 137 deletions packages/keychain/src/utils/token.tsx

This file was deleted.

0 comments on commit 07216e9

Please sign in to comment.