Skip to content

Commit 71b94fd

Browse files
committed
Merge branch 'feature/coinbase-ramp' into feature/fw-adoptation
2 parents 195b023 + 504917d commit 71b94fd

File tree

19 files changed

+505
-201
lines changed

19 files changed

+505
-201
lines changed

Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ abstract_target 'fearlessAll' do
2020
pod 'SVGKit'
2121
pod 'Charts', '~> 4.1.0'
2222
pod 'MediaView', :git => 'https://github.com/bnsports/MediaView.git', :branch => 'dev'
23-
pod 'FearlessKeys', '0.1.4'
23+
pod 'FearlessKeys', '0.1.5'
2424

2525
target 'fearlessTests' do
2626
inherit! :search_paths

Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ PODS:
99
- Cuckoo (2.0.9):
1010
- Cuckoo/Swift (= 2.0.9)
1111
- Cuckoo/Swift (2.0.9)
12-
- FearlessKeys (0.1.4)
12+
- FearlessKeys (0.1.5)
1313
- FireMock (3.1)
1414
- Kingfisher (7.10.2)
1515
- MediaView (0.2.0)
@@ -82,7 +82,7 @@ PODS:
8282
DEPENDENCIES:
8383
- Charts (~> 4.1.0)
8484
- Cuckoo
85-
- FearlessKeys (= 0.1.4)
85+
- FearlessKeys (= 0.1.5)
8686
- FireMock
8787
- Kingfisher (= 7.10.2)
8888
- MediaView (from `https://github.com/bnsports/MediaView.git`, branch `dev`)
@@ -140,7 +140,7 @@ SPEC CHECKSUMS:
140140
Charts: ce0768268078eee0336f122c3c4ca248e4e204c5
141141
CocoaLumberjack: 6a459bc897d6d80bd1b8c78482ec7ad05dffc3f0
142142
Cuckoo: e2cc9a06a47d3faee7430a261c9c654b79b35f6e
143-
FearlessKeys: 5ec2782533624d237c899677a8c10859fbbc6668
143+
FearlessKeys: 54697ac7bdb2a16aa4525bed06c8769a351606db
144144
FireMock: 3eed872059c12f94855413347da83b9d6d1a6fac
145145
Kingfisher: 99edc495d3b7607e6425f0d6f6847b2abd6d716d
146146
MediaView: 10ff6a5c7950a7c72c5da9e9b89cc85a981e6abc
@@ -158,6 +158,6 @@ SPEC CHECKSUMS:
158158
SwiftLint: bd7cfb914762ab5f0cbb632964849571db075706
159159
SwiftyBeaver: ade157e4f857812e7d7f15f2e3396bb8733f8a1c
160160

161-
PODFILE CHECKSUM: 6eca9a23a0e78699b9b76e0f4a5d70c067f5290f
161+
PODFILE CHECKSUM: d50f67e5652b6dc7c25c383940113f88a40d89bc
162162

163163
COCOAPODS: 1.15.2

fearless.xcodeproj/project.pbxproj

Lines changed: 201 additions & 179 deletions
Large diffs are not rendered by default.

fearless.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 7 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.25 KB
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "Coinbase SVG Icon.pdf",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
}
12+
}

fearless/Common/Helpers/AssetModelMapper.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ extension AssetModelMapper: CoreDataMapperProtocol {
100100
assetType: assetType,
101101
priceProvider: priceProvider,
102102
coingeckoPriceId: entity.priceId,
103-
priceData: priceDatas
103+
priceData: priceDatas,
104+
coinbaseUrl: entity.coinbaseUrl
104105
)
105106
}
106107

@@ -122,6 +123,7 @@ extension AssetModelMapper: CoreDataMapperProtocol {
122123
entity.isUtility = model.isUtility
123124
entity.isNative = model.isNative
124125
entity.staking = model.staking?.rawValue
126+
entity.coinbaseUrl = model.coinbaseUrl
125127

126128
let priceProviderContext = CDPriceProvider(context: context)
127129
priceProviderContext.type = model.priceProvider?.type.rawValue
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import Foundation
2+
import SSFModels
3+
import FearlessKeys
4+
5+
final class CoinbasePurchaseProvivder: PurchaseProviderProtocol {
6+
enum Constants {
7+
static let title = "Coinbase"
8+
static let icon = R.image.iconCoinbase()
9+
}
10+
11+
static let baseUrlString = "https://pay.coinbase.com/buy/select-asset"
12+
13+
private var chainName: String?
14+
15+
func with(chainName: String) -> Self {
16+
self.chainName = chainName
17+
return self
18+
}
19+
20+
func buildPurchaseActions(asset: AssetModel, address: String) -> [PurchaseAction] {
21+
if let url = buildURLForAsset(asset, address: address) {
22+
return [PurchaseAction(title: Constants.title, url: url, icon: Constants.icon!)]
23+
}
24+
return []
25+
}
26+
27+
private func buildURLForAsset(_ asset: AssetModel, address: String) -> URL? {
28+
guard let chainName else {
29+
return nil
30+
}
31+
32+
guard let endpoint = asset.coinbaseUrl?.replacingOccurrences(of: "{address}", with: address) else {
33+
return nil
34+
}
35+
36+
var components = URLComponents(string: Self.baseUrlString.appending(endpoint))
37+
38+
let queryItems = [
39+
URLQueryItem(name: "appId", value: CoinbaseKeys.coinbaseAppId)
40+
]
41+
42+
components?.queryItems = queryItems
43+
44+
return components?.url
45+
}
46+
}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Foundation
2+
import SSFModels
23

34
extension PurchaseAggregator {
4-
static func defaultAggregator(with purchaseProviders: [PurchaseProviderProtocol]?) -> PurchaseAggregator {
5+
static func defaultAggregator(with purchaseProviders: [PurchaseProviderProtocol]?, chain: ChainModel) -> PurchaseAggregator {
56
let config: ApplicationConfigProtocol = ApplicationConfig.shared
67

78
let moonpaySecretKeyData = Data(MoonPayKeys.secretKey.utf8)
@@ -11,12 +12,14 @@ extension PurchaseAggregator {
1112
MoonpayProviderFactory().createProvider(
1213
with: moonpaySecretKeyData,
1314
apiKey: config.moonPayApiKey
14-
)
15+
),
16+
CoinbasePurchaseProvivder()
1517
]
1618
return PurchaseAggregator(providers: purchaseProviders ?? defaultProviders)
1719
.with(appName: config.purchaseAppName)
1820
.with(logoUrl: config.logoURL)
1921
.with(colorCode: R.color.colorPink()!.hexRGB)
2022
.with(callbackUrl: config.purchaseRedirect)
23+
.with(chainName: chain.name)
2124
}
2225
}

fearless/Common/PurchaseProvider/PurchaseProvider.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ extension PurchaseAggregator: PurchaseProviderProtocol {
3030
providers = providers.map { $0.with(callbackUrl: callbackUrl) }
3131
return self
3232
}
33+
34+
func with(chainName: String) -> Self {
35+
providers = providers.map { $0.with(chainName: chainName ) }
36+
return self
37+
}
3338

3439
func buildPurchaseActions(asset: AssetModel, address: String) -> [PurchaseAction] {
3540
providers.flatMap { $0.buildPurchaseActions(asset: asset, address: address) }

0 commit comments

Comments
 (0)