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

[Notify] SIWE message updated + null app #1177

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Sources/WalletConnectNotify/Client/Wallet/NotifyClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public class NotifyClient {
self.subscriptionWatcher = subscriptionWatcher
}

public func register(account: Account, domain: String, onSign: @escaping SigningCallback) async throws {
try await identityService.register(account: account, domain: domain, onSign: onSign)
public func register(account: Account, domain: String, isLimited: Bool = false, onSign: @escaping SigningCallback) async throws {
try await identityService.register(account: account, domain: domain, isLimited: isLimited, onSign: onSign)
subscriptionWatcher.setAccount(account)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ final class NotifyIdentityService {
self.logger = logger
}

public func register(account: Account, domain: String, onSign: @escaping SigningCallback) async throws {
public func register(account: Account, domain: String, isLimited: Bool, onSign: @escaping SigningCallback) async throws {
let statement = makeStatement(isLimited: isLimited)
let pubKey = try await identityClient.register(account: account,
domain: domain,
statement: makeStatement(),
statement: statement,
resources: [keyserverURL.absoluteString],
onSign: onSign)
logger.debug("Did register an account: \(account)")
Expand All @@ -28,7 +29,12 @@ final class NotifyIdentityService {

private extension NotifyIdentityService {

func makeStatement() -> String {
return "I further authorize this app to send and receive messages on my behalf using my WalletConnect identity. Read more at https://walletconnect.com/identity"
func makeStatement(isLimited: Bool) -> String {
switch isLimited {
case true:
return "I further authorize this app to send and receive messages on my behalf for THIS domain using my WalletConnect identity. Read more at https://walletconnect.com/identity"
case false:
return "I further authorize this app to send and receive messages on my behalf for ALL domains using my WalletConnect identity. Read more at https://walletconnect.com/identity"
}
}
}
3 changes: 2 additions & 1 deletion Sources/Web3Inbox/NotifyClientProxy/NotifyClientProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class NotifyClientProxy {
try await respond(request: request)
case .register:
let params = try parse(RegisterRequest.self, params: request.params)
try await client.register(account: params.account, domain: params.domain, onSign: onSign)
try await client.register(account: params.account, domain: params.domain, isLimited: params.isLimited, onSign: onSign)
try await respond(request: request)
}
}
Expand Down Expand Up @@ -92,6 +92,7 @@ private extension NotifyClientProxy {
struct RegisterRequest: Codable {
let account: Account
let domain: String
let isLimited: Bool
}

func parse<Request: Codable>(_ type: Request.Type, params: AnyCodable?) throws -> Request {
Expand Down