feat: add register method for network registry
This commit is contained in:
parent
032470029c
commit
e7d85a2af4
|
@ -11,6 +11,7 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lumeweb/bigint-crypto-utils": "^1.0.0",
|
||||
"@lumeweb/kernel-network-registry-client": "^0.1.0-develop.2",
|
||||
"@lumeweb/kernel-rpc-client": "0.0.2-develop.4",
|
||||
"@lumeweb/libethsync": "0.1.0-develop.42",
|
||||
"@lumeweb/libkernel": "0.1.0-develop.16",
|
||||
|
@ -3096,6 +3097,35 @@
|
|||
"@lumeweb/relay-cfg": "0.1.9"
|
||||
}
|
||||
},
|
||||
"node_modules/@lumeweb/kernel-network-registry-client": {
|
||||
"version": "0.1.0-develop.2",
|
||||
"resolved": "https://registry.npmjs.org/@lumeweb/kernel-network-registry-client/-/kernel-network-registry-client-0.1.0-develop.2.tgz",
|
||||
"integrity": "sha512-e2iJylhabt+T++lcVJ2o+hoR6DNXtyTWeodROyJ+f1VPhS9rgzAGflDOKyd7Zpi4DDHzpRY2gJtiL18FHOmMrw==",
|
||||
"dependencies": {
|
||||
"@lumeweb/libkernel": "^0.1.0-develop.20"
|
||||
}
|
||||
},
|
||||
"node_modules/@lumeweb/kernel-network-registry-client/node_modules/@lumeweb/libkernel": {
|
||||
"version": "0.1.0-develop.20",
|
||||
"resolved": "https://registry.npmjs.org/@lumeweb/libkernel/-/libkernel-0.1.0-develop.20.tgz",
|
||||
"integrity": "sha512-z7yRk6B0P0bxPe+a4Xm5/Bl6eIfkDCB2IJhNK2Gm+o7j4RbWbizRk79+zgBFWMrYzo8bVrpBKK7nGI3iNOgT9g==",
|
||||
"dependencies": {
|
||||
"@lumeweb/libweb": "0.2.0-develop.26",
|
||||
"emittery": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@lumeweb/kernel-network-registry-client/node_modules/@lumeweb/libweb": {
|
||||
"version": "0.2.0-develop.26",
|
||||
"resolved": "https://registry.npmjs.org/@lumeweb/libweb/-/libweb-0.2.0-develop.26.tgz",
|
||||
"integrity": "sha512-XRIDiqRFqlEbcwjxAfkv7UYnyTflN3Q4rki8YAd9QrLQM2vycslgPLYS53vVJVL9GPH93V5J9z2V4DPQZlOOkQ==",
|
||||
"dependencies": {
|
||||
"@lumeweb/community-portals": "^0.1.0-develop.6",
|
||||
"@lumeweb/libportal": "^0.2.0-develop.16",
|
||||
"@lumeweb/node-library-preset": "0.2.7",
|
||||
"@noble/curves": "^1.1.0",
|
||||
"@noble/hashes": "^1.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@lumeweb/kernel-rpc-client": {
|
||||
"version": "0.0.2-develop.4",
|
||||
"resolved": "https://registry.npmjs.org/@lumeweb/kernel-rpc-client/-/kernel-rpc-client-0.0.2-develop.4.tgz",
|
||||
|
@ -3154,9 +3184,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@lumeweb/libportal": {
|
||||
"version": "0.2.0-develop.12",
|
||||
"resolved": "https://registry.npmjs.org/@lumeweb/libportal/-/libportal-0.2.0-develop.12.tgz",
|
||||
"integrity": "sha512-FKdMzeOvi8viXwFbKLeD7c4SadLDaz/ZvSLaAumuyXiJCKk0gVM0aPO8mTkibDtJG5JfeFHef0jI9aOSMYWfXw==",
|
||||
"version": "0.2.0-develop.16",
|
||||
"resolved": "https://registry.npmjs.org/@lumeweb/libportal/-/libportal-0.2.0-develop.16.tgz",
|
||||
"integrity": "sha512-wyzza/ttvU6I1gIs4tnYSkcT6s7MIBnUdJSNAbe6k6NsQ1w4bhBVJhEKbBru/lAEASO/PAhHGBwaOCv20rZZfA==",
|
||||
"dependencies": {
|
||||
"@lumeweb/node-library-preset": "git+https://git.lumeweb.com/LumeWeb/node-library-preset.git",
|
||||
"@noble/curves": "^1.1.0",
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@lumeweb/bigint-crypto-utils": "^1.0.0",
|
||||
"@lumeweb/kernel-network-registry-client": "^0.1.0-develop.2",
|
||||
"@lumeweb/kernel-rpc-client": "0.0.2-develop.4",
|
||||
"@lumeweb/libethsync": "0.1.0-develop.42",
|
||||
"@lumeweb/libkernel": "0.1.0-develop.16",
|
||||
|
|
18
src/index.ts
18
src/index.ts
|
@ -5,7 +5,11 @@ import {
|
|||
log,
|
||||
logErr,
|
||||
} from "@lumeweb/libkernel/module";
|
||||
import { createClient, RpcNetwork } from "@lumeweb/kernel-rpc-client";
|
||||
import {
|
||||
createClient as createRpcClient,
|
||||
RpcNetwork,
|
||||
} from "@lumeweb/kernel-rpc-client";
|
||||
import { createClient as createNetworkRegistryClient } from "@lumeweb/kernel-network-registry-client";
|
||||
import {
|
||||
Client as EthClient,
|
||||
ConsensusCommitteeUpdateRequest,
|
||||
|
@ -15,6 +19,9 @@ import * as capella from "@lodestar/types/capella";
|
|||
|
||||
onmessage = handleMessage;
|
||||
|
||||
const TYPES = ["blockchain"];
|
||||
const networkRegistry = createNetworkRegistryClient();
|
||||
|
||||
let moduleReadyResolve: Function;
|
||||
let moduleReady: Promise<void> = new Promise((resolve) => {
|
||||
moduleReadyResolve = resolve;
|
||||
|
@ -24,6 +31,7 @@ let client: EthClient;
|
|||
let rpc: RpcNetwork;
|
||||
|
||||
addHandler("presentKey", handlePresentKey);
|
||||
addHandler("register", handleRegister);
|
||||
addHandler("ready", handleReady);
|
||||
|
||||
[
|
||||
|
@ -121,7 +129,7 @@ async function executionHandler(data: Map<string, string | any>) {
|
|||
}
|
||||
|
||||
async function setup() {
|
||||
rpc = createClient();
|
||||
rpc = createRpcClient();
|
||||
await rpc.ready;
|
||||
|
||||
client = createEthClient(
|
||||
|
@ -163,3 +171,9 @@ async function handleReady(aq: ActiveQuery) {
|
|||
|
||||
aq.respond();
|
||||
}
|
||||
|
||||
async function handleRegister(aq: ActiveQuery) {
|
||||
await networkRegistry.registerNetwork(TYPES);
|
||||
|
||||
aq.respond();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue