Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
allow fund wallet (#2529)
Browse files Browse the repository at this point in the history
  • Loading branch information
intergalacticspacehighway committed Nov 15, 2023
1 parent a9b5ff8 commit 466bb0e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
49 changes: 40 additions & 9 deletions packages/app/components/creator-token/buy-creator-token.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import { useState, useEffect } from "react";
import { Linking } from "react-native";

import { useWallets } from "@privy-io/react-auth";
import { createParam } from "solito";

import { Avatar } from "@showtime-xyz/universal.avatar";
import { BottomSheetModalProvider } from "@showtime-xyz/universal.bottom-sheet";
import { Button } from "@showtime-xyz/universal.button";
import { useIsDarkMode } from "@showtime-xyz/universal.hooks";
import {
Ethereum,
InformationCircle,
LockBadge,
} from "@showtime-xyz/universal.icon";
import { InformationCircle, LockBadge } from "@showtime-xyz/universal.icon";
import { Image } from "@showtime-xyz/universal.image";
import { ModalSheet } from "@showtime-xyz/universal.modal-sheet";
import { Pressable } from "@showtime-xyz/universal.pressable";
Expand Down Expand Up @@ -79,6 +76,8 @@ export const BuyCreatorToken = () => {
const [username] = useParam("username");
const [selectedActionParam] = useParam("selectedAction");
const [tokenAmount, setTokenAmount] = useState(1);
const { wallets } = useWallets();
const isPrivyWalletConnected = wallets?.[0]?.walletClientType === "privy";

const { data: profileData } = useUserProfile({ address: username });
const sellToken = useCreatorTokenSell();
Expand Down Expand Up @@ -158,9 +157,25 @@ export const BuyCreatorToken = () => {
);
} else if (
paymentMethod === "USDC" &&
usdcBalance.data?.balance === 0n &&
!wallet.isMagicWallet
Number(usdcBalance.data?.balance) === 0
) {
if (isPrivyWalletConnected) {
return (
<Button
size="regular"
onPress={() => {
wallets[0].fund({
config: {
currencyCode: "USDC_BASE",
},
});
}}
>
Add USDC to your wallet
</Button>
);
}

return (
<Button
onPress={() =>
Expand All @@ -175,9 +190,25 @@ export const BuyCreatorToken = () => {
);
} else if (
paymentMethod === "ETH" &&
ethBalance.data?.balance === 0n &&
!wallet.isMagicWallet
Number(ethBalance.data?.balance) === 0
) {
if (isPrivyWalletConnected) {
return (
<Button
size="regular"
onPress={() => {
wallets[0].fund({
config: {
currencyCode: "ETH_BASE",
},
});
}}
>
Add ETH to your wallet
</Button>
);
}

return (
<Button
onPress={() => Linking.openURL("https://bridge.base.org/deposit")}
Expand Down
3 changes: 3 additions & 0 deletions packages/app/lib/privy/privy-provider.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const PrivyProvider = ({ children }: any) => {
accentColor: "#676FFF",
logo: "https://pbs.twimg.com/profile_images/1720182212468051968/CPBHLyGx_400x400.jpg",
},
fiatOnRamp: {
useSandbox: process.env.NEXT_PUBLIC_STAGE === "development",
},
}}
>
{children}
Expand Down

0 comments on commit 466bb0e

Please sign in to comment.