Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Network] #364: Change relay methods prefix from "iridium" to "irn" #402

Merged
merged 3 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/WalletConnectPairing/Types/WCPairing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public struct WCPairing: SequenceObject {

public init(topic: String) {
self.topic = topic
self.relay = RelayProtocolOptions(protocol: "iridium", data: nil)
self.relay = RelayProtocolOptions(protocol: "irn", data: nil)
self.active = false
self.expiryDate = Self.dateInitializer().advanced(by: Self.timeToLiveInactive)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ protocol ClientIdStoring {
}

struct ClientIdStorage: ClientIdStoring {
private let key = "com.walletconnect.iridium.client_id"
private let key = "com.walletconnect.irn.client_id"
private let keychain: KeychainStorageProtocol

init(keychain: KeychainStorageProtocol) {
Expand Down
4 changes: 0 additions & 4 deletions Sources/WalletConnectRelay/RPC/RelayRPC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ extension RelayRPC where Parameters: Codable {
return WalletConnectRPCID()
}

func wrapToIridium() -> PrefixDecorator<Self> {
return PrefixDecorator(rpcMethod: self, prefix: "iridium")
}

func wrapToIRN() -> PrefixDecorator<Self> {
return PrefixDecorator(rpcMethod: self, prefix: "irn")
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/WalletConnectRelay/RelayClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public final class RelayClient {
/// Completes when networking client sends a request, error if it fails on client side
public func publish(topic: String, payload: String, tag: Int, prompt: Bool = false) async throws {
let request = Publish(params: .init(topic: topic, message: payload, ttl: defaultTtl, prompt: prompt, tag: tag))
.wrapToIridium()
.wrapToIRN()
.asRPCRequest()
let message = try request.asJSONEncodedString()
logger.debug("Publishing payload on topic: \(topic)")
Expand All @@ -128,7 +128,7 @@ public final class RelayClient {
) {
let rpc = Publish(params: .init(topic: topic, message: payload, ttl: defaultTtl, prompt: prompt, tag: tag))
let request = rpc
.wrapToIridium()
.wrapToIRN()
.asRPCRequest()
let message = try! request.asJSONEncodedString()
logger.debug("Publishing Payload on Topic: \(topic)")
Expand All @@ -153,7 +153,7 @@ public final class RelayClient {
logger.debug("Relay: Subscribing to topic: \(topic)")
let rpc = Subscribe(params: .init(topic: topic))
let request = rpc
.wrapToIridium()
.wrapToIRN()
.asRPCRequest()
let message = try! request.asJSONEncodedString()
var cancellable: AnyCancellable?
Expand Down Expand Up @@ -195,7 +195,7 @@ public final class RelayClient {
logger.debug("Relay: Unsubscribing from topic: \(topic)")
let rpc = Unsubscribe(params: .init(id: subscriptionId, topic: topic))
let request = rpc
.wrapToIridium()
.wrapToIRN()
.asRPCRequest()
let message = try! request.asJSONEncodedString()
rpcHistory.deleteAll(forTopic: topic)
Expand Down
4 changes: 2 additions & 2 deletions Tests/RelayerTests/AuthTests/ClientIdStorageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ final class ClientIdStorageTests: XCTestCase {
let keychain = KeychainStorageMock()
let storage = ClientIdStorage(keychain: keychain)

XCTAssertThrowsError(try keychain.read(key: "com.walletconnect.iridium.client_id") as SigningPrivateKey)
XCTAssertThrowsError(try keychain.read(key: "com.walletconnect.irn.client_id") as SigningPrivateKey)

let saved = try storage.getOrCreateKeyPair()
XCTAssertEqual(saved, try keychain.read(key: "com.walletconnect.iridium.client_id"))
XCTAssertEqual(saved, try keychain.read(key: "com.walletconnect.irn.client_id"))

let restored = try storage.getOrCreateKeyPair()
XCTAssertEqual(saved, restored)
Expand Down
2 changes: 1 addition & 1 deletion Tests/WalletConnectSignTests/Stub/Stubs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ extension WCRequestSubscriptionPayload {

extension SessionProposal {
static func stub(proposerPubKey: String = "") -> SessionProposal {
let relayOptions = RelayProtocolOptions(protocol: "iridium", data: nil)
let relayOptions = RelayProtocolOptions(protocol: "irn", data: nil)
return SessionType.ProposeParams(
relays: [relayOptions],
proposer: Participant(publicKey: proposerPubKey, metadata: AppMetadata.stub()),
Expand Down
2 changes: 1 addition & 1 deletion Tests/WalletConnectSignTests/WCRelayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private let testPayload =
{
"id":1630300527198334,
"jsonrpc":"2.0",
"method":"iridium_subscription",
"method":"irn_subscription",
"params":{
"id":"0847f4e1dd19cf03a43dc7525f39896b630e9da33e4683c8efbc92ea671b5e07",
"data":{
Expand Down
6 changes: 3 additions & 3 deletions Tests/WalletConnectSignTests/WalletConnectURITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import XCTest

private let stubTopic = "8097df5f14871126866252c1b7479a14aefb980188fc35ec97d130d24bd887c8"
private let stubSymKey = "587d5484ce2a2a6ee3ba1962fdd7e8588e06200c46823bd18fbd67def96ad303"
private let stubProtocol = "iridium"
private let stubProtocol = "irn"

private let stubURI = "wc:7f6e504bfad60b485450578e05678ed3e8e8c4751d3c6160be17160d63ec90f9@2?symKey=587d5484ce2a2a6ee3ba1962fdd7e8588e06200c46823bd18fbd67def96ad303&relay-protocol=iridium"
private let stubURI = "wc:7f6e504bfad60b485450578e05678ed3e8e8c4751d3c6160be17160d63ec90f9@2?symKey=587d5484ce2a2a6ee3ba1962fdd7e8588e06200c46823bd18fbd67def96ad303&relay-protocol=irn"

final class WalletConnectURITests: XCTestCase {

func testInitURIToString() {
let inputURI = WalletConnectURI(
topic: "8097df5f14871126866252c1b7479a14aefb980188fc35ec97d130d24bd887c8",
symKey: "19c5ecc857963976fabb98ed6a3e0a6ab6b0d65c018b6e25fbdcd3a164def868",
relay: RelayProtocolOptions(protocol: "iridium", data: nil))
relay: RelayProtocolOptions(protocol: "irn", data: nil))
let uriString = inputURI.absoluteString
let outputURI = WalletConnectURI(string: uriString)
XCTAssertEqual(inputURI, outputURI)
Expand Down