diff --git a/Sources/web3swift/Transaction/EthereumTransaction.swift b/Sources/web3swift/Transaction/EthereumTransaction.swift index 070e8fbb0..3c90172d4 100755 --- a/Sources/web3swift/Transaction/EthereumTransaction.swift +++ b/Sources/web3swift/Transaction/EthereumTransaction.swift @@ -445,4 +445,14 @@ extension EthereumTransaction { return self.envelope.encode(for: .transaction) } + @available(*, deprecated, message: "use Decodable instead") + public static func fromJSON(_ json: [String: Any]) -> EthereumTransaction? { + do { + let jsonData: Data = try JSONSerialization.data(withJSONObject: json, options: []) + return try JSONDecoder().decode(EthereumTransaction.self, from: jsonData) + } catch { + return nil + } + } + } diff --git a/Sources/web3swift/Web3/Web3+Options.swift b/Sources/web3swift/Web3/Web3+Options.swift index 3de9c4fc2..dac0b7d19 100755 --- a/Sources/web3swift/Web3/Web3+Options.swift +++ b/Sources/web3swift/Web3/Web3+Options.swift @@ -280,3 +280,16 @@ extension TransactionOptions: Decodable { } } } + +extension TransactionOptions { + @available(*, deprecated, message: "use Decodable instead") + public static func fromJSON(_ json: [String: Any]) -> TransactionOptions? { + do { + let jsonData: Data = try JSONSerialization.data(withJSONObject: json, options: []) + return try JSONDecoder().decode(TransactionOptions.self, from: jsonData) + } catch { + return nil + } + } + +}