UNPKG

blub-sdk

Version:

A modular SDK for interacting with the BLUB ecosystem on the Sui blockchain.

84 lines (83 loc) 4.5 kB
"use strict"; // Copyright (c) Blub Labs, Inc. // SPDX-License-Identifier: Apache-2.0 var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _ConfigModule_config, _ConfigModule_client; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConfigModule = void 0; /** * BalanceManagerContract class for managing BalanceManager operations. */ class ConfigModule { /** * @param {StakingConfig} config Configuration for BlubStakingConfig */ constructor(config, client) { _ConfigModule_config.set(this, void 0); _ConfigModule_client.set(this, void 0); __classPrivateFieldSet(this, _ConfigModule_config, config, "f"); __classPrivateFieldSet(this, _ConfigModule_client, client, "f"); } /** * @description Start staking * @param {StartStakingParams} params Parameters for starting staking * @param {Transaction} tx Transaction object */ startStakingMoveCall(params, tx) { const adminCap = params.adminCap ?? __classPrivateFieldGet(this, _ConfigModule_config, "f").ADMIN_CAP_ID; const protocolConfig = params.protocolConfig ?? __classPrivateFieldGet(this, _ConfigModule_config, "f").PROTOCOL_CONFIG_ID; tx.moveCall({ target: `${__classPrivateFieldGet(this, _ConfigModule_config, "f").BLUB_STAKING_PACKAGE_ID}::config::start_staking`, arguments: [tx.object(adminCap), tx.object(protocolConfig)], }); } /** * @description Stop staking * @param {StopStakingParams} params Parameters for stopping staking * @param {Transaction} tx Transaction object */ stopStakingMoveCall(params, tx) { const adminCap = params.adminCap ?? __classPrivateFieldGet(this, _ConfigModule_config, "f").ADMIN_CAP_ID; const protocolConfig = params.protocolConfig ?? __classPrivateFieldGet(this, _ConfigModule_config, "f").PROTOCOL_CONFIG_ID; tx.moveCall({ target: `${__classPrivateFieldGet(this, _ConfigModule_config, "f").BLUB_STAKING_PACKAGE_ID}::config::stop_staking`, arguments: [tx.object(adminCap), tx.object(protocolConfig)], }); } /** * @description Update package version * @param {UpdatePackageVersionParams} params Parameters for updating package version * @param {Transaction} tx Transaction object */ updatePackageVersionMoveCall(params, tx) { const adminCap = params.adminCap ?? __classPrivateFieldGet(this, _ConfigModule_config, "f").ADMIN_CAP_ID; const protocolConfig = params.protocolConfig ?? __classPrivateFieldGet(this, _ConfigModule_config, "f").PROTOCOL_CONFIG_ID; tx.moveCall({ target: `${__classPrivateFieldGet(this, _ConfigModule_config, "f").BLUB_STAKING_PACKAGE_ID}::config::update_package_version`, arguments: [ tx.object(adminCap), tx.object(protocolConfig), tx.pure.u64(params.version), ], }); } async get_protocol_config(protocolConfigId) { const protocolConfig = await __classPrivateFieldGet(this, _ConfigModule_client, "f").getObject({ id: protocolConfigId ?? __classPrivateFieldGet(this, _ConfigModule_config, "f").PROTOCOL_CONFIG_ID, options: { showContent: true, showType: true }, }); return protocolConfig; } } exports.ConfigModule = ConfigModule; _ConfigModule_config = new WeakMap(), _ConfigModule_client = new WeakMap();