Compare commits
4 Commits
a473dfdad5
...
b6b419ec06
Author | SHA1 | Date |
---|---|---|
Derrick Hammer | b6b419ec06 | |
Derrick Hammer | a9c8990baa | |
Derrick Hammer | 3873bd47a2 | |
Derrick Hammer | b39af76606 |
20
src/index.ts
20
src/index.ts
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue