refactor: upgrade lavanet
This commit is contained in:
parent
90a90e9c80
commit
fd2251bdde
|
@ -1,46 +0,0 @@
|
|||
diff --git a/node_modules/@lavanet/lava-sdk/bin/src/badge/fetchBadge.js b/node_modules/@lavanet/lava-sdk/bin/src/badge/fetchBadge.js
|
||||
index 0c3063a..b989837 100644
|
||||
--- a/node_modules/@lavanet/lava-sdk/bin/src/badge/fetchBadge.js
|
||||
+++ b/node_modules/@lavanet/lava-sdk/bin/src/badge/fetchBadge.js
|
||||
@@ -24,6 +24,7 @@ class BadgeManager {
|
||||
this.badgeServerAddress = "";
|
||||
this.projectId = "";
|
||||
this.active = true;
|
||||
+ this.transport = options?.transport;
|
||||
if (!options) {
|
||||
this.active = false;
|
||||
return;
|
||||
@@ -52,7 +53,7 @@ class BadgeManager {
|
||||
request: request,
|
||||
host: this.badgeServerAddress,
|
||||
metadata: this.authentication ? this.authentication : {},
|
||||
- transport: browser_1.default,
|
||||
+ transport: this.transport ?? browser_1.default,
|
||||
onMessage: (message) => {
|
||||
resolve(message);
|
||||
},
|
||||
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 53bfa7d..4ef0fd7 100644
|
||||
--- a/node_modules/@lavanet/lava-sdk/bin/src/sdk/sdk.js
|
||||
+++ b/node_modules/@lavanet/lava-sdk/bin/src/sdk/sdk.js
|
||||
@@ -47,9 +47,6 @@ class LavaSDK {
|
||||
if (!badge && !privateKey) {
|
||||
throw errors_1.default.errPrivKeyAndBadgeNotInitialized;
|
||||
}
|
||||
- else if (badge && privateKey) {
|
||||
- throw errors_1.default.errPrivKeyAndBadgeBothInitialized;
|
||||
- }
|
||||
// Initialize local attributes
|
||||
this.debugMode = options.debug ? options.debug : false; // enabling debug prints mainly used for development / debugging
|
||||
this.secure = options.secure !== undefined ? options.secure : true;
|
||||
@@ -148,8 +145,8 @@ class LavaSDK {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const start = performance.now();
|
||||
if (this.badgeManager.isActive()) {
|
||||
- const { wallet, privKey } = yield (0, wallet_1.createDynamicWallet)();
|
||||
- this.privKey = privKey;
|
||||
+ const wallet = yield (0, wallet_1.createWallet)(this.privKey);
|
||||
+ const account = yield wallet.getConsumerAccount();
|
||||
this.walletAddress = (yield wallet.getConsumerAccount()).address;
|
||||
const badgeResponse = yield this.fetchNewBadge();
|
||||
this.currentEpochBadge = badgeResponse.getBadge();
|
|
@ -0,0 +1,13 @@
|
|||
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() {
|
11
src/index.ts
11
src/index.ts
|
@ -40,14 +40,14 @@ async function handleQuery(aq: ActiveQuery) {
|
|||
return;
|
||||
}
|
||||
|
||||
let { chain, query, rpcInterface = undefined } = aq.callerInput;
|
||||
let { chain, query } = aq.callerInput;
|
||||
|
||||
chain = chain.toUpperCase();
|
||||
|
||||
let lava: LavaSDK;
|
||||
|
||||
if (!chainInstances.has(chain)) {
|
||||
lava = await setupRelayChain(chain, rpcInterface);
|
||||
lava = await setupRelayChain(chain);
|
||||
} else {
|
||||
lava = chainInstances.get(chain) as LavaSDK;
|
||||
}
|
||||
|
@ -61,15 +61,14 @@ async function handleQuery(aq: ActiveQuery) {
|
|||
}
|
||||
}
|
||||
|
||||
async function setupRelayChain(chain: string, rpcInterface?: string) {
|
||||
async function setupRelayChain(chain: string) {
|
||||
const instance = await LavaSDK.create({
|
||||
chainID: chain,
|
||||
privateKey: bytesToHex(deriveChildKey(await getKey(), "lavanet")),
|
||||
badge: {
|
||||
// @ts-ignore
|
||||
transport: hyperTransport(rpc),
|
||||
},
|
||||
rpcInterface,
|
||||
chainIds: chain,
|
||||
privateKey: bytesToHex(deriveChildKey(await getKey(), "lavanet")),
|
||||
});
|
||||
|
||||
chainInstances.set(chain, instance);
|
||||
|
|
Loading…
Reference in New Issue