@kamino-finance/farms-sdk
Version:
38 lines • 2.08 kB
JavaScript
;
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");
async function updateGlobalConfigCommand(updateMode, flagValueType, flagValue, mode, priorityFeeMultiplier) {
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);
await updateGlobalConfig(env, globalConfigPk, updateMode, flagValueType, flagValue, mode, priorityFeeMultiplier);
let globalConfigState = await accounts_1.GlobalConfig.fetch(env.provider.connection, new web3_js_1.PublicKey(globalConfig));
mode !== "multisig" &&
console.log("Global Config", globalConfigState?.toJSON());
}
async function updateGlobalConfig(env, globalConfig, modeName, flagValueType, flagValue, mode, priorityFeeMultiplier) {
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);
await 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