@kyve/core-beta
Version:
🚀 The base KYVE node implementation.
62 lines (61 loc) • 2.44 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupSDK = void 0;
const sdk_beta_1 = __importStar(require("@kyve/sdk-beta"));
const __1 = require("../..");
/**
* setupSDK creates the main KYVE SDK and the client which is used for transactions
* and the lcd client which is used for queries
*
* @method setupSDK
* @param {Node} this
* @return {Promise<void>}
*/
async function setupSDK() {
try {
this.logger.debug(`Initializing KyveSDK with network ${this.network}`);
// get KYVE network settings from network parameter
// TODO @regenisis: use chain-id as new network property
let network = sdk_beta_1.constants.KYVE_ENDPOINTS[this.network];
if (this.rpc) {
network = { ...network, rpc: this.rpc };
}
if (this.rest) {
network = { ...network, rest: this.rest };
}
this.sdk = new sdk_beta_1.default(network);
this.logger.debug(`Initializing KyveClient from valaccount mnemonic`);
this.client = await this.sdk.fromMnemonic(this.valaccount);
this.logger.debug(`Initializing KyveLCD from sdk`);
this.lcd = this.sdk.createLCDClient();
}
catch (err) {
this.logger.fatal(`Failed to init KYVE SDK. Exiting ...`);
this.logger.fatal((0, __1.standardizeJSON)(err));
process.exit(1);
}
}
exports.setupSDK = setupSDK;