Compare commits
No commits in common. "b6b419ec06396a647099035e85010aad3071ef6b" and "a473dfdad52a9d592c7f873dd3c00ea484649fd1" have entirely different histories.
b6b419ec06
...
a473dfdad5
26
src/index.ts
26
src/index.ts
|
@ -24,8 +24,6 @@ addHandler("presentSeed", handlePresentSeed);
|
|||
addHandler("ready", handleReady);
|
||||
|
||||
[
|
||||
"eth_accounts",
|
||||
"eth_requestAccounts",
|
||||
"eth_getBalance",
|
||||
"eth_chainId",
|
||||
"eth_blockNumber",
|
||||
|
@ -43,12 +41,10 @@ addHandler("ready", handleReady);
|
|||
"eth_getLogs",
|
||||
"net_version",
|
||||
].forEach((rpcMethod) => {
|
||||
addHandler(rpcMethod, async (aq: ActiveQuery) => {
|
||||
aq.callerInput = {
|
||||
params: aq.callerInput || {},
|
||||
method: rpcMethod,
|
||||
};
|
||||
aq.respond(await handleRpcMethod(aq));
|
||||
addHandler(rpcMethod, (aq: ActiveQuery) => {
|
||||
aq.callerInput = aq.callerInput || {};
|
||||
aq.callerInput.method = rpcMethod;
|
||||
handleRpcMethod(aq);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -60,10 +56,6 @@ 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],
|
||||
|
@ -182,7 +174,9 @@ async function setup() {
|
|||
const method = data.get("method");
|
||||
let params = data.get("params");
|
||||
|
||||
params = JSON.parse(params);
|
||||
if (params === "null") {
|
||||
params = null;
|
||||
}
|
||||
|
||||
let query;
|
||||
let ret: RPCResponse;
|
||||
|
@ -212,10 +206,10 @@ async function setup() {
|
|||
await client.sync();
|
||||
}
|
||||
|
||||
async function handleReady(aq: ActiveQuery) {
|
||||
await moduleReady;
|
||||
async function handleReady(aq:ActiveQuery){
|
||||
await moduleReady;
|
||||
|
||||
aq.respond();
|
||||
aq.respond();
|
||||
}
|
||||
|
||||
function mapToObj(map: Map<any, any> | undefined): Object | undefined {
|
||||
|
|
Loading…
Reference in New Issue