-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ec6b8d
commit 6a4abe0
Showing
3 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
Sources/WalletConnectSign/Engine/Common/ApproveEngineLoggingHelper.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
import Foundation | ||
|
||
|
||
final class ApproveEngineLoggingHelper { | ||
|
||
private let logger: ConsoleLogging | ||
|
||
init(logger: ConsoleLogging) { | ||
self.logger = logger | ||
} | ||
|
||
func logProposalNamespaces(title: String, _ namespaces: [String: ProposalNamespace]) { | ||
logger.debug("\(title):") | ||
for (key, namespace) in namespaces { | ||
logger.debug(" Namespace Key: \(key)") | ||
|
||
if let chains = namespace.chains, !chains.isEmpty { | ||
let chainList = chains.map { $0.absoluteString }.joined(separator: ", ") | ||
logger.debug(" Chains: [\(chainList)]") | ||
} else { | ||
logger.debug(" Chains: None") | ||
} | ||
|
||
if !namespace.methods.isEmpty { | ||
let methodsList = namespace.methods.sorted().joined(separator: ", ") | ||
logger.debug(" Methods: [\(methodsList)]") | ||
} else { | ||
logger.debug(" Methods: None") | ||
} | ||
|
||
if !namespace.events.isEmpty { | ||
let eventsList = namespace.events.sorted().joined(separator: ", ") | ||
logger.debug(" Events: [\(eventsList)]") | ||
} else { | ||
logger.debug(" Events: None") | ||
} | ||
} | ||
} | ||
|
||
func logSessionNamespaces(_ sessionNamespaces: [String: SessionNamespace]) { | ||
logger.debug("Session Namespaces:") | ||
for (namespaceKey, ns) in sessionNamespaces { | ||
logger.debug("Namespace: \(namespaceKey)") | ||
|
||
if let chains = ns.chains, !chains.isEmpty { | ||
let chainStrings = chains.map { $0.absoluteString }.joined(separator: ", ") | ||
logger.debug(" Chains: [\(chainStrings)]") | ||
} else { | ||
logger.debug(" Chains: None") | ||
} | ||
|
||
if !ns.accounts.isEmpty { | ||
// Assuming `Account` has a property `address` and `blockchain` | ||
let accountStrings = ns.accounts.map { "\($0.blockchain.absoluteString):\($0.address)" }.joined(separator: ", ") | ||
logger.debug(" Accounts: [\(accountStrings)]") | ||
} else { | ||
logger.debug(" Accounts: None") | ||
} | ||
|
||
if !ns.methods.isEmpty { | ||
let methodList = ns.methods.sorted().joined(separator: ", ") | ||
logger.debug(" Methods: [\(methodList)]") | ||
} else { | ||
logger.debug(" Methods: None") | ||
} | ||
|
||
if !ns.events.isEmpty { | ||
let eventList = ns.events.sorted().joined(separator: ", ") | ||
logger.debug(" Events: [\(eventList)]") | ||
} else { | ||
logger.debug(" Events: None") | ||
} | ||
} | ||
} | ||
} |