-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add keystone #907
Open
soralit
wants to merge
7
commits into
tonkeeper:release/4.8.0
Choose a base branch
from
KeystoneHQ:add-keystone
base: release/4.8.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add keystone #907
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8eb1a07
feat(keystone): add basic keystone components
soralit 7e69bce
feat(keystone): add connection progress
soralit 69dcca6
feat(keystone): add sign transaction
soralit 6f1009f
feat(keystone): support ton connect for keystone
soralit cc96861
feat(keystone): ui refinement
soralit 0b19e58
feat(keystone): prevent adding the same wallets for keystone
soralit b4b1b3d
fix(keystone): wallet connection failed
soralit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
56 changes: 56 additions & 0 deletions
56
packages/mobile/src/core/KeystoneQRCode/KeystoneQRCode.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,56 @@ | ||
import { UR, UREncoder } from '@keystonehq/keystone-sdk'; | ||
import { View, ViewStyle, deviceWidth, ns } from '@tonkeeper/uikit'; | ||
import React, { useCallback, useEffect, useMemo, useState } from 'react'; | ||
import { Animated, LayoutChangeEvent, StyleSheet } from 'react-native'; | ||
import QRCode from 'react-native-qrcode-styled'; | ||
import { useAnimatedStyle, useSharedValue } from 'react-native-reanimated'; | ||
|
||
export type KeystoneQRCodeProps = { | ||
ur: UR; | ||
}; | ||
|
||
export const QR_SIZE = deviceWidth - ns(16) * 2 - ns(24) * 2; | ||
|
||
export const QR_WRAP_STYLE: ViewStyle = { | ||
width: QR_SIZE, | ||
height: QR_SIZE, | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}; | ||
|
||
export const KeystoneQRCode = ({ ur }: KeystoneQRCodeProps) => { | ||
const encoder = useMemo(() => { | ||
return new UREncoder(ur, 200); | ||
}, [ur]); | ||
const [data, setData] = useState(encoder.nextPart().toUpperCase()); | ||
useEffect(() => { | ||
const id = setInterval(() => { | ||
setData(encoder.nextPart().toUpperCase()); | ||
}, 100); | ||
return () => { | ||
clearInterval(id); | ||
}; | ||
}, [encoder, setData]); | ||
|
||
const qrCodeScale = useSharedValue(1); | ||
|
||
const handleQrCodeLayout = useCallback( | ||
(e: LayoutChangeEvent) => { | ||
qrCodeScale.value = QR_SIZE / e.nativeEvent.layout.width; | ||
}, | ||
[qrCodeScale], | ||
); | ||
|
||
return ( | ||
<View style={QR_WRAP_STYLE}> | ||
<QRCode data={data} padding={20} style={styles.qrcode} onLayout={handleQrCodeLayout} pieceSize={4} /> | ||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
qrcode: { | ||
backgroundColor: '#FFF', | ||
borderRadius: 16, | ||
}, | ||
}); |
17 changes: 17 additions & 0 deletions
17
packages/mobile/src/core/KeystoneScanQR/KeystoneScanQR.interface.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,17 @@ | ||
import { RouteProp } from '@react-navigation/native'; | ||
import { AppStackRouteNames } from '$navigation'; | ||
import { AppStackParamList } from '$navigation/AppStack'; | ||
|
||
export enum KeystoneScanState { | ||
SUCCESS, | ||
FAILED, | ||
} | ||
|
||
export interface KeystoneScanStatus { | ||
state: KeystoneScanState, | ||
errorMessage: string, | ||
} | ||
|
||
export interface KeystoneScanQRProps { | ||
route: RouteProp<AppStackParamList, AppStackRouteNames.KeystoneScanQR>; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.