Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hazae41 committed Oct 29, 2023
1 parent c349052 commit 8bc3288
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 0 additions & 6 deletions src/mods/background/content_script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,6 @@ new Pool<Disposer<chrome.runtime.Port>, Error>(async (params) => {

port.events.on("close", onClose, { passive: true })

{
const detail = { chainId: 1 }
const event = new CustomEvent("ethereum#connect", { detail })
window.dispatchEvent(event)
}

const onClean = () => {
window.removeEventListener("ethereum#request", onScriptRequest)
port.events.off("close", onClose)
Expand Down
5 changes: 4 additions & 1 deletion src/mods/background/injected_script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ class Provider {
let suplistener = listeners.get(sublistener)

if (suplistener == null) {
suplistener = (e: CustomEvent<string>) => void sublistener(JSON.parse(e.detail))
suplistener = (e: CustomEvent<string>) => {
sublistener(JSON.parse(e.detail))
}

listeners.set(sublistener, suplistener)
}

Expand Down
5 changes: 5 additions & 0 deletions src/mods/background/service_worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@ export class Global {
return new None()
})

await script.tryRequest<void>({
method: "connect",
params: [{ chainId: `0x${chainId.toString(16)}` }]
}).then(r => r.throw(t).throw(t))

return new Ok(sessionData)
})
}
Expand Down

0 comments on commit 8bc3288

Please sign in to comment.