Implement EIP-1193 provider for dApp connectivity
All checks were successful
check / check (push) Successful in 13s
All checks were successful
check / check (push) Successful in 13s
Three-part architecture: - inpage.js: creates window.ethereum in page context with request(), on(), send(), sendAsync(), enable() methods. Sets isMetaMask=true for compatibility. - content/index.js: bridge between page and extension via postMessage (page<->content) and runtime.sendMessage (content<->background). - background/index.js: handles RPC routing. Proxies read-only methods (eth_call, eth_getBalance, etc.) to configured RPC. Handles eth_requestAccounts (auto-connect for now), wallet_switchEthereumChain (mainnet only), and returns informative errors for unimplemented signing methods. Manifests updated with web_accessible_resources for inpage.js. Build updated to bundle inpage.js as a separate output file.
This commit is contained in:
11
build.js
11
build.js
@@ -62,6 +62,17 @@ async function build() {
|
||||
minify: true,
|
||||
});
|
||||
|
||||
// bundle inpage script (injected into page context, separate file)
|
||||
await esbuild.build({
|
||||
entryPoints: [path.join(SRC, "content", "inpage.js")],
|
||||
bundle: true,
|
||||
format: "iife",
|
||||
outfile: path.join(distDir, "src", "content", "inpage.js"),
|
||||
platform: "browser",
|
||||
target: ["chrome110", "firefox110"],
|
||||
minify: true,
|
||||
});
|
||||
|
||||
// copy popup HTML
|
||||
fs.copyFileSync(
|
||||
path.join(SRC, "popup", "index.html"),
|
||||
|
||||
Reference in New Issue
Block a user