Compare commits
41 Commits
Author | SHA1 | Date |
---|---|---|
semantic-release-bot | ca5348ee64 | |
Derrick Hammer | a75e8916a5 | |
Derrick Hammer | 53504f7e4d | |
semantic-release-bot | a12a46ab65 | |
Derrick Hammer | 0f5fb2f564 | |
Derrick Hammer | 982e81a8e8 | |
semantic-release-bot | 519bbf9316 | |
Derrick Hammer | b6071312b7 | |
Derrick Hammer | 8df32ad402 | |
Derrick Hammer | 71ed20ff13 | |
semantic-release-bot | b436ed06bf | |
Derrick Hammer | ec1479b3c8 | |
Derrick Hammer | fd2251bdde | |
Derrick Hammer | 90a90e9c80 | |
semantic-release-bot | 6f256495da | |
Derrick Hammer | 5e57fe15ca | |
Derrick Hammer | 46a7d0cd7a | |
semantic-release-bot | 024207f419 | |
Derrick Hammer | 7168baf893 | |
Derrick Hammer | d5da11f4a6 | |
semantic-release-bot | fb35d9404d | |
Derrick Hammer | bdc7600444 | |
Derrick Hammer | 4639a43e42 | |
semantic-release-bot | 606e767515 | |
Derrick Hammer | 63a0201809 | |
Derrick Hammer | 6a3175dc7b | |
semantic-release-bot | 41270fd335 | |
Derrick Hammer | 3f5dfd4261 | |
Derrick Hammer | 10e83d8d55 | |
semantic-release-bot | 449838ce83 | |
Derrick Hammer | 37baedf27e | |
Derrick Hammer | 326d38275d | |
Derrick Hammer | 3e28aa782a | |
Derrick Hammer | 9259e6723c | |
semantic-release-bot | 821232889d | |
Derrick Hammer | 0c0d717439 | |
Derrick Hammer | a71f1cb155 | |
semantic-release-bot | 819c7395b7 | |
Derrick Hammer | f77db1cf7d | |
Derrick Hammer | 72c6072c41 | |
Derrick Hammer | 59ece6720e |
|
@ -0,0 +1,13 @@
|
||||||
|
name: Build/Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
- develop-*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
main:
|
||||||
|
uses: lumeweb/github-node-deploy-workflow/.github/workflows/main.yml@master
|
||||||
|
secrets: inherit
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"preset": [
|
||||||
|
"@lumeweb/presetter-kernel-module-preset"
|
||||||
|
],
|
||||||
|
"config": {
|
||||||
|
"official": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
# [0.1.0-develop.12](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.11...v0.1.0-develop.12) (2023-11-16)
|
||||||
|
|
||||||
|
# [0.1.0-develop.11](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.10...v0.1.0-develop.11) (2023-10-31)
|
||||||
|
|
||||||
|
# [0.1.0-develop.10](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.9...v0.1.0-develop.10) (2023-10-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* need to store walletAddress ([71ed20f](https://git.lumeweb.com/LumeWeb/kernel-lavanet/commit/71ed20ff13dbf0cd396dfd6c3a31163a467b4fc4))
|
||||||
|
|
||||||
|
# [0.1.0-develop.9](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.8...v0.1.0-develop.9) (2023-10-23)
|
||||||
|
|
||||||
|
# [0.1.0-develop.8](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.7...v0.1.0-develop.8) (2023-09-04)
|
||||||
|
|
||||||
|
# [0.1.0-develop.7](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.6...v0.1.0-develop.7) (2023-09-03)
|
||||||
|
|
||||||
|
# [0.1.0-develop.6](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.5...v0.1.0-develop.6) (2023-09-02)
|
||||||
|
|
||||||
|
# [0.1.0-develop.5](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.4...v0.1.0-develop.5) (2023-08-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* ensure chain is uppercase since map is indexed by it ([6a3175d](https://git.lumeweb.com/LumeWeb/kernel-lavanet/commit/6a3175dc7b336534fdbfdfb55937e5895b967fb6))
|
||||||
|
|
||||||
|
# [0.1.0-develop.4](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.3...v0.1.0-develop.4) (2023-08-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* missing await ([10e83d8](https://git.lumeweb.com/LumeWeb/kernel-lavanet/commit/10e83d8d55fb1925dccc800be7eeae74771fc5b6))
|
||||||
|
|
||||||
|
# [0.1.0-develop.3](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.2...v0.1.0-develop.3) (2023-08-21)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* if we have data, set dummy header response, parse data to a uint8array and process as a chunk ([326d382](https://git.lumeweb.com/LumeWeb/kernel-lavanet/commit/326d38275da7a46534ac600bce5b7df6e6be7648))
|
||||||
|
* sdk patch needs to use options object ([9259e67](https://git.lumeweb.com/LumeWeb/kernel-lavanet/commit/9259e6723cfeec4ba1a130b6a594b72240c81fd9))
|
||||||
|
|
||||||
|
# [0.1.0-develop.2](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.1.0-develop.1...v0.1.0-develop.2) (2023-08-20)
|
||||||
|
|
||||||
|
# [0.1.0-develop.1](https://git.lumeweb.com/LumeWeb/kernel-lavanet/compare/v0.0.1...v0.1.0-develop.1) (2023-08-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* initial version ([59ece67](https://git.lumeweb.com/LumeWeb/kernel-lavanet/commit/59ece6720e23869063da00b2a460265a615c2e10))
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2023 LumeWeb
|
Copyright (c) 2023 Hammer Technologies LLC
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
"name": "@lumeweb/kernel-lavanet",
|
||||||
|
"type": "module",
|
||||||
|
"version": "0.1.0-develop.12",
|
||||||
|
"readme": "ERROR: No README data found!",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "gitea@git.lumeweb.com:LumeWeb/kernel-lavanet.git"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"prepare": "presetter bootstrap",
|
||||||
|
"build": "run build",
|
||||||
|
"semantic-release": "semantic-release",
|
||||||
|
"postinstall": "patch-package"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@lavanet/lava-sdk": "^0.26.1",
|
||||||
|
"@lumeweb/kernel-rpc-client": "^0.0.2-develop.18",
|
||||||
|
"@lumeweb/libkernel": "^0.1.0-develop.67"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@lumeweb/presetter-kernel-module-preset": "^0.1.0-develop.44",
|
||||||
|
"patch-package": "^8.0.0"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
diff --git a/node_modules/@lavanet/lava-sdk/bin/src/badge/badgeManager.js b/node_modules/@lavanet/lava-sdk/bin/src/badge/badgeManager.js
|
||||||
|
index aae75cf..96939be 100644
|
||||||
|
--- a/node_modules/@lavanet/lava-sdk/bin/src/badge/badgeManager.js
|
||||||
|
+++ b/node_modules/@lavanet/lava-sdk/bin/src/badge/badgeManager.js
|
||||||
|
@@ -35,7 +35,7 @@ class BadgeManager {
|
||||||
|
if (options.authentication) {
|
||||||
|
this.authentication.append("Authorization", options.authentication);
|
||||||
|
}
|
||||||
|
- this.transport = transport;
|
||||||
|
+ this.transport = transport || options.transport;
|
||||||
|
this.badgeGeneratorClient = new badges_pb_service_1.BadgeGeneratorClient(this.badgeServerAddress, this.getTransportWrapped());
|
||||||
|
}
|
||||||
|
isActive() {
|
||||||
|
diff --git a/node_modules/@lavanet/lava-sdk/bin/src/sdk/sdk.js b/node_modules/@lavanet/lava-sdk/bin/src/sdk/sdk.js
|
||||||
|
index 89267e8..90f6a88 100644
|
||||||
|
--- a/node_modules/@lavanet/lava-sdk/bin/src/sdk/sdk.js
|
||||||
|
+++ b/node_modules/@lavanet/lava-sdk/bin/src/sdk/sdk.js
|
||||||
|
@@ -89,6 +89,7 @@ class LavaSDK {
|
||||||
|
if (!this.badgeManager.isActive() || this.privKey != "") {
|
||||||
|
const wallet = yield (0, wallet_1.createWallet)(this.privKey);
|
||||||
|
this.account = yield wallet.getConsumerAccount();
|
||||||
|
+ this.walletAddress = this.account.address;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const { wallet, privKey } = yield (0, wallet_1.createDynamicWallet)();
|
|
@ -0,0 +1,77 @@
|
||||||
|
import { LavaSDK } from "@lavanet/lava-sdk";
|
||||||
|
import type { ActiveQuery } from "@lumeweb/libkernel/module";
|
||||||
|
import {
|
||||||
|
addHandler,
|
||||||
|
defer,
|
||||||
|
getKey,
|
||||||
|
handlePresentKey as handlePresentKeyModule,
|
||||||
|
} from "@lumeweb/libkernel/module";
|
||||||
|
import {
|
||||||
|
createClient as createRpcClient,
|
||||||
|
RpcNetwork,
|
||||||
|
} from "@lumeweb/kernel-rpc-client";
|
||||||
|
import { bytesToHex, deriveChildKey } from "@lumeweb/libweb";
|
||||||
|
import { hyperTransport } from "./transport.js";
|
||||||
|
|
||||||
|
addHandler("presentKey", handlePresentKey);
|
||||||
|
addHandler("query", handleQuery);
|
||||||
|
|
||||||
|
const chainInstances = new Map<string, LavaSDK>();
|
||||||
|
const moduleReadyDefer = defer();
|
||||||
|
let rpc: RpcNetwork;
|
||||||
|
|
||||||
|
async function handlePresentKey(aq: ActiveQuery) {
|
||||||
|
handlePresentKeyModule({
|
||||||
|
callerInput: {
|
||||||
|
key: aq.callerInput.rootKey,
|
||||||
|
},
|
||||||
|
} as ActiveQuery);
|
||||||
|
rpc = createRpcClient();
|
||||||
|
moduleReadyDefer.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleQuery(aq: ActiveQuery) {
|
||||||
|
if (!("chain" in aq.callerInput)) {
|
||||||
|
aq.reject("chain missing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!("query" in aq.callerInput)) {
|
||||||
|
aq.reject("query missing");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let { chain, query } = aq.callerInput;
|
||||||
|
|
||||||
|
chain = chain.toUpperCase();
|
||||||
|
|
||||||
|
let lava: LavaSDK;
|
||||||
|
|
||||||
|
if (!chainInstances.has(chain)) {
|
||||||
|
lava = await setupRelayChain(chain);
|
||||||
|
} else {
|
||||||
|
lava = chainInstances.get(chain) as LavaSDK;
|
||||||
|
}
|
||||||
|
|
||||||
|
await rpc.ready;
|
||||||
|
|
||||||
|
try {
|
||||||
|
aq.respond(await lava.sendRelay(query));
|
||||||
|
} catch (e) {
|
||||||
|
aq.reject(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setupRelayChain(chain: string) {
|
||||||
|
const instance = await LavaSDK.create({
|
||||||
|
badge: {
|
||||||
|
// @ts-ignore
|
||||||
|
transport: hyperTransport(rpc),
|
||||||
|
},
|
||||||
|
chainIds: chain,
|
||||||
|
privateKey: bytesToHex(deriveChildKey(await getKey(), "lavanet")),
|
||||||
|
});
|
||||||
|
|
||||||
|
chainInstances.set(chain, instance);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
import { grpc } from "@improbable-eng/grpc-web";
|
||||||
|
import { RpcNetwork } from "@lumeweb/kernel-rpc-client";
|
||||||
|
import Metadata = grpc.Metadata;
|
||||||
|
|
||||||
|
class HyperTransport implements grpc.Transport {
|
||||||
|
private options: grpc.TransportOptions;
|
||||||
|
private rpc: RpcNetwork;
|
||||||
|
|
||||||
|
constructor(transportOptions: grpc.TransportOptions, rpc: RpcNetwork) {
|
||||||
|
this.options = transportOptions;
|
||||||
|
this.rpc = rpc;
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel(): void {}
|
||||||
|
|
||||||
|
finishSend(): void {}
|
||||||
|
|
||||||
|
async sendMessage(msgBytes: Uint8Array): Promise<void> {
|
||||||
|
const req = this.rpc.simpleQuery({
|
||||||
|
query: {
|
||||||
|
module: "lavanet",
|
||||||
|
method: "badge_request",
|
||||||
|
data: {
|
||||||
|
data: msgBytes,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const ret = await req.result;
|
||||||
|
if (ret.error) {
|
||||||
|
this.options.onEnd({ message: ret.error, name: "", stack: "" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.data) {
|
||||||
|
ret.data?.forEach((item: number[]) => {
|
||||||
|
this.options.onChunk(Uint8Array.from(item));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.options.onEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
start(metadata: Metadata): void {}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function hyperTransport(rpc: RpcNetwork): grpc.TransportFactory {
|
||||||
|
return (opts: grpc.TransportOptions) => {
|
||||||
|
return new HyperTransport(opts, rpc);
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue