-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: valtio state management * feat: using vialto for state management. Disconnect not working * fix: types and rename clasess * fix: requestUpdate on disconnect * fix: typo * fix: add usePersistence: true * fix: remove commented code * fix: dist instead of src * fix: typo * fix: using built it connection functions * fix: tests
- Loading branch information
1 parent
5517d3b
commit 79dd9c7
Showing
46 changed files
with
394 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 2 additions & 29 deletions
31
...t-react/src/Components/ConnectWalletButtonWithModal/Components/ConnectButtonWithModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,11 @@ | ||
import { useCallback, useContext, useMemo } from 'react'; | ||
import type { WalletSource } from '@vechainfoundation/dapp-kit'; | ||
import type { SourceInfo } from '@vechainfoundation/dapp-kit-ui'; | ||
import { useContext, useMemo } from 'react'; | ||
import { ThemeContext } from '../../../provider/ThemeProvider'; | ||
import { useWallet } from '../../../ConnexProvider'; | ||
import { createButtonWithModal } from './Wrapped/ConnectModalWithButtonWrapped'; | ||
|
||
export const ConnectButtonWithModal = () => { | ||
const { theme } = useContext(ThemeContext); | ||
|
||
const ModalWithButton = useMemo(() => createButtonWithModal(), []); | ||
|
||
const { setSource, connect, setAccount } = useWallet(); | ||
|
||
const connectHandler = useCallback( | ||
async (source: WalletSource) => { | ||
setSource(source); | ||
|
||
const { account } = await connect(); | ||
|
||
setAccount(account); | ||
}, | ||
[connect, setAccount, setSource], | ||
); | ||
|
||
const _connect = useCallback( | ||
(source?: SourceInfo) => { | ||
if (source) { | ||
connectHandler(source.id).catch(() => { | ||
// do nothing | ||
}); | ||
} | ||
}, | ||
[connectHandler], | ||
); | ||
|
||
return <ModalWithButton mode={theme.mode} onSourceClick={_connect} />; | ||
return <ModalWithButton mode={theme.mode} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.