*Initial version
This commit is contained in:
commit
8462fb5c4b
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"name": "@lumeweb/kernel-eth-client",
|
||||
"version": "0.1.0",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"dependencies": {
|
||||
"@lumeweb/libkernel-universal": "git+https://git.lumeweb.com/LumeWeb/libkernel-universal.git",
|
||||
"@lumeweb/rpc-client": "git+https://git.lumeweb.com/LumeWeb/rpc-client.git",
|
||||
"buffer": "^6.0.3",
|
||||
"ethers": "^6.2.2",
|
||||
"libkernel": "^0.1.48",
|
||||
"libkmodule": "^0.2.53",
|
||||
"libskynet": "^0.0.62"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lumeweb/cfg": "git+https://git.lumeweb.com/LumeWeb/cfg.git",
|
||||
"@lumeweb/interface-relay": "git+https://git.lumeweb.com/LumeWeb/interface-relay.git",
|
||||
"@types/b4a": "^1.6.0",
|
||||
"@types/node": "^18.15.5",
|
||||
"@types/node-cache": "^4.2.5",
|
||||
"prettier": "^2.8.6",
|
||||
"typescript": "^5.0.2"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import { Client, factory } from "@lumeweb/libkernel-universal";
|
||||
|
||||
const RPC_MODULE = "AAAkzekB6FeX9sW2oBKOZ32G_2oU2oQWJIE9Iv4p6xBVGw";
|
||||
|
||||
export class EthClient extends Client {
|
||||
public async ready() {
|
||||
return this.callModuleReturn("ready");
|
||||
}
|
||||
public async method(method: string, params: any) {
|
||||
return this.callModuleReturn("method", params);
|
||||
}
|
||||
}
|
||||
|
||||
export const createClient = factory<EthClient>(EthClient, RPC_MODULE);
|
|
@ -0,0 +1,2 @@
|
|||
export { createClient } from "./client.js";
|
||||
export { createProvider } from "./provider.js";
|
|
@ -0,0 +1,19 @@
|
|||
import { Eip1193Provider, ethers } from "ethers";
|
||||
import { createClient, EthClient } from "./client.js";
|
||||
|
||||
export class Provider implements Eip1193Provider {
|
||||
private client: EthClient = createClient();
|
||||
|
||||
public async request(args: RequestArguments): Promise<unknown> {
|
||||
return this.client.method(args.method, args.params);
|
||||
}
|
||||
}
|
||||
|
||||
interface RequestArguments {
|
||||
readonly method: string;
|
||||
readonly params?: readonly unknown[] | object;
|
||||
}
|
||||
|
||||
export function createProvider(): ethers.BrowserProvider {
|
||||
return new ethers.BrowserProvider(new Provider());
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"strict": true,
|
||||
"module": "esnext",
|
||||
"target": "esnext",
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": false,
|
||||
"rootDir": "src",
|
||||
"outDir": "dist",
|
||||
"typeRoots": [
|
||||
"node_modules/@types",
|
||||
],
|
||||
"moduleResolution": "nodenext",
|
||||
"declarationMap": true,
|
||||
"declarationDir": "dist",
|
||||
"emitDeclarationOnly": false,
|
||||
"allowJs": true
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue