mirror of
https://github.com/lil-org/tokenary.git
synced 2025-01-07 14:10:28 +03:00
Add chain info to response to extension
This commit is contained in:
parent
2496941709
commit
dd3a552969
@ -328,9 +328,9 @@ class Agent: NSObject {
|
||||
let accountsList = instantiate(AccountsListViewController.self)
|
||||
|
||||
accountsList.onSelectedWallet = { chainId, wallet in
|
||||
// TODO: pass results
|
||||
|
||||
ExtensionBridge.respond(id: safariRequest.id, response: ResponseToExtension(name: safariRequest.name, results: [wallet.ethereumAddress ?? "weird address"]))
|
||||
// TODO: pass chain info
|
||||
let response = ResponseToExtension(name: safariRequest.name, results: [wallet.ethereumAddress ?? "weird address"], chainId: "", rpcURL: "")
|
||||
ExtensionBridge.respond(id: safariRequest.id, response: response)
|
||||
Window.closeAllAndActivateBrowser()
|
||||
}
|
||||
|
||||
|
@ -8,36 +8,37 @@ struct ResponseToExtension: Codable {
|
||||
let result: String?
|
||||
let results: [String]?
|
||||
let error: String?
|
||||
let chainId: String?
|
||||
let rpcURL: String?
|
||||
|
||||
var json: [String: AnyHashable] {
|
||||
if let result = result {
|
||||
return ["name": name, "result": result]
|
||||
} else if let results = results {
|
||||
return ["name": name, "results": results]
|
||||
} else if let error = error {
|
||||
return ["name": name, "error": error]
|
||||
if let data = try? JSONEncoder().encode(self),
|
||||
let dict = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: AnyHashable] {
|
||||
return dict
|
||||
} else {
|
||||
return [:]
|
||||
}
|
||||
}
|
||||
|
||||
init(name: String, result: String) {
|
||||
self.init(name: name, result: result, results: nil, error: nil)
|
||||
self.init(name: name, result: result, results: nil, error: nil, chainId: nil, rpcURL: nil)
|
||||
}
|
||||
|
||||
init(name: String, results: [String]) {
|
||||
self.init(name: name, result: nil, results: results, error: nil)
|
||||
init(name: String, results: [String], chainId: String, rpcURL: String) {
|
||||
self.init(name: name, result: nil, results: results, error: nil, chainId: chainId, rpcURL: rpcURL)
|
||||
}
|
||||
|
||||
init(name: String, error: String) {
|
||||
self.init(name: name, result: nil, results: nil, error: error)
|
||||
self.init(name: name, result: nil, results: nil, error: error, chainId: nil, rpcURL: nil)
|
||||
}
|
||||
|
||||
private init(name: String, result: String?, results: [String]?, error: String?) {
|
||||
private init(name: String, result: String?, results: [String]?, error: String?, chainId: String?, rpcURL: String?) {
|
||||
self.name = name
|
||||
self.result = result
|
||||
self.results = results
|
||||
self.error = error
|
||||
self.chainId = chainId
|
||||
self.rpcURL = rpcURL
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user