@1hive/connect-core
Version:
Access and interact with Aragon Organizations and their apps.
87 lines • 3.99 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasAppInfo = exports.getAppInfo = exports.getArtifact = exports.getAbi = void 0;
const app_1 = require("../app");
// ABIs
const ACL_json_1 = __importDefault(require("./abi/ACL.json"));
const Kernel_json_1 = __importDefault(require("./abi/Kernel.json"));
const EVMScriptRegistry_json_1 = __importDefault(require("./abi/EVMScriptRegistry.json"));
const APMRegistry_json_1 = __importDefault(require("./abi/APMRegistry.json"));
const Repo_json_1 = __importDefault(require("./abi/Repo.json"));
const ENSSubdomainRegistrar_json_1 = __importDefault(require("./abi/ENSSubdomainRegistrar.json"));
// Artifacts
const ACL_json_2 = __importDefault(require("./artifacts/aragon/ACL.json"));
const Kernel_json_2 = __importDefault(require("./artifacts/aragon/Kernel.json"));
const EVMScriptRegistry_json_2 = __importDefault(require("./artifacts/aragon/EVMScriptRegistry.json"));
const APMRegistry_json_2 = __importDefault(require("./artifacts/apm/APMRegistry.json"));
const Repo_json_2 = __importDefault(require("./artifacts/apm/Repo.json"));
const ENSSubdomainRegistrar_json_2 = __importDefault(require("./artifacts/apm/ENSSubdomainRegistrar.json"));
const ABIS = {
'aragon/ACL': ACL_json_1.default.abi,
'aragon/Kernel': Kernel_json_1.default.abi,
'aragon/EVM Script Registry': EVMScriptRegistry_json_1.default.abi,
'apm/APM Registry': APMRegistry_json_1.default.abi,
'apm/Repo': Repo_json_1.default.abi,
'apm/ENS Subdomain Registrar': ENSSubdomainRegistrar_json_1.default.abi,
};
const ARTIFACTS = {
'aragon/ACL': ACL_json_2.default,
'aragon/Kernel': Kernel_json_2.default,
'aragon/EVM Script Registry': EVMScriptRegistry_json_2.default,
'apm/APM Registry': APMRegistry_json_2.default,
'apm/Repo': Repo_json_2.default,
'apm/ENS Subdomain Registrar': ENSSubdomainRegistrar_json_2.default,
};
const SYSTEM_APP_MAPPINGS = new Map([
[app_1.apmAppId('acl'), 'ACL'],
[app_1.apmAppId('evmreg'), 'EVM Script Registry'],
[app_1.apmAppId('kernel'), 'Kernel'],
]);
const APM_APP_MAPPINGS = new Map([
[app_1.apmAppId('apm-registry'), 'APM Registry'],
[app_1.apmAppId('apm-repo'), 'Repo'],
[app_1.apmAppId('apm-enssub'), 'ENS Subdomain Registrar'],
// Support open.aragonpm.eth's native packages
// Note that these were erroneously deployed on the open.aragonpm.eth instance rather than
// reusing the aragonpm.eth versions
[app_1.apmAppId('apm-registry.open'), 'APM Registry'],
[app_1.apmAppId('apm-repo.open'), 'Repo'],
[app_1.apmAppId('apm-enssub.open'), 'ENS Subdomain Registrar'],
// Support hatch.aragonpm.eth's native packages (see note above for `open.aragonpm.eth`)
[app_1.apmAppId('apm-registry.hatch'), 'APM Registry'],
[app_1.apmAppId('apm-repo.hatch'), 'Repo'],
[app_1.apmAppId('apm-enssub.hatch'), 'ENS Subdomain Registrar'],
]);
const APP_NAMESPACE_MAPPINGS = new Map([
['aragon', SYSTEM_APP_MAPPINGS],
['apm', APM_APP_MAPPINGS],
]);
exports.getAbi = (name) => ABIS[name] || null;
exports.getArtifact = (name) => ARTIFACTS[name] || null;
function getAppInfo(appId, namespace) {
const nameMapping = APP_NAMESPACE_MAPPINGS.get(namespace);
if (!nameMapping || !nameMapping.has(appId)) {
return null;
}
const appName = nameMapping.get(appId);
const app = `${namespace}/${appName}`;
const abi = exports.getAbi(app);
const artifact = exports.getArtifact(app);
return {
abi,
appName,
...artifact,
};
}
exports.getAppInfo = getAppInfo;
function hasAppInfo(appId, namespace) {
const mapping = APP_NAMESPACE_MAPPINGS.get(namespace);
if (mapping)
return Boolean(mapping) && mapping.has(appId);
return false;
}
exports.hasAppInfo = hasAppInfo;
//# sourceMappingURL=interfaces.js.map