Skip to content

Commit

Permalink
Remove prefunds
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura committed Dec 23, 2024
1 parent 07216e9 commit 364cc71
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 34 deletions.
2 changes: 0 additions & 2 deletions packages/controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ export type ProfileContextTypeVariant =
| "achievements"
| "activity";

export type Prefund = { address: string; min: string };

export type Tokens = {
erc20?: string[];
};
1 change: 0 additions & 1 deletion packages/keychain/.storybook/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export function useMockedConnection({
chainName,
policies: {},
theme: defaultTheme,
prefunds: [],
hasPrefundRequest: false,
error: undefined,
setContext: () => {},
Expand Down
2 changes: 0 additions & 2 deletions packages/keychain/src/components/Provider/connection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createContext } from "react";
import Controller from "@/utils/controller";
import { ConnectionCtx } from "@/utils/connection";
import { Prefund } from "@cartridge/controller";
import { UpgradeInterface } from "@/hooks/upgrade";
import { ControllerTheme } from "@cartridge/presets";
import { ParsedSessionPolicies } from "@/hooks/session";
Expand All @@ -19,7 +18,6 @@ export type ConnectionContextValue = {
chainName?: string;
policies?: ParsedSessionPolicies;
theme: ControllerTheme;
prefunds: Prefund[];
hasPrefundRequest: boolean;
error?: Error;
upgrade: UpgradeInterface;
Expand Down
33 changes: 4 additions & 29 deletions packages/keychain/src/hooks/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@ import {
ConnectionCtx,
OpenSettingsCtx,
} from "@/utils/connection";
import { ETH_CONTRACT_ADDRESS, getChainName, isIframe } from "@cartridge/utils";
import { getChecksumAddress, RpcProvider } from "starknet";
import {
Prefund,
ResponseCodes,
toSessionPolicies,
} from "@cartridge/controller";
import { getChainName, isIframe } from "@cartridge/utils";
import { RpcProvider } from "starknet";
import { ResponseCodes, toSessionPolicies } from "@cartridge/controller";
import { setIsSignedUp } from "@/utils/cookie";
import {
ConnectionContext,
Expand Down Expand Up @@ -41,7 +37,6 @@ export function useConnectionValue() {
const [policies, setPolicies] = useState<ParsedSessionPolicies>();
const [theme, setTheme] = useState<ControllerTheme>(defaultTheme);
const [controller, setControllerRaw] = useState<Controller | undefined>();
const [prefunds, setPrefunds] = useState<Prefund[]>([]);
const [hasPrefundRequest, setHasPrefundRequest] = useState<boolean>(false);
const upgrade: UpgradeInterface = useUpgrade(controller);
const [error, setError] = useState<Error>();
Expand Down Expand Up @@ -115,25 +110,6 @@ export function useConnectionValue() {
}
}

// Handle prefunds
const prefundParam = urlParams.get("prefunds");
const prefunds: Prefund[] = prefundParam
? JSON.parse(decodeURIComponent(prefundParam))
: [];
setHasPrefundRequest(!!prefundParam);
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");
const themeParam = urlParams.get("theme");
Expand Down Expand Up @@ -190,7 +166,7 @@ export function useConnectionValue() {
);
}
}
}, [setTheme, setPolicies, setHasPrefundRequest, setOrigin, setPrefunds]);
}, [setTheme, setPolicies, setHasPrefundRequest, setOrigin]);

useEffect(() => {
const connection = connectToController<ParentMethods>({
Expand Down Expand Up @@ -257,7 +233,6 @@ export function useConnectionValue() {
chainName,
policies,
theme,
prefunds,
hasPrefundRequest,
error,
upgrade,
Expand Down

0 comments on commit 364cc71

Please sign in to comment.