@molecularlabs/nucleus-frontend
Version:
Nucleus BoringVault Frontend SDK
53 lines • 1.91 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var vault_status_exports = {};
__export(vault_status_exports, {
getVaultStatus: () => getVaultStatus
});
module.exports = __toCommonJS(vault_status_exports);
var import_multi_call = require("../api/multi-call");
var import_vaults = require("../vaults");
const getVaultStatus = async ({ vaultKey, chainId }) => {
const vault = await (0, import_vaults.getVaultByKey)(vaultKey);
if (!vault) {
throw new Error(`Vault not found: ${vaultKey}`);
}
const tellerAddress = vault.contracts.teller;
const accountantAddress = vault.contracts.accountant;
const [tellerStatus, accountantStatus] = await (0, import_multi_call.getPausedStates)({
accountantAddress,
tellerAddress,
chainId
});
if (tellerStatus.status === "failure") {
throw new Error(tellerStatus.error.message);
}
if (accountantStatus.status === "failure") {
throw new Error(accountantStatus.error.message);
}
if (tellerStatus.result === true || accountantStatus.result[7] === true) {
return {
isPaused: true
};
}
return {
isPaused: false
};
};
//# sourceMappingURL=vault-status.js.map