From 08057d8ad33997f453c7d5c7a351347f702bc6c6 Mon Sep 17 00:00:00 2001 From: Josh Pyles Date: Sun, 13 May 2018 10:11:50 -0700 Subject: [PATCH] Expose properties and RPCRequest initializer for extensions This fixes some issues with extending Web3.Eth to add additional methods. Eth.properties is not public and the only way to get to the current provider. Additionally the auto-generated initializer for RPCRequest struct was not accessible outside of the Web3 module. --- Web3/Classes/Core/Json/RPCRequest.swift | 7 +++++++ Web3/Classes/Core/Web3/Web3.swift | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Web3/Classes/Core/Json/RPCRequest.swift b/Web3/Classes/Core/Json/RPCRequest.swift index 7cfdd1e1..79f5ec43 100644 --- a/Web3/Classes/Core/Json/RPCRequest.swift +++ b/Web3/Classes/Core/Json/RPCRequest.swift @@ -21,6 +21,13 @@ public struct RPCRequest: Codable { /// The jsonrpc parameters public let params: Params + + public init(id: Int, jsonrpc: String, method: String, params: Params) { + self.id = id + self.jsonrpc = jsonrpc + self.method = method + self.params = params + } } public typealias BasicRPCRequest = RPCRequest diff --git a/Web3/Classes/Core/Web3/Web3.swift b/Web3/Classes/Core/Web3/Web3.swift index 509cae4c..cd0ad4e1 100644 --- a/Web3/Classes/Core/Web3/Web3.swift +++ b/Web3/Classes/Core/Web3/Web3.swift @@ -75,7 +75,7 @@ public struct Web3 { public struct Net { - let properties: Properties + public let properties: Properties /** * Returns the current network id (chain id). @@ -108,7 +108,7 @@ public struct Web3 { public struct Eth { - let properties: Properties + public let properties: Properties public func protocolVersion(response: @escaping Web3ResponseCompletion) { let req = BasicRPCRequest(