@hubbleprotocol/farms-sdk
Version:
51 lines • 3.05 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateGlobalConfigCommand = updateGlobalConfigCommand;
const web3_js_1 = require("@solana/web3.js");
const accounts_1 = require("../rpc_client/accounts");
const utils_1 = require("../utils");
const utils_2 = require("./utils");
const Farms_1 = require("../Farms");
const types_1 = require("../rpc_client/types");
function updateGlobalConfigCommand(updateMode, flagValueType, flagValue, mode, priorityFeeMultiplier) {
return __awaiter(this, void 0, void 0, function* () {
const admin = process.env.ADMIN;
const rpc = process.env.RPC;
const globalConfig = new web3_js_1.PublicKey(process.env.FARMS_GLOBAL_CONFIG);
const env = (0, utils_2.initializeClient)(rpc, admin, (0, utils_1.getFarmsProgramId)(rpc), mode === "multisig");
let globalConfigPk = new web3_js_1.PublicKey(globalConfig);
yield updateGlobalConfig(env, globalConfigPk, updateMode, flagValueType, flagValue, mode, priorityFeeMultiplier);
let globalConfigState = yield accounts_1.GlobalConfig.fetch(env.provider.connection, new web3_js_1.PublicKey(globalConfig));
mode !== "multisig" &&
console.log("Global Config", globalConfigState === null || globalConfigState === void 0 ? void 0 : globalConfigState.toJSON());
});
}
function updateGlobalConfig(env, globalConfig, modeName, flagValueType, flagValue, mode, priorityFeeMultiplier) {
return __awaiter(this, void 0, void 0, function* () {
if (flagValueType != "number" &&
flagValueType != "bool" &&
flagValueType != "boolean" &&
flagValueType != "publicKey") {
throw new Error("The type is invalid, it should be 'number', 'bool' or 'publicKey");
}
const farmsClient = new Farms_1.Farms(env.provider.connection);
yield farmsClient.updateGlobalConfig(env.initialOwner, globalConfig, types_1.GlobalConfigOption.fromDecoded({ [modeName]: "" }), flagValue, flagValueType, mode, priorityFeeMultiplier, env.web3Client);
mode !== "multisig" &&
console.log("Update Global Config: " +
globalConfig.toString() +
" mode: " +
modeName +
" value: " +
flagValue);
});
}
//# sourceMappingURL=update_global_config.js.map
;