cc-zos-vouching
Version:
Vouching logic for the EVM packages of the ZeppelinOS smart contract platform
69 lines (59 loc) • 2.86 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addValidator = addValidator;
exports.addAttributeType = addAttributeType;
exports.addValidatorApproval = addValidatorApproval;
exports.createZeppelinOrganization = createZeppelinOrganization;
var _log = require('../helpers/log');
var _log2 = _interopRequireDefault(_log);
var _constants = require('../constants');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = async function configureTPL(jurisdiction, validator, options) {
_log2.default.base('\n--------------------------------------------------------------------\n\n');
await addValidator(jurisdiction, validator, options);
await addAttributeType(jurisdiction, options);
await addValidatorApproval(jurisdiction, validator, options);
await createZeppelinOrganization(validator, options);
};
async function addValidator(jurisdiction, validator, { txParams }) {
_log2.default.base(`Adding Organizations validator ${validator.address} to the jurisdiction...`);
try {
await jurisdiction.addValidator(validator.address, _constants.VALIDATOR_NAME, txParams);
_log2.default.info(` ✔ Organizations validator added`);
} catch (error) {
_log2.default.error(` ✘ Could not add Organizations validator to the jurisdiction`);
throw error;
}
}
async function addAttributeType(jurisdiction, { txParams }) {
_log2.default.base(`Adding ZEP Token attribute ${_constants.ZEPTOKEN_ATTRIBUTE_ID} to the jurisdiction...`);
try {
await jurisdiction.addAttributeType(_constants.ZEPTOKEN_ATTRIBUTE_ID, _constants.ZEPTOKEN_ATTRIBUTE_DESCRIPTION, txParams);
_log2.default.info(` ✔ ZEP Token attribute added`);
} catch (error) {
_log2.default.error(` ✘ Could not add ZEP Token attribute to the jurisdiction`);
throw error;
}
}
async function addValidatorApproval(jurisdiction, validator, { txParams }) {
_log2.default.base(`Adding Organizations validator approval to the jurisdiction...`);
try {
await jurisdiction.addValidatorApproval(validator.address, _constants.ZEPTOKEN_ATTRIBUTE_ID, txParams);
_log2.default.info(` ✔ Organizations validator approval added`);
} catch (error) {
_log2.default.error(` ✘ Could not add Organizations validator approval to the jurisdiction`);
throw error;
}
}
async function createZeppelinOrganization(validator, { txParams }) {
_log2.default.base(`Creating Zeppelin organization for the OrganizationsValidator...`);
try {
await validator.addOrganization(txParams.from, _constants.ZEPPELIN_ORG_MAX_ADDRESSES, _constants.ZEPPELIN_ORG_NAME, txParams);
_log2.default.info(` ✔ TPL Zeppelin organization created`);
} catch (error) {
_log2.default.error(` ✘ Could create Zeppelin organization for TPL`);
throw error;
}
}