From 4c6a55374c301f11f5060b9ab1cb192593f2a328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Vants?= Date: Thu, 28 Jul 2022 20:12:03 -0300 Subject: [PATCH] Organize files and folders --- .../{RelayMethods.swift => RPC/Methods.swift} | 0 .../WalletConnectRelay/RPC/RPCMethod.swift | 5 ++++ .../{ => RPC}/RelayRPC.swift | 24 ++++--------------- .../RPC/WalletConnectRPCID.swift | 11 +++++++++ 4 files changed, 20 insertions(+), 20 deletions(-) rename Sources/WalletConnectRelay/{RelayMethods.swift => RPC/Methods.swift} (100%) create mode 100644 Sources/WalletConnectRelay/RPC/RPCMethod.swift rename Sources/WalletConnectRelay/{ => RPC}/RelayRPC.swift (61%) create mode 100644 Sources/WalletConnectRelay/RPC/WalletConnectRPCID.swift diff --git a/Sources/WalletConnectRelay/RelayMethods.swift b/Sources/WalletConnectRelay/RPC/Methods.swift similarity index 100% rename from Sources/WalletConnectRelay/RelayMethods.swift rename to Sources/WalletConnectRelay/RPC/Methods.swift diff --git a/Sources/WalletConnectRelay/RPC/RPCMethod.swift b/Sources/WalletConnectRelay/RPC/RPCMethod.swift new file mode 100644 index 000000000..1f104f7c7 --- /dev/null +++ b/Sources/WalletConnectRelay/RPC/RPCMethod.swift @@ -0,0 +1,5 @@ +protocol RPCMethod { + associatedtype Parameters + var method: String { get } + var params: Parameters { get } +} diff --git a/Sources/WalletConnectRelay/RelayRPC.swift b/Sources/WalletConnectRelay/RPC/RelayRPC.swift similarity index 61% rename from Sources/WalletConnectRelay/RelayRPC.swift rename to Sources/WalletConnectRelay/RPC/RelayRPC.swift index 45bbe6227..a8f3230a7 100644 --- a/Sources/WalletConnectRelay/RelayRPC.swift +++ b/Sources/WalletConnectRelay/RPC/RelayRPC.swift @@ -1,11 +1,5 @@ import JSONRPC -protocol RPCMethod { - associatedtype Parameters - var method: String { get } - var params: Parameters { get } -} - protocol RelayRPC: RPCMethod {} extension RelayRPC where Parameters: Codable { @@ -16,7 +10,10 @@ extension RelayRPC where Parameters: Codable { func wrapToIridium() -> PrefixDecorator { return PrefixDecorator(rpcMethod: self, prefix: "iridium") -// return PrefixDecorator.iridium(rpcMethod: self) + } + + func wrapToIRN() -> PrefixDecorator { + return PrefixDecorator(rpcMethod: self, prefix: "irn") } func asRPCRequest() -> RPCRequest { @@ -39,16 +36,3 @@ struct PrefixDecorator: RelayRPC where T: RelayRPC { rpcMethod.params } } - - -// TODO: Move -import Foundation - -struct WalletConnectRPCID: IdentifierGenerator { - - func next() -> RPCID { - let timestamp = Int64(Date().timeIntervalSince1970 * 1000) * 1000 - let random = Int64.random(in: 0..<1000) - return .right(Int(timestamp + random)) - } -} diff --git a/Sources/WalletConnectRelay/RPC/WalletConnectRPCID.swift b/Sources/WalletConnectRelay/RPC/WalletConnectRPCID.swift new file mode 100644 index 000000000..956b28868 --- /dev/null +++ b/Sources/WalletConnectRelay/RPC/WalletConnectRPCID.swift @@ -0,0 +1,11 @@ +import Foundation +import JSONRPC + +struct WalletConnectRPCID: IdentifierGenerator { + + func next() -> RPCID { + let timestamp = Int64(Date().timeIntervalSince1970 * 1000) * 1000 + let random = Int64.random(in: 0..<1000) + return .right(Int(timestamp + random)) + } +}