diff --git a/README.md b/README.md index a4e1ed0..5adc908 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ The Core SDK must be initialised before any of its classes are used. Upon initia For example, you initialise the SDK and retrieve a URL to buy crypto through Moonpay: ```swift -ImmutableX.initialize(base: .ropsten) +ImmutableX.initialize(base: .sandbox) let url = try await ImmutableX.shared.buyCryptoURL(signer: signer) ``` diff --git a/Sources/ImmutableXCore/Config/ImmutableXBase.swift b/Sources/ImmutableXCore/Config/ImmutableXBase.swift index ed3b85a..e1fa6f9 100644 --- a/Sources/ImmutableXCore/Config/ImmutableXBase.swift +++ b/Sources/ImmutableXCore/Config/ImmutableXBase.swift @@ -1,14 +1,17 @@ /// An enum for defining the environment the SDK will communicate with public enum ImmutableXBase { + /// Ethereum network case production - case ropsten + + /// The default test network (currently Goerli) + case sandbox internal var publicApiUrl: String { switch self { case .production: return "https://api.x.immutable.com" - case .ropsten: - return "https://api.ropsten.x.immutable.com" + case .sandbox: + return "https://api.sandbox.x.immutable.com" } } @@ -16,7 +19,7 @@ public enum ImmutableXBase { switch self { case .production: return "pk_live_lgGxv3WyWjnWff44ch4gmolN0953" - case .ropsten: + case .sandbox: return "pk_test_nGdsu1IBkjiFzmEvN8ddf4gM9GNy5Sgz" } } @@ -25,7 +28,7 @@ public enum ImmutableXBase { switch self { case .production: return "https://buy.moonpay.io" - case .ropsten: + case .sandbox: return "https://buy-staging.moonpay.io" } } diff --git a/Sources/ImmutableXCore/ImmutableX.swift b/Sources/ImmutableXCore/ImmutableX.swift index ea13782..1e50ca4 100644 --- a/Sources/ImmutableXCore/ImmutableX.swift +++ b/Sources/ImmutableXCore/ImmutableX.swift @@ -9,7 +9,7 @@ public struct ImmutableX { /// is accessed. public internal(set) static var shared: ImmutableX! - /// The environment the SDK will communicate with. Defaults to `.ropsten`. + /// The environment the SDK will communicate with. Defaults to `.sandbox`. public let base: ImmutableXBase /// Defines the level of logging for ImmutableX network calls. Defaults to `.none`. @@ -37,7 +37,7 @@ public struct ImmutableX { private let buyCryptoWorkflow: BuyCryptoWorkflow.Type /// Internal init method that includes dependencies. For the public facing API use ``initialize(base:logLevel:)`` instead. - internal init(base: ImmutableXBase = .ropsten, logLevel: ImmutableXHTTPLoggingLevel = .none, buyWorkflow: BuyWorkflow.Type = BuyWorkflow.self, sellWorkflow: SellWorkflow.Type = SellWorkflow.self, cancelOrderWorkflow: CancelOrderWorkflow.Type = CancelOrderWorkflow.self, transferWorkflow: TransferWorkflow.Type = TransferWorkflow.self, registerWorkflow: RegisterWorkflow.Type = RegisterWorkflow.self, buyCryptoWorkflow: BuyCryptoWorkflow.Type = BuyCryptoWorkflow.self) { + internal init(base: ImmutableXBase = .sandbox, logLevel: ImmutableXHTTPLoggingLevel = .none, buyWorkflow: BuyWorkflow.Type = BuyWorkflow.self, sellWorkflow: SellWorkflow.Type = SellWorkflow.self, cancelOrderWorkflow: CancelOrderWorkflow.Type = CancelOrderWorkflow.self, transferWorkflow: TransferWorkflow.Type = TransferWorkflow.self, registerWorkflow: RegisterWorkflow.Type = RegisterWorkflow.self, buyCryptoWorkflow: BuyCryptoWorkflow.Type = BuyCryptoWorkflow.self) { self.base = base self.logLevel = logLevel self.buyWorkflow = buyWorkflow @@ -49,7 +49,7 @@ public struct ImmutableX { } /// Initializes the SDK with the given ``base`` and ``logLevel`` by assigning a shared instance accessible via `ImmutableX.shared`. - public static func initialize(base: ImmutableXBase = .ropsten, logLevel: ImmutableXHTTPLoggingLevel = .none) { + public static func initialize(base: ImmutableXBase = .sandbox, logLevel: ImmutableXHTTPLoggingLevel = .none) { ImmutableX.shared = ImmutableX(base: base, logLevel: logLevel) } diff --git a/Tests/ImmutableXCoreTests/Config/ImmutableXBaseTests.swift b/Tests/ImmutableXCoreTests/Config/ImmutableXBaseTests.swift index 5890b9b..8f9480b 100644 --- a/Tests/ImmutableXCoreTests/Config/ImmutableXBaseTests.swift +++ b/Tests/ImmutableXCoreTests/Config/ImmutableXBaseTests.swift @@ -4,16 +4,16 @@ import XCTest final class ImmutableXBaseTests: XCTestCase { func testPublicApiUrl() async throws { XCTAssertEqual(ImmutableXBase.production.publicApiUrl, "https://api.x.immutable.com") - XCTAssertEqual(ImmutableXBase.ropsten.publicApiUrl, "https://api.ropsten.x.immutable.com") + XCTAssertEqual(ImmutableXBase.sandbox.publicApiUrl, "https://api.sandbox.x.immutable.com") } func testMoonpayApiKey() async throws { XCTAssertEqual(ImmutableXBase.production.moonpayApiKey, "pk_live_lgGxv3WyWjnWff44ch4gmolN0953") - XCTAssertEqual(ImmutableXBase.ropsten.moonpayApiKey, "pk_test_nGdsu1IBkjiFzmEvN8ddf4gM9GNy5Sgz") + XCTAssertEqual(ImmutableXBase.sandbox.moonpayApiKey, "pk_test_nGdsu1IBkjiFzmEvN8ddf4gM9GNy5Sgz") } func testBuyCryptoUrl() async throws { XCTAssertEqual(ImmutableXBase.production.buyCryptoUrl, "https://buy.moonpay.io") - XCTAssertEqual(ImmutableXBase.ropsten.buyCryptoUrl, "https://buy-staging.moonpay.io") + XCTAssertEqual(ImmutableXBase.sandbox.buyCryptoUrl, "https://buy-staging.moonpay.io") } } diff --git a/Tests/ImmutableXCoreTests/ImmutableXTests.swift b/Tests/ImmutableXCoreTests/ImmutableXTests.swift index 0c3ff4b..cc8f90e 100644 --- a/Tests/ImmutableXCoreTests/ImmutableXTests.swift +++ b/Tests/ImmutableXCoreTests/ImmutableXTests.swift @@ -51,8 +51,8 @@ final class ImmutableXTests: XCTestCase { } func testInitialize() { - ImmutableX.initialize(base: .ropsten, logLevel: .calls(including: [.requestBody])) - XCTAssertEqual(ImmutableX.shared.base, .ropsten) + ImmutableX.initialize(base: .sandbox, logLevel: .calls(including: [.requestBody])) + XCTAssertEqual(ImmutableX.shared.base, .sandbox) if case .calls(including: [.requestBody]) = ImmutableX.shared.logLevel { // success diff --git a/Tests/ImmutableXCoreTests/Mocks/Stubs/Models.swift b/Tests/ImmutableXCoreTests/Mocks/Stubs/Models.swift index a6e9c8a..7008847 100644 --- a/Tests/ImmutableXCoreTests/Mocks/Stubs/Models.swift +++ b/Tests/ImmutableXCoreTests/Mocks/Stubs/Models.swift @@ -1,7 +1,7 @@ import Foundation @testable import ImmutableXCore -let coreStub1 = ImmutableX(base: .ropsten, buyWorkflow: BuyWorkflowMock.self, sellWorkflow: SellWorkflowMock.self, cancelOrderWorkflow: CancelOrderWorkflowMock.self, transferWorkflow: TransferWorkflowMock.self, registerWorkflow: RegisterWorkflowMock.self) +let coreStub1 = ImmutableX(base: .sandbox, buyWorkflow: BuyWorkflowMock.self, sellWorkflow: SellWorkflowMock.self, cancelOrderWorkflow: CancelOrderWorkflowMock.self, transferWorkflow: TransferWorkflowMock.self, registerWorkflow: RegisterWorkflowMock.self) let tokenETHStub1 = Token( data: TokenData( diff --git a/Tests/ImmutableXCoreTests/Workflows/BuyCryptoWorkflowTests.swift b/Tests/ImmutableXCoreTests/Workflows/BuyCryptoWorkflowTests.swift index 20b6e34..a5c980e 100644 --- a/Tests/ImmutableXCoreTests/Workflows/BuyCryptoWorkflowTests.swift +++ b/Tests/ImmutableXCoreTests/Workflows/BuyCryptoWorkflowTests.swift @@ -36,7 +36,7 @@ final class BuyCryptoWorkflowTests: XCTestCase { let response = try await BuyCryptoWorkflow.buyCryptoURL( colorCodeHex: "#000000", signer: SignerMock(), - base: .ropsten, + base: .sandbox, moonpayAPI: moonpayAPI, exchangesAPI: exchangesAPI, usersAPI: usersAPI @@ -54,7 +54,7 @@ final class BuyCryptoWorkflowTests: XCTestCase { _ = try await BuyCryptoWorkflow.buyCryptoURL( colorCodeHex: "#000000", signer: SignerMock(), - base: .ropsten, + base: .sandbox, moonpayAPI: self.moonpayAPI, exchangesAPI: self.exchangesAPI, usersAPI: self.usersAPI @@ -71,7 +71,7 @@ final class BuyCryptoWorkflowTests: XCTestCase { _ = try await BuyCryptoWorkflow.buyCryptoURL( colorCodeHex: "#000000", signer: SignerMock(), - base: .ropsten, + base: .sandbox, moonpayAPI: self.moonpayAPI, exchangesAPI: self.exchangesAPI, usersAPI: self.usersAPI @@ -88,7 +88,7 @@ final class BuyCryptoWorkflowTests: XCTestCase { _ = try await BuyCryptoWorkflow.buyCryptoURL( colorCodeHex: "#000000", signer: SignerMock(), - base: .ropsten, + base: .sandbox, moonpayAPI: self.moonpayAPI, exchangesAPI: self.exchangesAPI, usersAPI: self.usersAPI @@ -105,7 +105,7 @@ final class BuyCryptoWorkflowTests: XCTestCase { _ = try await BuyCryptoWorkflow.buyCryptoURL( colorCodeHex: "#000000", signer: SignerMock(), - base: .ropsten, + base: .sandbox, moonpayAPI: self.moonpayAPI, exchangesAPI: self.exchangesAPI, usersAPI: self.usersAPI diff --git a/openapi.json b/openapi.json index 59361f0..3bd5a80 100644 --- a/openapi.json +++ b/openapi.json @@ -11,7 +11,7 @@ }, "version": "0.1" }, - "host": "api.ropsten.x.immutable.com", + "host": "api.sandbox.x.immutable.com", "basePath": "/", "paths": { "/v1/assets": { @@ -5369,4 +5369,4 @@ "x-go-gen-location": "models" } } -} \ No newline at end of file +}