forked from keep-starknet-strange/joyboy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Wallet Connect integration (keep-starknet-strange#177)
* wallet connect integration * Rename Modal to Dialog * Modal component * Wallet Modal * Wallet QR Modal * Add todo * Fix dependencies * Regenerate yarn lockfile * Remove dependency check
- Loading branch information
Showing
22 changed files
with
2,310 additions
and
734 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {mainnet} from '@starknet-react/chains'; | ||
import { | ||
argent, | ||
braavos, | ||
publicProvider, | ||
StarknetConfig, | ||
useInjectedConnectors, | ||
voyager, | ||
} from '@starknet-react/core'; | ||
import { | ||
ConnectorProvider as StarknetWCProvider, | ||
useArgentMobileConnector, | ||
} from '@starknet-wc/react'; | ||
import {Platform} from 'react-native'; | ||
import {constants} from 'starknet'; | ||
|
||
import {WalletQRModal} from '../modules/WalletQRModal'; | ||
|
||
export const StarknetReactProvider: React.FC<React.PropsWithChildren> = ({children}) => { | ||
const {connectors} = useInjectedConnectors({ | ||
// Show these connectors if the user has no connector installed. | ||
recommended: [argent(), braavos()], | ||
// Hide recommended connectors if the user has any connector installed. | ||
includeRecommended: 'onlyIfNoConnectors', | ||
// Randomize the order of the connectors. | ||
order: 'random', | ||
}); | ||
|
||
const argentMobileConnector = useArgentMobileConnector(); | ||
|
||
return ( | ||
<StarknetConfig | ||
chains={[mainnet]} | ||
provider={publicProvider()} | ||
connectors={[ | ||
argentMobileConnector({ | ||
chain: constants.NetworkName.SN_MAIN, | ||
// TODO: Move this to ENV | ||
wcProjectId: 'a9b4b052eb741f95a54c90ac5bdb343e', | ||
dappName: 'Joyboy', | ||
description: 'Joyboy Starknet dApp', | ||
url: 'https://joyboy.community', | ||
}), | ||
|
||
...(Platform.OS === 'web' ? connectors : []), | ||
]} | ||
explorer={voyager} | ||
> | ||
{children} | ||
</StarknetConfig> | ||
); | ||
}; | ||
|
||
export const StarknetProvider: React.FC<React.PropsWithChildren> = ({children}) => { | ||
return ( | ||
<StarknetWCProvider modal={WalletQRModal}> | ||
<StarknetReactProvider>{children}</StarknetReactProvider> | ||
</StarknetWCProvider> | ||
); | ||
}; |
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,66 @@ | ||
import React from 'react'; | ||
import {View} from 'react-native'; | ||
import {Portal} from 'react-native-portalize'; | ||
|
||
import {useStyles} from '../../hooks'; | ||
import {Button, ButtonProps} from '../Button'; | ||
import {Text} from '../Text'; | ||
import stylesheet from './styles'; | ||
|
||
export type DialogProps = { | ||
title: string; | ||
description: string; | ||
icon?: React.ReactNode; | ||
visible?: boolean; | ||
buttons: { | ||
label: string; | ||
type: ButtonProps['variant']; | ||
onPress: () => void; | ||
}[]; | ||
}; | ||
|
||
export const Dialog: React.FC<DialogProps> = ({ | ||
title, | ||
icon, | ||
description, | ||
visible = true, | ||
buttons, | ||
}) => { | ||
const styles = useStyles(stylesheet); | ||
|
||
if (!visible) return null; | ||
|
||
return ( | ||
<Portal> | ||
<View style={styles.container}> | ||
<View style={styles.modal}> | ||
<View style={styles.content}> | ||
{icon && <View style={styles.icon}>{icon}</View>} | ||
|
||
<Text weight="bold" fontSize={21} lineHeight={24} style={styles.title}> | ||
{title} | ||
</Text> | ||
|
||
<Text | ||
weight="semiBold" | ||
color="textSecondary" | ||
align="center" | ||
fontSize={15} | ||
lineHeight={20} | ||
> | ||
{description} | ||
</Text> | ||
</View> | ||
|
||
<View style={styles.buttons}> | ||
{buttons.map((button, index) => ( | ||
<Button key={index.toString()} block variant={button.type} onPress={button.onPress}> | ||
{button.label} | ||
</Button> | ||
))} | ||
</View> | ||
</View> | ||
</View> | ||
</Portal> | ||
); | ||
}; |
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,39 @@ | ||
import {Spacing, ThemedStyleSheet} from '../../styles'; | ||
|
||
export default ThemedStyleSheet((theme) => ({ | ||
container: { | ||
position: 'absolute', | ||
top: 0, | ||
right: 0, | ||
bottom: 0, | ||
left: 0, | ||
width: '100%', | ||
height: '100%', | ||
backgroundColor: 'rgba(0, 0, 0, 0.4)', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
paddingHorizontal: Spacing.xlarge, | ||
}, | ||
modal: { | ||
width: '100%', | ||
backgroundColor: theme.colors.surface, | ||
padding: Spacing.large, | ||
borderRadius: 24, | ||
}, | ||
|
||
content: { | ||
alignItems: 'center', | ||
}, | ||
icon: { | ||
marginTop: Spacing.xsmall, | ||
marginBottom: Spacing.large, | ||
}, | ||
title: { | ||
marginBottom: Spacing.medium, | ||
}, | ||
|
||
buttons: { | ||
gap: Spacing.xsmall, | ||
marginTop: Spacing.xlarge, | ||
}, | ||
})); |
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.