Skip to content

Commit

Permalink
fix compatibility issue
Browse files Browse the repository at this point in the history
  • Loading branch information
llbartekll committed Jan 23, 2024
1 parent 3e9b7fc commit bb2f36d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Sources/WalletConnectSign/Engine/Common/SessionEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final class SessionEngine {
guard session.hasPermission(forMethod: request.method, onChain: request.chainId) else {
throw WalletConnectError.invalidPermissions
}
let chainRequest = SessionType.RequestParams.Request(method: request.method, params: request.params, expiry: request.expiryTimestamp)
let chainRequest = SessionType.RequestParams.Request(method: request.method, params: request.params, expiryTimestamp: request.expiryTimestamp)
let sessionRequestParams = SessionType.RequestParams(request: chainRequest, chainId: request.chainId)
let ttl = try request.calculateTtl()
let protocolMethod = SessionRequestProtocolMethod(ttl: ttl)
Expand Down Expand Up @@ -229,7 +229,7 @@ private extension SessionEngine {
method: payload.request.request.method,
params: payload.request.request.params,
chainId: payload.request.chainId,
expiry: payload.request.request.expiry
expiryTimestamp: payload.request.request.expiryTimestamp
)
guard let session = sessionStore.getSession(forTopic: topic) else {
return respondError(payload: payload, reason: .noSessionForTopic, protocolMethod: protocolMethod)
Expand Down
8 changes: 4 additions & 4 deletions Sources/WalletConnectSign/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public struct Request: Codable, Equatable {
}

let calculatedExpiry = UInt64(Date().timeIntervalSince1970) + UInt64(ttl)
self.init(id: RPCID(JsonRpcID.generate()), topic: topic, method: method, params: params, chainId: chainId, expiry: calculatedExpiry)
self.init(id: RPCID(JsonRpcID.generate()), topic: topic, method: method, params: params, chainId: chainId, expiryTimestamp: calculatedExpiry)
}

init<C>(id: RPCID, topic: String, method: String, params: C, chainId: Blockchain, ttl: TimeInterval = 300) throws where C: Codable {
Expand All @@ -39,16 +39,16 @@ public struct Request: Codable, Equatable {
}

let calculatedExpiry = UInt64(Date().timeIntervalSince1970) + UInt64(ttl)
self.init(id: id, topic: topic, method: method, params: AnyCodable(params), chainId: chainId, expiry: calculatedExpiry)
self.init(id: id, topic: topic, method: method, params: AnyCodable(params), chainId: chainId, expiryTimestamp: calculatedExpiry)
}

internal init(id: RPCID, topic: String, method: String, params: AnyCodable, chainId: Blockchain, expiry: UInt64?) {
internal init(id: RPCID, topic: String, method: String, params: AnyCodable, chainId: Blockchain, expiryTimestamp: UInt64?) {
self.id = id
self.topic = topic
self.method = method
self.params = params
self.chainId = chainId
self.expiryTimestamp = expiry
self.expiryTimestamp = expiryTimestamp
}

func isExpired(currentDate: Date = Date()) -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectSign/Services/HistoryService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private extension HistoryService {
method: request.request.method,
params: request.request.params,
chainId: request.chainId,
expiry: request.request.expiry
expiryTimestamp: request.request.expiryTimestamp
)

return (mappedRequest, record.id)
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectSign/SignDecryptionService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class SignDecryptionService {
method: request.request.method,
params: request.request.params,
chainId: request.chainId,
expiry: request.request.expiry
expiryTimestamp: request.request.expiryTimestamp
)

return request
Expand Down
2 changes: 1 addition & 1 deletion Sources/WalletConnectSign/Types/Session/SessionType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal enum SessionType {
struct Request: Codable, Equatable {
let method: String
let params: AnyCodable
let expiry: UInt64?
let expiryTimestamp: UInt64?
}
}

Expand Down

0 comments on commit bb2f36d

Please sign in to comment.