This repository was archived by the owner on Mar 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Decouple Transfer from FiatConnect and auto-enable asset on buy #1837
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2421df4
Auto-enable asset on fiat buy continue
gemdev111 16225a5
Decouple Transfer from FiatConnect by moving navigation to app target
gemdev111 4c1b7a1
Fix walletId initialization and add missing properties
gemdev111 6147953
Remove redundant walletId stored property, derive from wallet
gemdev111 8e4e03b
Remove unused fiatService @Entry and GemAPI import
gemdev111 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| import Validators | ||
| import BigInt | ||
| import FiatService | ||
| import BalanceService | ||
|
|
||
| @MainActor | ||
| @Observable | ||
|
|
@@ -43,15 +44,18 @@ | |
| fiatService: FiatService, | ||
| currencyFormatter: CurrencyFormatter = CurrencyFormatter(currencyCode: Currency.usd.rawValue), | ||
| assetAddress: AssetAddress, | ||
| walletId: WalletId, | ||
| wallet: Wallet, | ||
| assetsEnabler: any AssetsEnabler, | ||
| type: FiatQuoteType = .buy, | ||
| amount: Int? = nil | ||
| ) { | ||
| self.fiatService = fiatService | ||
| self.currencyFormatter = currencyFormatter | ||
| self.assetAddress = assetAddress | ||
| self.walletId = walletId | ||
| self.wallet = wallet | ||
| self.assetsEnabler = assetsEnabler | ||
| self.type = type | ||
| let walletId = wallet.walletId | ||
| self.assetQuery = ObservableQuery(AssetRequest(walletId: walletId, assetId: assetAddress.asset.id), initialValue: .with(asset: assetAddress.asset)) | ||
|
|
||
| let buyOperation = BuyOperation( | ||
|
|
@@ -191,6 +195,7 @@ | |
| } | ||
|
|
||
| urlState = .data(()) | ||
| Task { await enableAsset() } | ||
| await UIApplication.shared.open(url, options: [:]) | ||
| } catch { | ||
| urlState = .error(error) | ||
|
|
@@ -239,6 +244,14 @@ | |
| // MARK: - Private | ||
|
|
||
| extension FiatSceneViewModel { | ||
| private func enableAsset() async { | ||
| do { | ||
| try await assetsEnabler.enableAssets(wallet: wallet, assetIds: [asset.id], enabled: true) | ||
|
Check failure on line 249 in Features/FiatConnect/Sources/ViewModels/FiatSceneViewModel.swift
|
||
| } catch { | ||
| debugLog("FiatSceneViewModel enableAsset error: \(error)") | ||
| } | ||
|
Comment on lines
+250
to
+252
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } | ||
|
|
||
| private var balanceModel: BalanceViewModel { | ||
| BalanceViewModel(asset: asset, balance: assetData.balance, formatter: valueFormatter) | ||
| } | ||
|
|
||
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
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
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
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
Oops, something went wrong.
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 class property
walletIdis not being initialized in theinitmethod, which will cause a compilation error. You should initialize it from thewalletparameter. The localwalletIdvariable then becomes redundant.Please also ensure that
walletandassetsEnablerare declared as properties ofFiatSceneViewModel.