@exromany/lido-csm-sdk
Version:
[](https://github.com/lidofinance/lido-csm-sdk/blob/main/LICENSE.txt) [](h
151 lines • 9.69 kB
JavaScript
;
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
var useValue = arguments.length > 2;
for (var i = 0; i < initializers.length; i++) {
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
}
return useValue ? value : void 0;
};
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
var _, done = false;
for (var i = decorators.length - 1; i >= 0; i--) {
var context = {};
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
if (kind === "accessor") {
if (result === void 0) continue;
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
if (_ = accept(result.get)) descriptor.get = _;
if (_ = accept(result.set)) descriptor.set = _;
if (_ = accept(result.init)) initializers.unshift(_);
}
else if (_ = accept(result)) {
if (kind === "field") initializers.unshift(_);
else descriptor[key] = _;
}
}
if (target) Object.defineProperty(target, contextIn.name, descriptor);
done = true;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RolesSDK = void 0;
const lido_ethereum_sdk_1 = require("@lidofinance/lido-ethereum-sdk");
const csm_sdk_module_js_1 = require("../common/class-primitives/csm-sdk-module.js");
const index_js_1 = require("../common/decorators/index.js");
const index_js_2 = require("../common/index.js");
const index_js_3 = require("../tx-sdk/index.js");
let RolesSDK = (() => {
var _a;
let _classSuper = csm_sdk_module_js_1.CsmSDKModule;
let _instanceExtraInitializers = [];
let _changeRewardsAddress_decorators;
let _proposeManagerAddress_decorators;
let _proposeRewardsAddress_decorators;
let _resetManagerAddress_decorators;
let _confirmRewardsAddress_decorators;
let _confirmManagerAddress_decorators;
return _a = class RolesSDK extends _classSuper {
get moduleContract() {
return this.core.contractBaseModule;
}
async changeRewardsAddress(props) {
const { nodeOperatorId, address, ...rest } = props;
return this.bus.tx.perform({
...rest,
call: () => (0, index_js_3.prepCall)(this.moduleContract, 'changeNodeOperatorRewardAddress', [
nodeOperatorId,
address,
]),
decodeResult: () => this.prepareRoleResult(nodeOperatorId),
});
}
async proposeManagerAddress(props) {
const { nodeOperatorId, address, ...rest } = props;
return this.bus.tx.perform({
...rest,
call: () => (0, index_js_3.prepCall)(this.moduleContract, 'proposeNodeOperatorManagerAddressChange', [nodeOperatorId, address]),
decodeResult: () => this.prepareRoleResult(nodeOperatorId),
});
}
async proposeRewardsAddress(props) {
const { nodeOperatorId, address, ...rest } = props;
return this.bus.tx.perform({
...rest,
call: () => (0, index_js_3.prepCall)(this.moduleContract, 'proposeNodeOperatorRewardAddressChange', [nodeOperatorId, address]),
decodeResult: () => this.prepareRoleResult(nodeOperatorId),
});
}
async resetManagerAddress(props) {
const { nodeOperatorId, ...rest } = props;
return this.bus.tx.perform({
...rest,
call: () => (0, index_js_3.prepCall)(this.moduleContract, 'resetNodeOperatorManagerAddress', [
nodeOperatorId,
]),
decodeResult: () => this.prepareRoleResult(nodeOperatorId),
});
}
async confirmRewardsAddress(props) {
const { nodeOperatorId, ...rest } = props;
return this.bus.tx.perform({
...rest,
call: () => (0, index_js_3.prepCall)(this.moduleContract, 'confirmNodeOperatorRewardAddressChange', [nodeOperatorId]),
decodeResult: () => this.prepareRoleResult(nodeOperatorId),
});
}
async confirmManagerAddress(props) {
const { nodeOperatorId, ...rest } = props;
return this.bus.tx.perform({
...rest,
call: () => (0, index_js_3.prepCall)(this.moduleContract, 'confirmNodeOperatorManagerAddressChange', [nodeOperatorId]),
decodeResult: () => this.prepareRoleResult(nodeOperatorId),
});
}
async confirmAddress(props) {
const { role } = props;
switch (role) {
case index_js_2.ROLES.MANAGER:
return this.confirmManagerAddress(props);
case index_js_2.ROLES.REWARDS:
return this.confirmRewardsAddress(props);
default:
throw new lido_ethereum_sdk_1.SDKError({
message: 'unsupported role',
code: lido_ethereum_sdk_1.ERROR_CODE.INVALID_ARGUMENT,
});
}
}
prepareRoleResult(nodeOperatorId) {
return this.bus.operator.getManagementProperties(nodeOperatorId);
}
constructor() {
super(...arguments);
__runInitializers(this, _instanceExtraInitializers);
}
},
(() => {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
_changeRewardsAddress_decorators = [(0, index_js_1.Logger)('Call:'), (0, index_js_1.ErrorHandler)()];
_proposeManagerAddress_decorators = [(0, index_js_1.Logger)('Call:'), (0, index_js_1.ErrorHandler)()];
_proposeRewardsAddress_decorators = [(0, index_js_1.Logger)('Call:'), (0, index_js_1.ErrorHandler)()];
_resetManagerAddress_decorators = [(0, index_js_1.Logger)('Call:'), (0, index_js_1.ErrorHandler)()];
_confirmRewardsAddress_decorators = [(0, index_js_1.Logger)('Call:'), (0, index_js_1.ErrorHandler)()];
_confirmManagerAddress_decorators = [(0, index_js_1.Logger)('Call:'), (0, index_js_1.ErrorHandler)()];
__esDecorate(_a, null, _changeRewardsAddress_decorators, { kind: "method", name: "changeRewardsAddress", static: false, private: false, access: { has: obj => "changeRewardsAddress" in obj, get: obj => obj.changeRewardsAddress }, metadata: _metadata }, null, _instanceExtraInitializers);
__esDecorate(_a, null, _proposeManagerAddress_decorators, { kind: "method", name: "proposeManagerAddress", static: false, private: false, access: { has: obj => "proposeManagerAddress" in obj, get: obj => obj.proposeManagerAddress }, metadata: _metadata }, null, _instanceExtraInitializers);
__esDecorate(_a, null, _proposeRewardsAddress_decorators, { kind: "method", name: "proposeRewardsAddress", static: false, private: false, access: { has: obj => "proposeRewardsAddress" in obj, get: obj => obj.proposeRewardsAddress }, metadata: _metadata }, null, _instanceExtraInitializers);
__esDecorate(_a, null, _resetManagerAddress_decorators, { kind: "method", name: "resetManagerAddress", static: false, private: false, access: { has: obj => "resetManagerAddress" in obj, get: obj => obj.resetManagerAddress }, metadata: _metadata }, null, _instanceExtraInitializers);
__esDecorate(_a, null, _confirmRewardsAddress_decorators, { kind: "method", name: "confirmRewardsAddress", static: false, private: false, access: { has: obj => "confirmRewardsAddress" in obj, get: obj => obj.confirmRewardsAddress }, metadata: _metadata }, null, _instanceExtraInitializers);
__esDecorate(_a, null, _confirmManagerAddress_decorators, { kind: "method", name: "confirmManagerAddress", static: false, private: false, access: { has: obj => "confirmManagerAddress" in obj, get: obj => obj.confirmManagerAddress }, metadata: _metadata }, null, _instanceExtraInitializers);
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
})(),
_a;
})();
exports.RolesSDK = RolesSDK;
//# sourceMappingURL=roles-sdk.js.map