Skip to content

Commit

Permalink
feat: custom seed enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Polybius93 committed Oct 10, 2024
1 parent 4f81a82 commit 7a2577b
Show file tree
Hide file tree
Showing 10 changed files with 353 additions and 180 deletions.
53 changes: 28 additions & 25 deletions src/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { BitcoinWalletContextProvider } from '@providers/bitcoin-wallet-context-
import { EthereumNetworkConfigurationContextProvider } from '@providers/ethereum-network-configuration.provider';
import { EthereumObserverProvider } from '@providers/ethereum-observer-provider';
import { ProofOfReserveContextProvider } from '@providers/proof-of-reserve-context-provider';
import { RippleWalletContextProvider } from '@providers/ripple-user-wallet-context-provider';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { WagmiProvider } from 'wagmi';

Expand All @@ -29,31 +30,33 @@ export function App(): React.JSX.Element {
<WagmiProvider config={wagmiConfiguration}>
<QueryClientProvider client={queryClient}>
<EthereumNetworkConfigurationContextProvider>
<BitcoinWalletContextProvider>
<VaultContextProvider>
<EthereumObserverProvider>
<BitcoinTransactionConfirmationsProvider>
<BalanceContextProvider>
<ProofOfReserveContextProvider>
<AppLayout>
<Route path="/" element={<PointsPage />} />
<Route path="/my-vaults" element={<MyVaults />} />
{/* <Route path="/how-it-works" element={<About />} /> */}
<Route path="/proof-of-reserve" element={<ProofOfReservePage />} />
<Route path="/attestor-details" element={<AttestorDetailsPage />} />
<Route
path="/attestor-details-select"
element={<AttestorDetailsSelectPage />}
/>
<Route path="/merchant-details/:name" element={<MerchantDetails />} />
<Route path="/mint-withdraw" element={<Dashboard />} />
</AppLayout>
</ProofOfReserveContextProvider>
</BalanceContextProvider>
</BitcoinTransactionConfirmationsProvider>
</EthereumObserverProvider>
</VaultContextProvider>
</BitcoinWalletContextProvider>
<RippleWalletContextProvider>
<BitcoinWalletContextProvider>
<VaultContextProvider>
<EthereumObserverProvider>
<BitcoinTransactionConfirmationsProvider>
<BalanceContextProvider>
<ProofOfReserveContextProvider>
<AppLayout>
<Route path="/" element={<PointsPage />} />
<Route path="/my-vaults" element={<MyVaults />} />
{/* <Route path="/how-it-works" element={<About />} /> */}
<Route path="/proof-of-reserve" element={<ProofOfReservePage />} />
<Route path="/attestor-details" element={<AttestorDetailsPage />} />
<Route
path="/attestor-details-select"
element={<AttestorDetailsSelectPage />}
/>
<Route path="/merchant-details/:name" element={<MerchantDetails />} />
<Route path="/mint-withdraw" element={<Dashboard />} />
</AppLayout>
</ProofOfReserveContextProvider>
</BalanceContextProvider>
</BitcoinTransactionConfirmationsProvider>
</EthereumObserverProvider>
</VaultContextProvider>
</BitcoinWalletContextProvider>
</RippleWalletContextProvider>
</EthereumNetworkConfigurationContextProvider>
</QueryClientProvider>
</WagmiProvider>
Expand Down
43 changes: 24 additions & 19 deletions src/app/components/account/account.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,44 @@
import { useContext } from 'react';
import { useDispatch } from 'react-redux';

import { HStack } from '@chakra-ui/react';
import { Button, HStack } from '@chakra-ui/react';
import { AccountMenu } from '@components/account/components/account-menu';
import { RippleWalletContext } from '@providers/ripple-user-wallet-context-provider';
import { mintUnmintActions } from '@store/slices/mintunmint/mintunmint.actions';
import { modalActions } from '@store/slices/modal/modal.actions';

// import { modalActions } from '@store/slices/modal/modal.actions';
import { useAccount, useDisconnect } from 'wagmi';
// import { useAccount, useDisconnect } from 'wagmi';

export function Account(): React.JSX.Element {
const dispatch = useDispatch();

const { address, connector } = useAccount();
const { disconnect } = useDisconnect();
// const { address, connector } = useAccount();
// const { disconnect } = useDisconnect();
const { isRippleWalletInitialized, resetRippleWallet } = useContext(RippleWalletContext);

// function onConnectWalletClick(): void {
// dispatch(modalActions.toggleSelectWalletModalVisibility());
// }
function onConnectWalletClick(): void {
dispatch(modalActions.toggleSelectWalletModalVisibility());
}

function onDisconnectWalletClick(): void {
disconnect();
resetRippleWallet();
dispatch(mintUnmintActions.resetMintUnmintState());
}

return (
<HStack w={'275px'}>
{/* {isConnected ? ( */}
<AccountMenu
address={address}
wagmiConnector={connector}
handleDisconnectWallet={() => onDisconnectWalletClick()}
/>
{/* ) : ( */}
{/* <Button variant={'account'} onClick={() => onConnectWalletClick()}> */}
{/* Connect Wallet */}
{/* </Button> */}
{/* )} */}
{isRippleWalletInitialized ? (
<AccountMenu
// address={address}
// wagmiConnector={connector}
handleDisconnectWallet={() => onDisconnectWalletClick()}
/>
) : (
<Button variant={'account'} onClick={() => onConnectWalletClick()}>
Connect Wallet
</Button>
)}
</HStack>
);
}
14 changes: 9 additions & 5 deletions src/app/components/account/components/account-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { useContext } from 'react';

import { ChevronDownIcon } from '@chakra-ui/icons';
import { HStack, Image, Menu, MenuButton, MenuItem, MenuList, Stack, Text } from '@chakra-ui/react';
import { RippleWalletContext } from '@providers/ripple-user-wallet-context-provider';
import { truncateAddress } from 'dlc-btc-lib/utilities';
import { Connector } from 'wagmi';

// import { Connector } from 'wagmi';

interface AccountMenuProps {
address?: string;
wagmiConnector?: Connector;
// address?: string;
// wagmiConnector?: Connector;
handleDisconnectWallet: () => void;
}

Expand All @@ -14,15 +18,15 @@ export function AccountMenu({
// wagmiConnector,
handleDisconnectWallet,
}: AccountMenuProps): React.JSX.Element | false {
// if (!address || !wagmiConnector) return false;
const { rippleWallet } = useContext(RippleWalletContext);
return (
<Menu variant={'account'}>
<MenuButton>
<HStack justifyContent={'space-evenly'}>
<Stack bg={'white.01'} borderRadius={'full'} p={'5px'}>
<Image p={'2.5px'} src={'./images/logos/xpr-logo.svg'} alt={'xrpl'} boxSize={'25px'} />
</Stack>
<Text>{truncateAddress('rfvtbrXSxLsxVWDktR4sdzjJgv8EnMKFKG')}</Text>
<Text>{truncateAddress(rippleWallet?.classicAddress!)}</Text>
<ChevronDownIcon boxSize={'35px'} color={'white'} />
</HStack>
</MenuButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import { VaultTransactionForm } from '@components/transaction-screen/transaction
import { Vault } from '@components/vault/vault';
import { BitcoinWalletContext } from '@providers/bitcoin-wallet-context-provider';
import { ProofOfReserveContext } from '@providers/proof-of-reserve-context-provider';
import { RippleWalletContext } from '@providers/ripple-user-wallet-context-provider';
import { RootState } from '@store/index';
import { mintUnmintActions } from '@store/slices/mintunmint/mintunmint.actions';
import { Client } from 'dlc-btc-lib/models';
import { createCheck, getRippleClient, getRippleWallet } from 'dlc-btc-lib/ripple-functions';
import { createCheck, getRippleClient } from 'dlc-btc-lib/ripple-functions';
import { shiftValue } from 'dlc-btc-lib/utilities';

interface BurnTokenTransactionFormProps {
Expand All @@ -35,6 +36,8 @@ export function BurnTokenTransactionForm({
const { unmintStep } = useSelector((state: RootState) => state.mintunmint);
const [isSubmitting, setIsSubmitting] = useState(false);

const { rippleWallet } = useContext(RippleWalletContext);

const currentVault = unmintStep[2];

async function handleButtonClick(withdrawAmount: number): Promise<void> {
Expand All @@ -45,12 +48,14 @@ export function BurnTokenTransactionForm({
// if (currentRisk === 'High') throw new Error('Risk Level is too high');
const formattedWithdrawAmount = BigInt(shiftValue(withdrawAmount));

const rippleWallet = getRippleWallet('sEdSKUhR1Hhwomo7CsUzAe2pv7nqUXT');
const issuerAddress = 'ra9epzthPkNXykgfadCwu8D7mtajj8DVCP';
const rippleClient: Client = getRippleClient('wss://s.altnet.rippletest.net:51233');
if (!rippleClient.isConnected()) {
await rippleClient.connect();
}
await createCheck(
rippleClient,
rippleWallet,
rippleWallet!,
issuerAddress,
undefined,
formattedWithdrawAmount.toString(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { useState } from 'react';
import { useContext, useState } from 'react';

import { Button, VStack, useToast } from '@chakra-ui/react';
import { setupXRPLVault } from '@functions/fetch.functions';
import { getRippleWallet } from 'dlc-btc-lib/ripple-functions';
import { RippleWalletContext } from '@providers/ripple-user-wallet-context-provider';

import { SetupVaultScreenVaultGraphics } from './components/setup-vault-screen.vault-graphics';

export function SetupVaultScreen(): React.JSX.Element {
const toast = useToast();

const [isSubmitting, setIsSubmitting] = useState(false);
const { rippleWallet } = useContext(RippleWalletContext);

async function handleSetup() {
try {
setIsSubmitting(true);
const xrplWallet = getRippleWallet('sEdSKUhR1Hhwomo7CsUzAe2pv7nqUXT');
await setupXRPLVault(xrplWallet.classicAddress);
await setupXRPLVault(rippleWallet?.classicAddress!);
} catch (error: any) {
setIsSubmitting(false);
toast({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
import { Box, Button, HStack, Image, Spinner, Text } from '@chakra-ui/react';
import { Connector } from 'wagmi';
// import { Box, Button, HStack, Image, Spinner, Text } from '@chakra-ui/react';
// import { Connector } from 'wagmi';

interface SelectWalletMenuProps {
wagmiConnector: Connector;
selectedWagmiConnectorID?: string;
isConnectWalletPending: boolean;
isConnectWalletSuccess: boolean;
handleConnectWallet: (wagmiConnector: Connector) => void;
}
// interface SelectWalletMenuProps {
// wagmiConnector: Connector;
// selectedWagmiConnectorID?: string;
// isConnectWalletPending: boolean;
// isConnectWalletSuccess: boolean;
// handleConnectWallet: (wagmiConnector: Connector) => void;
// }

export function SelectWalletMenu({
wagmiConnector,
selectedWagmiConnectorID,
isConnectWalletPending,
isConnectWalletSuccess,
handleConnectWallet,
}: SelectWalletMenuProps): React.JSX.Element {
const { id, icon, name } = wagmiConnector;
// export function SelectWalletMenu({
// wagmiConnector,
// selectedWagmiConnectorID,
// isConnectWalletPending,
// isConnectWalletSuccess,
// handleConnectWallet,
// }: SelectWalletMenuProps): React.JSX.Element {
// const { id, icon, name } = wagmiConnector;

const isThisWalletSelected = selectedWagmiConnectorID === id;
// const isThisWalletSelected = selectedWagmiConnectorID === id;

return (
<Button
borderColor={
isConnectWalletSuccess && isThisWalletSelected ? 'accent.lightBlue.01' : 'border.white.01'
}
variant={'wallet'}
onClick={() => handleConnectWallet(wagmiConnector)}
>
<Box position="relative" w={'100%'} display={'flex'} justifyContent={'center'}>
<HStack
justifyContent={'space-evenly'}
w={'250px'}
filter={isConnectWalletPending && isThisWalletSelected ? 'opacity(25%)' : 'none'}
>
<Image
src={name === 'WalletConnect' ? './images/logos/walletconnect.svg' : icon}
alt={name}
boxSize={'25px'}
/>
<Text w={'150px'}>{name}</Text>
</HStack>
{isConnectWalletPending && isThisWalletSelected && (
<Spinner size={'md'} color={'accent.lightBlue.01'} position={'absolute'} />
)}
</Box>
</Button>
);
}
// return (
// <Button
// borderColor={
// isConnectWalletSuccess && isThisWalletSelected ? 'accent.lightBlue.01' : 'border.white.01'
// }
// variant={'wallet'}
// onClick={() => handleConnectWallet(wagmiConnector)}
// >
// <Box position="relative" w={'100%'} display={'flex'} justifyContent={'center'}>
// <HStack
// justifyContent={'space-evenly'}
// w={'250px'}
// filter={isConnectWalletPending && isThisWalletSelected ? 'opacity(25%)' : 'none'}
// >
// <Image
// src={name === 'WalletConnect' ? './images/logos/walletconnect.svg' : icon}
// alt={name}
// boxSize={'25px'}
// />
// <Text w={'150px'}>{name}</Text>
// </HStack>
// {isConnectWalletPending && isThisWalletSelected && (
// <Spinner size={'md'} color={'accent.lightBlue.01'} position={'absolute'} />
// )}
// </Box>
// </Button>
// );
// }
Loading

0 comments on commit 7a2577b

Please sign in to comment.