-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow custom button for connecting (#74)
* feat: allow custom button for connecting * fix: private constructors * fix: theme types * fix: linting typescript * fix: merge main * fix: connect wallet not working * fix: fix ts issues
- Loading branch information
1 parent
adcacc0
commit dbe61c2
Showing
34 changed files
with
336 additions
and
161 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
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
...nnectWalletButton/ConnectWalletButton.tsx → ...etButtonWithModal/ConnectWalletButton.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
File renamed without changes.
49 changes: 49 additions & 0 deletions
49
packages/react-wallet-kit/src/Components/ConnectWalletModal/ConnectWalletModal.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, { useCallback } from 'react'; | ||
import type { WalletSource } from '@vechainfoundation/wallet-kit'; | ||
import type { SourceInfo } from '@vechainfoundation/vanilla-wallet-kit'; | ||
import { ConnectModal } from '@vechainfoundation/vanilla-wallet-kit'; | ||
import { createComponent } from '@lit/react'; | ||
import GlobalFonts from '../../../assets/fonts/fonts'; | ||
import { ThemeProvider } from '../../provider/ThemeProvider'; | ||
import { ThemeSelector } from '../ThemeSelector'; | ||
import { useWallet } from '../../ConnexProvider'; | ||
|
||
export const ConnectModalWrapped = createComponent({ | ||
tagName: 'vwk-connect-modal', | ||
elementClass: ConnectModal, | ||
react: React, | ||
}); | ||
|
||
export const ConnectWalletModal: React.FC = (): React.ReactElement => { | ||
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 ( | ||
<ThemeProvider> | ||
<GlobalFonts /> | ||
<ConnectModalWrapped onSourceClick={_connect} open={false} /> | ||
<ThemeSelector /> | ||
</ThemeProvider> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/react-wallet-kit/src/Components/ConnectWalletModal/index.ts
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ConnectWalletModal'; |
5 changes: 2 additions & 3 deletions
5
...WalletButton/Components/ThemeSelector.tsx → ...llet-kit/src/Components/ThemeSelector.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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './ConnectWalletModal'; | ||
export * from './ConnectWalletButtonWithModal'; |
41 changes: 0 additions & 41 deletions
41
packages/react-wallet-kit/src/ConnectWalletButton/Constants/Constants.ts
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
packages/react-wallet-kit/src/ConnectWalletButton/Constants/index.ts
This file was deleted.
Oops, something went wrong.
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.