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