Compare commits

...

4 Commits

1 changed files with 16 additions and 10 deletions

View File

@ -24,6 +24,8 @@ addHandler("presentSeed", handlePresentSeed);
addHandler("ready", handleReady);
[
"eth_accounts",
"eth_requestAccounts",
"eth_getBalance",
"eth_chainId",
"eth_blockNumber",
@ -41,10 +43,12 @@ addHandler("ready", handleReady);
"eth_getLogs",
"net_version",
].forEach((rpcMethod) => {
addHandler(rpcMethod, (aq: ActiveQuery) => {
aq.callerInput = aq.callerInput || {};
aq.callerInput.method = rpcMethod;
handleRpcMethod(aq);
addHandler(rpcMethod, async (aq: ActiveQuery) => {
aq.callerInput = {
params: aq.callerInput || {},
method: rpcMethod,
};
aq.respond(await handleRpcMethod(aq));
});
});
@ -56,6 +60,10 @@ async function handlePresentSeed() {
async function handleRpcMethod(aq: ActiveQuery) {
await moduleReady;
switch (aq.callerInput?.method) {
case "eth_accounts":
case "eth_requestAccounts": {
return [];
}
case "eth_getBalance": {
return client.get_balance(
aq.callerInput?.params[0],
@ -174,9 +182,7 @@ async function setup() {
const method = data.get("method");
let params = data.get("params");
if (params === "null") {
params = null;
}
params = JSON.parse(params);
let query;
let ret: RPCResponse;