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
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@
141141
"kind" : "remoteSourceControl",
142142
"location" : "https://github.com/soramitsu/shared-features-spm.git",
143143
"state" : {
144-
"branch" : "FW-new-ecosystem",
145-
"revision" : "53e0a4bbea854ab32e97392365c3e523b9a0dc66"
144+
"revision" : "b3e2bf1bc380d0e046b603921cbb63dcefb920cf"
146145
}
147146
},
148147
{
@@ -177,8 +176,8 @@
177176
"kind" : "remoteSourceControl",
178177
"location" : "https://github.com/apple/swift-nio.git",
179178
"state" : {
180-
"revision" : "ba72f31e11275fc5bf060c966cf6c1f36842a291",
181-
"version" : "2.79.0"
179+
"revision" : "c51907a839e63ebf0ba2076bba73dd96436bd1b9",
180+
"version" : "2.81.0"
182181
}
183182
},
184183
{
@@ -204,17 +203,17 @@
204203
"kind" : "remoteSourceControl",
205204
"location" : "https://github.com/apple/swift-nio-ssl.git",
206205
"state" : {
207-
"revision" : "c7e95421334b1068490b5d41314a50e70bab23d1",
208-
"version" : "2.29.0"
206+
"revision" : "0cc3528ff48129d64ab9cab0b1cd621634edfc6b",
207+
"version" : "2.29.3"
209208
}
210209
},
211210
{
212211
"identity" : "swift-nio-transport-services",
213212
"kind" : "remoteSourceControl",
214213
"location" : "https://github.com/apple/swift-nio-transport-services.git",
215214
"state" : {
216-
"revision" : "bbd5e63cf949b7db0c9edaf7a21e141c52afe214",
217-
"version" : "1.23.0"
215+
"revision" : "3c394067c08d1225ba8442e9cffb520ded417b64",
216+
"version" : "1.23.1"
218217
}
219218
},
220219
{
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) }

fearless/Common/PurchaseProvider/PurchaseProviderProtocol.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ protocol PurchaseProviderProtocol {
1313
func with(logoUrl: URL) -> Self
1414
func with(colorCode: String) -> Self
1515
func with(callbackUrl: URL) -> Self
16+
func with(chainName: String) -> Self
1617
func buildPurchaseActions(asset: AssetModel, address: String) -> [PurchaseAction]
1718
}
1819

@@ -32,4 +33,8 @@ extension PurchaseProviderProtocol {
3233
func with(callbackUrl _: URL) -> Self {
3334
self
3435
}
36+
37+
func with(chainName _: String) -> Self {
38+
self
39+
}
3540
}

fearless/Common/Services/ChainRegistry/ChainSyncService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum ChainSyncServiceError: Error {
1414
}
1515

1616
final class ChainSyncService {
17-
static let fetchLocalData = false
17+
static let fetchLocalData = true
1818

1919
struct SyncChanges {
2020
let newOrUpdatedItems: [ChainModel]

fearless/Common/Storage/EntityToModel/ChainModelMapper.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ final class ChainModelMapper {
9494
}
9595
return createPriceData(from: priceData)
9696
}
97+
print("CoinbaseURL debug: createAsset: coinbaseUrl: \(entity.coinbaseUrl)")
9798
return AssetModel(
9899
id: id,
99100
name: name,
@@ -110,7 +111,8 @@ final class ChainModelMapper {
110111
assetType: assetType,
111112
priceProvider: priceProvider,
112113
coingeckoPriceId: entity.priceId,
113-
priceData: priceDatas
114+
priceData: priceDatas,
115+
coinbaseUrl: entity.coinbaseUrl
114116
)
115117
}
116118

@@ -150,6 +152,7 @@ final class ChainModelMapper {
150152
assetEntity.isUtility = assetModel.isUtility
151153
assetEntity.isNative = assetModel.isNative
152154
assetEntity.staking = assetModel.staking?.rawValue
155+
assetEntity.coinbaseUrl = assetModel.coinbaseUrl
153156

154157
let priceProviderContext = CDPriceProvider(context: context)
155158
priceProviderContext.type = assetModel.priceProvider?.type.rawValue
@@ -186,6 +189,7 @@ final class ChainModelMapper {
186189
}
187190
}
188191
assetEntity.priceData = Set(priceData) as NSSet
192+
print("CoinbaseURL debug: updateEntityAsset: coinbaseUrl: \(assetEntity.coinbaseUrl)")
189193

190194
return assetEntity
191195
}

fearless/Common/Storage/Migration/SubstrateStorage/SubstrateStorageVersion.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ enum SubstrateStorageVersion: String, CaseIterable {
99
case version6 = "SubstrateDataModel_v6"
1010
case version7 = "SubstrateDataModel_v7"
1111
case version8 = "SubstrateDataModel_v8"
12+
case version9 = "SubstrateDataModel_v9"
1213

1314
static var current: SubstrateStorageVersion {
1415
guard let currentVersion = allCases.last else {
@@ -35,6 +36,8 @@ enum SubstrateStorageVersion: String, CaseIterable {
3536
case .version7:
3637
return .version8
3738
case .version8:
39+
return .version9
40+
case .version9:
3841
return nil
3942
}
4043
}

fearless/Common/Storage/SubstrateDataModel.xcdatamodeld/.xccurrentversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
<plist version="1.0">
44
<dict>
55
<key>_XCCurrentVersionName</key>
6-
<string>SubstrateDataModel_v8.xcdatamodel</string>
6+
<string>SubstrateDataModel_v9.xcdatamodel</string>
77
</dict>
88
</plist>

0 commit comments

Comments
 (0)