Skip to content

Commit

Permalink
Merge branch 'dev' into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wenty22 committed Nov 8, 2023
2 parents 1f4d242 + 9daf474 commit 3937b2e
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 38 deletions.
14 changes: 14 additions & 0 deletions examples/test/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
WalletKitOptions,
WalletKitProvider,
getDefaultConfig,
useModal,
} from '@totejs/walletkit';
import { trustWallet, metaMask, walletConnect } from '@totejs/walletkit/wallets';
import { useState } from 'react';
Expand Down Expand Up @@ -44,9 +45,22 @@ export default function App({ Component, pageProps }: AppProps) {

<WalletKitProvider options={options} mode={mode} debugMode>
<WalletKitButton />
<Example />
<Component {...pageProps} />
<SwitchNetworkModal />
</WalletKitProvider>
</WagmiConfig>
);
}

function Example() {
const { onOpen, onOpenProfile, onOpenSwitchNetwork } = useModal();

return (
<>
<button onClick={onOpen}>Open Connect Modal</button>
<button onClick={onOpenProfile}>Open Profile Modal</button>
<button onClick={onOpenSwitchNetwork}>Open SwitchNetwork Modal</button>
</>
);
}
4 changes: 2 additions & 2 deletions packages/walletkit/src/components/ModalProvider/context.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useContext } from 'react';

export type OpenSwitchNetworkOptions = {
export interface OpenSwitchNetworkOptions extends React.MouseEvent {
isClosable?: boolean;
};
}

export interface ModalContextProps {
isClosable: boolean;
Expand Down
4 changes: 2 additions & 2 deletions packages/walletkit/src/components/ModalProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ export function ModalProvider(props: ModalProviderProps) {
});
}
},
onOpenSwitchNetwork(options: OpenSwitchNetworkOptions = {}) {
const { isClosable = true } = options;
onOpenSwitchNetwork(options?: OpenSwitchNetworkOptions) {
const { isClosable = true } = options ?? {};

if (isConnected) {
router.push(routes.SWITCH_NETWORK);
Expand Down
4 changes: 2 additions & 2 deletions packages/walletkit/src/components/WalletKitProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ export const WalletKitProvider = (props: WalletKitProviderProps) => {
const finalChains = getDefaultSupportedChains(options, chains);

const finalValue: WalletKitContextProps = {
// eslint-disable-next-line @typescript-eslint/no-empty-function
log: debugMode ? console.log : () => {},
options: finalOptions,
supportedChains: finalChains,
connectRole,
setConnectRole,
selectedConnector,
setSelectedConnector,
// eslint-disable-next-line @typescript-eslint/no-empty-function
log: debugMode ? console.log : () => {},
};
return finalValue;
}, [options, chains, connectRole, selectedConnector, debugMode]);
Expand Down
4 changes: 2 additions & 2 deletions packages/walletkit/src/hooks/useConnectors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Connector, useConnect } from 'wagmi';
import { useConnect } from 'wagmi';

export function useConnectors() {
const { connectors } = useConnect();
Expand All @@ -7,5 +7,5 @@ export function useConnectors() {

export function useConnector(id: string) {
const connectors = useConnectors();
return connectors.find((c) => c.id === id) as Connector;
return connectors.find((c) => c.id === id);
}
5 changes: 4 additions & 1 deletion packages/walletkit/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default defineConfig({
dts(),
],
build: {
target: 'es2020',
target: 'esnext',
minify: false,
lib: {
formats: ['es'],
Expand All @@ -27,6 +27,9 @@ export default defineConfig({
rollupOptions: {
external: ['react', 'react-dom', 'viem', 'wagmi', 'qrcode'],
plugins: [peerDepsExternal(), nodeResolve()],
output: {
chunkFileNames: 'common.js',
},
},
},
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3937b2e

Please sign in to comment.