diff --git a/Sources/MagicSDK/Core/Magic.swift b/Sources/MagicSDK/Core/Magic.swift index 90a7421..e563c90 100644 --- a/Sources/MagicSDK/Core/Magic.swift +++ b/Sources/MagicSDK/Core/Magic.swift @@ -30,7 +30,7 @@ public class Magic: NSObject { /// - apiKey: Your client ID. From https://dashboard.Magic.com /// - ethNetwork: Network setting public convenience init(apiKey: String, network: EthNetwork, locale: String = Locale.current.identifier) { - self.init(urlBuilder: URLBuilder(apiKey: apiKey, network: EthNetworkConfiguration(network: network), locale: locale)) + self.init(urlBuilder: URLBuilder(apiKey: apiKey, network: network, locale: locale)) } public convenience init(apiKey: String, customNode: CustomNodeConfiguration, locale: String = Locale.current.identifier) { @@ -38,7 +38,7 @@ public class Magic: NSObject { } public convenience init(apiKey: String, locale: String = Locale.current.identifier) { - self.init(urlBuilder: URLBuilder(apiKey: apiKey, network: EthNetworkConfiguration(network: apiKey.contains("live") ? EthNetwork.mainnet: EthNetwork.rinkeby), locale: locale)) + self.init(urlBuilder: URLBuilder(apiKey: apiKey, network: EthNetwork.mainnet, locale: locale)) } private init(urlBuilder: URLBuilder) { diff --git a/Sources/MagicSDK/Core/Relayer/URLBuilder.swift b/Sources/MagicSDK/Core/Relayer/URLBuilder.swift index 16c5f3a..c738c54 100644 --- a/Sources/MagicSDK/Core/Relayer/URLBuilder.swift +++ b/Sources/MagicSDK/Core/Relayer/URLBuilder.swift @@ -27,7 +27,7 @@ public struct URLBuilder { self.init(data: data, host: URLBuilder.host, apiKey: apiKey) } - init(apiKey: String, network: EthNetworkConfiguration, locale: String) { + init(apiKey: String, network: EthNetwork, locale: String) { let options = EthNetworkOptions(apiKey: apiKey, network: network, locale: locale) let data = try! JSONEncoder().encode(options) self.init(data: data, host: URLBuilder.host, apiKey: apiKey) @@ -50,11 +50,11 @@ public struct URLBuilder { let API_KEY: String let host = URLBuilder.host let sdk = "magic-sdk-ios" - let ETH_NETWORK: EthNetworkConfiguration + let ETH_NETWORK: String let locale: String let bundleId = Bundle.main.bundleIdentifier - init(apiKey: String, network: EthNetworkConfiguration, locale: String) { - self.ETH_NETWORK = network + init(apiKey: String, network: EthNetwork, locale: String) { + self.ETH_NETWORK = network.rawValue self.API_KEY = apiKey self.locale = locale } @@ -84,11 +84,3 @@ public struct CustomNodeConfiguration: Encodable { self.chainId = chainId } } - -internal struct EthNetworkConfiguration: Encodable { - let network: String - - init (network: EthNetwork) { - self.network = network.rawValue - } -} diff --git a/Sources/MagicSDK/Modules/Web3/Web3Extension.swift b/Sources/MagicSDK/Modules/Web3/Web3Extension.swift index ec8c82c..c1bee2a 100644 --- a/Sources/MagicSDK/Modules/Web3/Web3Extension.swift +++ b/Sources/MagicSDK/Modules/Web3/Web3Extension.swift @@ -12,7 +12,7 @@ import PromiseKit // MARK: - web3 extension with closure public extension Web3.Eth { - + func getCoinbase(response: @escaping Web3.Web3ResponseCompletion) { let req = BasicRPCRequest( id: properties.rpcId, @@ -22,7 +22,7 @@ public extension Web3.Eth { ) properties.provider.send(request: req, response: response) } - + func sign(from: EthereumAddress, message: EthereumData, response: @escaping Web3.Web3ResponseCompletion) { let req = RPCRequest( id: properties.rpcId, @@ -32,7 +32,7 @@ public extension Web3.Eth { ) properties.provider.send(request: req, response: response) } - + func signTypedDataV1( data: [EIP712TypedDataLegacyFields], account: EthereumAddress, @@ -48,7 +48,7 @@ public extension Web3.Eth { ) properties.provider.send(request: req, response: response) } - + func signTypedDataV3( account: EthereumAddress, data: EIP712TypedData, @@ -69,26 +69,26 @@ public extension Web3.Eth { // MARK: - web3 extension Promises /// public extension Web3.Eth { - + func getCoinbase() -> Promise { return Promise { resolver in getCoinbase(response: promiseResolver(resolver)) } } - + func sign(from: EthereumAddress, message: EthereumData) -> Promise { return Promise { resolver in sign(from: from, message: message, response: promiseResolver(resolver)) } } - + func signTypedDataLegacy( account: EthereumAddress, data: [EIP712TypedDataLegacyFields]) -> Promise { return Promise { resolver in signTypedDataV1(data: data, account: account, response: promiseResolver(resolver)) } } - + func signTypedData( account: EthereumAddress, data: EIP712TypedData) -> Promise { return Promise { resolver in @@ -98,7 +98,7 @@ public extension Web3.Eth { } public extension RPCRequest { - + init(method: String, params: Params) { self = RPCRequest(id: generateRandomId(), jsonrpc: "2.0", method: method, params: params) } @@ -109,7 +109,5 @@ public extension RPCRequest { /// Note: Conforms to Hashable so that we can use these as a Dictionary key public enum EthNetwork: String { case mainnet - case kovan - case rinkeby - case ropsten + case goerli }