-
Notifications
You must be signed in to change notification settings - Fork 6
310/972 ios create native bridge for onboarding workflow #2022
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
Open
zhouxl
wants to merge
13
commits into
dev
Choose a base branch
from
310/972-ios-create-native-bridge-for-onboarding-workflow
base: dev
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
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d7800bc
feat: create bridge launchNativeScreen
zhouxl 00e8933
feat: launchNativeScreen
zhouxl 411f0d3
Merge branch 'dev' into 310/972-ios-create-native-bridge-for-onboardi…
zhouxl d28c43b
feat: onboarding
zhouxl 74f733c
feat: push onboarding
zhouxl 14913e4
feat: update React Native topAnchor
zhouxl ee5a37b
Merge branch 'dev' into 310/972-ios-create-native-bridge-for-onboardi…
zhouxl a3d7777
feat: update RN
zhouxl 169fbc1
feat: eoa add parent for RN
zhouxl 12e0d10
feat: start with onboard for no profile
zhouxl 9e18ef4
feat: switch root between RN and SideContainerView
zhouxl 98f43e4
feat: add animation and setup flag
zhouxl c5dd810
feat: add restore from icloud
zhouxl 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 hidden or 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 hidden or 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 hidden or 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,18 @@ | ||
| // | ||
| // NativeScreenName.swift | ||
| // FRW | ||
| // | ||
| // Created by cat on 12/5/25. | ||
| // | ||
|
|
||
| import Foundation | ||
|
|
||
| enum NativeScreenName: String { | ||
| case deviceBackup | ||
| case recoveryPhraseRestore | ||
| case keyStoreRestore | ||
| case privateKeyRestore | ||
| case googleDriveRestore | ||
| case multiRestore | ||
| case backupOptions | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,157 @@ | ||
| // | ||
| // TurboModule+Onboard.swift | ||
| // FRW | ||
| // | ||
| // Created by cat on 12/11/25. | ||
| // | ||
|
|
||
| import Foundation | ||
| import FlowWalletKit | ||
| import WalletCore | ||
| import Flow | ||
| import UserNotifications | ||
| import FirebaseAuth | ||
| import Firebase | ||
|
|
||
| extension TurboModuleSwift { | ||
| @objc | ||
| static func generateSeedPhrase(strength: NSNumber?) async throws -> [String: Any] { | ||
|
|
||
| let mnemonicStrength = strength?.int32Value ?? 128 | ||
| guard let hdWallet = HDWallet(strength: mnemonicStrength, passphrase: "") else { | ||
| HUD.error(title: "invalid_data".localized) | ||
| throw RNBridgeError.mnemonicGenerationFailed | ||
| } | ||
|
|
||
| let key = FlowWalletKit.SeedPhraseKey(hdWallet: hdWallet, storage: FlowWalletKit.SeedPhraseKey.seedPhraseStorage) | ||
|
|
||
| guard let publicKey = key.publicKey(signAlgo: .ECDSA_SECP256k1) else { | ||
| throw RNBridgeError.accountCreationFailed | ||
| } | ||
| let publicKeyHex = publicKey.hexString | ||
| let accountKey = RNBridge.AccountKey( | ||
| publicKey: publicKeyHex, | ||
| hashAlgoStr: Flow.HashAlgorithm.SHA2_256.id, | ||
| signAlgoStr: Flow.SignatureAlgorithm.ECDSA_SECP256k1.id, | ||
| weight: 1000, | ||
| hashAlgo: Flow.HashAlgorithm.SHA2_256.index, | ||
| signAlgo: Flow.SignatureAlgorithm.ECDSA_SECP256k1.index | ||
| ) | ||
|
|
||
| let response = RNBridge.SeedPhraseGenerationResponse( | ||
| mnemonic: hdWallet.mnemonic, | ||
| accountKey: accountKey, | ||
| drivepath: FlowWalletKit.SeedPhraseKey.derivationPath | ||
| ) | ||
|
|
||
| return try response.toDictionary() | ||
| } | ||
|
|
||
| @objc | ||
| static func registerSecureTypeAccount(username: String) async throws -> [String: Any] { | ||
| print("TurboModuleSwift: registerSecureTypeAccount called") | ||
| do { | ||
| let result = try await UserManager.shared.register(username) | ||
| guard let txid = result else { | ||
| throw RNBridgeError.accountCreationFailed | ||
| } | ||
| let response = RNBridge.CreateAccountResponse( | ||
| success: true, | ||
| address: "", | ||
| username: username, | ||
| accountType: .hardware, | ||
| txId: txid, | ||
| error: "" | ||
| ) | ||
|
|
||
| return try response.toDictionary() | ||
| } catch { | ||
| let response = RNBridge.CreateAccountResponse( | ||
| success: false, | ||
| address: "", | ||
| username: username, | ||
| accountType: .hardware, | ||
| txId: "", | ||
| error: error.localizedDescription | ||
| ) | ||
| return try response.toDictionary() | ||
| } | ||
| } | ||
|
|
||
| @objc | ||
| static func initSecureEnclaveWallet(txId: String) async throws -> [String: Any] { | ||
| print("TurboModuleSwift: initSecureEnclaveWallet called") | ||
| guard let uid = UserManager.shared.RNRegisterInfo[txId] else { | ||
| return [ | ||
| "success": false, | ||
| "address": "", | ||
| "error": "Secure Enclave wallet initialization not yet implemented in WalletManager" | ||
| ] | ||
| } | ||
| let result = await WalletManager.shared.keyProvider(with: uid)?.keyType == .secureEnclave | ||
| let address = await WalletManager.shared.getPrimaryWalletAddress() ?? "" | ||
| return [ | ||
| "success": result, | ||
| "address": result ? address : "", | ||
| "error": "" | ||
| ] | ||
| } | ||
|
|
||
| @objc | ||
| static func signInWithCustomToken(customToken: String) async throws { | ||
| print("TurboModuleSwift: signInWithCustomToken called") | ||
| try await Auth.auth().signIn(withCustomToken: customToken) | ||
| } | ||
|
|
||
| @objc | ||
| static func saveMnemonic(mnemonic: String, customToken: String, txId: String, username: String) async throws { | ||
| print("TurboModuleSwift: saveMnemonic called") | ||
| try await UserManager.shared.restoreLogin(withMnemonic: mnemonic) | ||
|
|
||
| } | ||
|
|
||
| // MARK: - Screen Security | ||
| @objc | ||
| static func setScreenSecurityLevel(level: String) { | ||
| print("TurboModuleSwift: setScreenSecurityLevel called") | ||
| log.info("Screen Security level:\(level)") | ||
| switch level { | ||
| case "secure": | ||
| break | ||
| default: | ||
| break | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // MARK: - Notification Permissions | ||
| @objc | ||
| static func requestNotificationPermission() async throws -> Bool { | ||
| print("TurboModuleSwift: requestNotificationPermission called") | ||
| return await withCheckedContinuation { continuation in | ||
| UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { granted, error in | ||
| continuation.resume(returning: granted) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @objc | ||
| static func checkNotificationPermission() async throws -> Bool { | ||
| print("TurboModuleSwift: checkNotificationPermission called") | ||
| return await withCheckedContinuation { continuation in | ||
| UNUserNotificationCenter.current().getNotificationSettings { settings in | ||
| let granted = settings.authorizationStatus == .authorized | ||
| print("TurboModuleSwift: result: \(granted)") | ||
| continuation.resume(returning: granted) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Device Info | ||
| @objc | ||
| static func getDeviceId() -> String { | ||
| print("TurboModuleSwift: getDeviceId called") | ||
| return UUIDManager.appUUID() | ||
| } | ||
|
|
||
| } | ||
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.
The parameters
customToken,txId, andusernameare declared but never used in the method body. Either remove these unused parameters or implement the logic that requires them.