@1hive/connect-core
Version:
Access and interact with Aragon Organizations and their apps.
27 lines • 1.33 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const metadata_1 = require("../utils/metadata");
const Permission_1 = __importDefault(require("./Permission"));
class Role {
constructor(data, metadata, organization) {
var _a;
const { roles } = metadata[0];
const role = roles === null || roles === void 0 ? void 0 : roles.find((role) => role.bytes === data.hash);
this.appAddress = data.appAddress;
this.description = role === null || role === void 0 ? void 0 : role.name;
this.hash = data.hash;
this.manager = data.manager;
this.name = role === null || role === void 0 ? void 0 : role.id;
this.params = role === null || role === void 0 ? void 0 : role.params;
this.permissions = (_a = data.grantees) === null || _a === void 0 ? void 0 : _a.map((grantee) => new Permission_1.default(grantee, organization));
}
static async create(data, organization) {
const artifact = await metadata_1.resolveArtifact(organization.connection.ipfs, data);
return new Role(data, [artifact], organization);
}
}
exports.default = Role;
//# sourceMappingURL=Role.js.map