-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c6ff63
commit 4e13004
Showing
20 changed files
with
487 additions
and
114 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
Pod::Spec.new do |spec| | ||
spec.name = 'Ramp' | ||
spec.version = '2.0.0' | ||
spec.version = '3.0.0' | ||
spec.license = 'proprietary' | ||
spec.summary = 'Ramp SDK for iOS' | ||
spec.homepage = 'https://ramp.network/' | ||
spec.authors = { 'Ramp Network' => '[email protected]' } | ||
spec.source = { :git => 'https://github.com/RampNetwork/ramp-sdk-ios', :tag => spec.version } | ||
spec.source = { :git => 'https://github.com/RampNetwork/ramp-sdk-ios.git', :tag => spec.version } | ||
spec.ios.deployment_target = '11.0' | ||
spec.source_files = 'Sources/Ramp/*.swift' | ||
spec.resource_bundles = { 'Ramp' => 'Sources/Ramp/Resources/*' } | ||
spec.dependency 'Passbase', '~> 2.8' | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,84 @@ | ||
import Foundation | ||
|
||
/// Parameters description and usage can be found at [Ramp Configuratoin Documentation](https://docs.ramp.network/configuration) | ||
public struct Configuration { | ||
public var swapAsset: String? = nil | ||
public var swapAmount: String? = nil | ||
public var fiatCurrency: String? = nil | ||
public var fiatValue: String? = nil | ||
public var userAddress: String? = nil | ||
public var hostLogoUrl: String? = nil | ||
public var hostAppName: String? = nil | ||
public var userEmailAddress: String? = nil | ||
public var selectedCountryCode: String? = nil | ||
public var defaultAsset: String? = nil | ||
public var url: String? = nil | ||
public var webhookStatusUrl: String? = nil | ||
public var finalUrl: String? = nil | ||
public var containerNode: String? = nil | ||
public var hostApiKey: String? = nil | ||
public var deepLinkScheme: String? = nil | ||
public struct Configuration: Decodable { | ||
|
||
/// main URL | ||
public var url: String = Constants.defaultUrl | ||
|
||
/// query params | ||
public var containerNode: String? | ||
public var deepLinkScheme: String? | ||
public var defaultAsset: String? | ||
public var defaultFlow: Flow? | ||
public var enabledFlows: Set<Flow>? | ||
public var fiatCurrency: String? | ||
public var fiatValue: String? | ||
public var finalUrl: String? | ||
public var hostApiKey: String? | ||
public var hostAppName: String? | ||
public var hostLogoUrl: String? | ||
public var offrampAsset: String? | ||
public var offrampWebhookV3Url: String? | ||
public var selectedCountryCode: String? | ||
public var swapAmount: String? | ||
public var swapAsset: String? | ||
public var userAddress: String? | ||
public var userEmailAddress: String? | ||
public var useSendCryptoCallback: Bool? | ||
public var variant: String { Constants.sdkVariant } | ||
public var webhookStatusUrl: String? | ||
|
||
public init() {} | ||
} | ||
|
||
extension Configuration { | ||
public enum Error: Swift.Error { case invalidUrl, invalidParameters } | ||
|
||
func buildUrl() throws -> URL { | ||
let url = url ?? Constants.defaultUrl | ||
guard var urlComponents = URLComponents(string: url) else { throw Error.invalidUrl } | ||
urlComponents.path = "/" | ||
|
||
urlComponents.appendQueryItem(name: "containerNode", value: containerNode) | ||
urlComponents.appendQueryItem(name: "deepLinkScheme", value: deepLinkScheme) | ||
urlComponents.appendQueryItem(name: "defaultAsset", value: defaultAsset) | ||
urlComponents.appendQueryItem(name: "defaultFlow", value: defaultFlow) | ||
|
||
if let enabledFlows { | ||
let value = enabledFlows.map(\.rawValue).joined(separator: ",") | ||
urlComponents.appendQueryItem(name: "enabledFlows", value: value) | ||
} | ||
|
||
urlComponents.appendQueryItem(name: "swapAsset", value: swapAsset) | ||
urlComponents.appendQueryItem(name: "swapAmount", value: swapAmount) | ||
urlComponents.appendQueryItem(name: "fiatCurrency", value: fiatCurrency) | ||
urlComponents.appendQueryItem(name: "fiatValue", value: fiatValue) | ||
urlComponents.appendQueryItem(name: "userAddress", value: userAddress) | ||
urlComponents.appendQueryItem(name: "hostLogoUrl", value: hostLogoUrl) | ||
urlComponents.appendQueryItem(name: "finalUrl", value: finalUrl) | ||
urlComponents.appendQueryItem(name: "hostApiKey", value: hostApiKey) | ||
urlComponents.appendQueryItem(name: "hostAppName", value: hostAppName) | ||
urlComponents.appendQueryItem(name: "userEmailAddress", value: userEmailAddress) | ||
urlComponents.appendQueryItem(name: "hostLogoUrl", value: hostLogoUrl) | ||
urlComponents.appendQueryItem(name: "offrampAsset", value: offrampAsset) | ||
urlComponents.appendQueryItem(name: "offrampWebhookV3Url", value: offrampWebhookV3Url) | ||
urlComponents.appendQueryItem(name: "selectedCountryCode", value: selectedCountryCode) | ||
urlComponents.appendQueryItem(name: "defaultAsset", value: defaultAsset) | ||
urlComponents.appendQueryItem(name: "swapAmount", value: swapAmount) | ||
urlComponents.appendQueryItem(name: "swapAsset", value: swapAsset) | ||
urlComponents.appendQueryItem(name: "userAddress", value: userAddress) | ||
urlComponents.appendQueryItem(name: "userEmailAddress", value: userEmailAddress) | ||
|
||
if useSendCryptoCallback == true { | ||
urlComponents.appendQueryItem(name: "useSendCryptoCallbackVersion", | ||
value: Constants.sendCryptoVersion) | ||
} | ||
|
||
urlComponents.appendQueryItem(name: "variant", value: variant) | ||
urlComponents.appendQueryItem(name: "webhookStatusUrl", value: webhookStatusUrl) | ||
urlComponents.appendQueryItem(name: "finalUrl", value: finalUrl) | ||
urlComponents.appendQueryItem(name: "variant", value: Constants.sdkVariant) | ||
urlComponents.appendQueryItem(name: "containerNode", value: containerNode) | ||
urlComponents.appendQueryItem(name: "hostApiKey", value: hostApiKey) | ||
urlComponents.appendQueryItem(name: "deepLinkScheme", value: deepLinkScheme) | ||
|
||
if let url = urlComponents.url { return url } | ||
else { throw Error.invalidParameters } | ||
} | ||
} | ||
|
||
public extension Configuration { | ||
enum Flow: String, CaseIterable, Decodable { | ||
case onramp = "ONRAMP" | ||
case offramp = "OFFRAMP" | ||
} | ||
|
||
enum Error: Swift.Error { case invalidUrl, invalidParameters } | ||
} |
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 |
---|---|---|
@@ -1,17 +1,12 @@ | ||
import Foundation | ||
import SwiftUI | ||
|
||
struct Constants { | ||
static let sdkVariant: String = "sdk-mobile" | ||
static let defaultUrl: String = "https://buy.ramp.network" | ||
static let scriptMessageHandlerName: String = "RampInstantMobile" | ||
static let sendCryptoVersion: Int = 1 | ||
|
||
static let rampColor: UIColor = UIColor(red: 19/255.0, green: 159/255.0, blue: 106/255.0, alpha: 1) | ||
|
||
static let closeAlertTitle = "Do you really want to close Ramp?" | ||
static let closeAlertMessage = "You will loose all progress and will have to start over" | ||
static let closeAlertYesAction = "Yes, close" | ||
static let closeAlertNoAction = "No, continue" | ||
|
||
static func postMessageScript(_ message: String) -> String { "window.postMessage(\(message));" } | ||
static func postMessageScript(_ message: String) -> String { | ||
return "window.postMessage(" + message + ");" | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import Foundation | ||
|
||
struct Localizable { | ||
static var closeAlertTitle: String { NSLocalizedString("Do you really want to close Ramp?", comment: "Alert title for closing Ramp") } | ||
static var closeAlertMessage: String { NSLocalizedString("You will loose all progress and will have to start over", comment: "Alert message for closing Ramp") } | ||
static var yes: String { NSLocalizedString("Yes", comment: "Yes") } | ||
static var no: String { NSLocalizedString("No", comment: "No") } | ||
} |
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,10 @@ | ||
import Foundation | ||
|
||
public struct OfframpAssetInfo: Codable { | ||
public let address: String? | ||
public let chain: String | ||
public let decimals: Int | ||
public let name: String | ||
public let symbol: String | ||
public let type: String | ||
} |
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,18 @@ | ||
import Foundation | ||
|
||
public struct OfframpSale: Codable { | ||
public let createdAt: String | ||
public let crypto: Crypto | ||
public let fiat: Fiat | ||
public let id: UUID | ||
|
||
public struct Crypto: Codable { | ||
public let amount: String | ||
public let assetInfo: OfframpAssetInfo | ||
} | ||
|
||
public struct Fiat: Codable { | ||
public let amount: Double | ||
public let currencySymbol: String | ||
} | ||
} |
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
Oops, something went wrong.