Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Nov 15, 2024
1 parent be0c447 commit ef6af04
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ vi.mock(import('@/hooks'), async (importOriginal) => {

return {
...actual,
useAccount: vi.fn()
useBtcAccount: vi.fn()
};
});

Expand Down
7 changes: 6 additions & 1 deletion apps/evm/src/app/[lang]/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ export function Providers({ children }: PropsWithChildren) {
},
{
label: { icon: <EthereumIcon /> },
walletsFilter: FilterChain('EVM')
walletsFilter: FilterChain('EVM'),
recommendedWallets: [
{
walletKey: 'okxwallet'
}
]
},
{
label: { icon: <BitcoinIcon /> },
Expand Down
1 change: 0 additions & 1 deletion apps/evm/src/components/AuthButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export type { AuthButtonProps } from './AuthButton';
export { AuthButton } from './AuthButton';
1 change: 0 additions & 1 deletion apps/evm/src/components/ChainLogo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { ChainLogo } from './ChainLogo';
export type { ChainLogoProps } from './ChainLogo';
9 changes: 7 additions & 2 deletions apps/evm/src/components/Layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { t, Trans } from '@lingui/macro';
import { useState } from 'react';
import { useTheme } from 'styled-components';
import { useLingui } from '@lingui/react';
import { DynamicWidget } from '@dynamic-labs/sdk-react-core';
import { useDynamicContext } from '@dynamic-labs/sdk-react-core';

import { Logo } from '../Logo';
import { SocialsGroup } from '../SocialsGroup';
Expand All @@ -38,9 +38,12 @@ type HeaderProps = Props & InheritAttrs;

const Header = ({ isTestnet, isFusion, ...props }: HeaderProps): JSX.Element => {
const { i18n } = useLingui();

const { setSidebarOpen } = useLayoutContext();
const [isOpen, setOpen] = useState(false);

const { setShowAuthFlow } = useDynamicContext();

const theme = useTheme();
const isMobileViewport = useMediaQuery(theme.breakpoints.down('md'));
const { isMobile: isMobileUserAgent } = useUserAgent();
Expand Down Expand Up @@ -113,7 +116,9 @@ const Header = ({ isTestnet, isFusion, ...props }: HeaderProps): JSX.Element =>
</Popover>
<SocialsGroup hidden={isMobile} variant='ghost' />
<FusionPopover />
<DynamicWidget variant='modal' />
<Button variant='ghost' onPress={() => setShowAuthFlow(true)}>
Connect Modal
</Button>
</Flex>
</StyledHeader>
);
Expand Down
54 changes: 0 additions & 54 deletions apps/evm/src/hooks/btc/useDynamicWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,64 +5,10 @@ import { useUserWallets } from '@dynamic-labs/sdk-react-core';

type UserBtcDynamicWalletReturnType = BitcoinWallet | undefined;

// internal
const useBtcDynamicWallet = (): UserBtcDynamicWalletReturnType => {
const userWallets = useUserWallets();

return userWallets.find((wallet) => wallet.chain === 'BTC') as BitcoinWallet | undefined;

// if (!wallet) return undefined;

// const signAllInputs = useCallback(
// async (psbtBase64: string) => {
// if (!wallet) {
// throw new Error('BTC Wallet not connected');
// }

// const paymentAddress = wallet?.additionalAddresses.find((address) => address.type === 'payment');

// if (!paymentAddress) {
// throw new Error('Missing payment address');
// }

// // Sign all inputs with the payment address
// const unsignedTx = Transaction.fromPSBT(base64.decode(psbtBase64));
// const inputLength = unsignedTx.inputsLength;
// const inputsToSign = Array.from({ length: inputLength }, (_, i) => i);
// const psbt = unsignedTx.toPSBT(0);

// // Define the parameters for signing the PSBT
// const params = {
// allowedSighash: [1],
// unsignedPsbtBase64: base64.encode(psbt),
// signature: [
// {
// address: paymentAddress.address,
// signingIndexes: inputsToSign
// }
// ]
// };

// // Request the wallet to sign the PSBT
// const signedPsbt = await wallet.signPsbt(params);

// if (!signedPsbt) {
// throw new Error('Not signed');
// }

// const signedTx = Transaction.fromPSBT(base64.decode(signedPsbt.signedPsbt));

// signedTx.finalize();

// return signedTx.hex;
// },
// [wallet]
// );

// return {
// ...wallet,
// signAllInputs
// };
};

export { useBtcDynamicWallet };
1 change: 1 addition & 0 deletions apps/evm/src/hooks/btc/useFeeRate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ function useBtcFeeRate<TData = BtcFeeRateReturnType>({ query }: UseBtcFeeRatePro
}

export { useBtcFeeRate };
export type { BtcFeeRateReturnType };
29 changes: 22 additions & 7 deletions apps/evm/src/test-utils/wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
import { QueryClient, QueryClientProvider } from '@gobob/react-query';
import { BOBUIProvider } from '@gobob/ui';
import { WagmiProvider } from '@gobob/wagmi';
import { WagmiProvider } from 'wagmi';
import { PropsWithChildren } from 'react';
import { getConfig } from '@gobob/wagmi';
import { DynamicWagmiConnector } from '@dynamic-labs/wagmi-connector';
import { DynamicContextProvider } from '@dynamic-labs/sdk-react-core';
import { BitcoinWalletConnectors } from '@dynamic-labs/bitcoin';
import { EthereumWalletConnectors } from '@dynamic-labs/ethereum';

import { isProd } from '@/constants';
import { LinguiClientProvider } from '@/i18n/provider';

export const wrapper = ({ children }: PropsWithChildren) => {
const queryClient = new QueryClient();

return (
<LinguiClientProvider initialLocale='en' initialMessages={{}}>
<QueryClientProvider client={queryClient}>
<WagmiProvider>
<BOBUIProvider>{children}</BOBUIProvider>
<DynamicContextProvider
settings={{
environmentId: process.env.NEXT_PUBLIC_DYNAMIC_ENVIRONMENT_ID as string,
walletConnectors: [BitcoinWalletConnectors, EthereumWalletConnectors]
}}
>
<LinguiClientProvider initialLocale='en' initialMessages={{}}>
<WagmiProvider config={getConfig({ isProd, multiInjectedProviderDiscovery: false })}>
<QueryClientProvider client={queryClient}>
<DynamicWagmiConnector>
<BOBUIProvider>{children}</BOBUIProvider>
</DynamicWagmiConnector>
</QueryClientProvider>
</WagmiProvider>
</QueryClientProvider>
</LinguiClientProvider>
</LinguiClientProvider>
</DynamicContextProvider>
);
};

0 comments on commit ef6af04

Please sign in to comment.