UNPKG

@1hive/connect-core

Version:

Access and interact with Aragon Organizations and their apps.

50 lines 2.15 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.filterAndDecodeAppUpgradeIntents = exports.appIntent = void 0; const address_1 = require("./address"); const kernel_1 = require("./kernel"); const index_1 = require("./path/index"); const ForwardingPath_1 = __importDefault(require("../entities/ForwardingPath")); async function appIntent(sender, destinationApp, methodSignature, params, installedApps, provider) { const acl = installedApps.find((app) => app.name === 'acl'); if (acl && address_1.addressesEqual(destinationApp.address, acl.address)) { try { return index_1.getACLForwardingPath(sender, acl, methodSignature, params, installedApps, provider); } catch (_) { // emtpy path return new ForwardingPath_1.default({ destination: destinationApp, path: [], transactions: [], }, installedApps, provider); } } return index_1.getForwardingPath(sender, destinationApp, methodSignature, params, installedApps, provider); } exports.appIntent = appIntent; function filterAndDecodeAppUpgradeIntents(intents, installedApps) { const kernel = installedApps.find((app) => app.name === 'kernel'); if (!kernel) { throw new Error(`Organization not found.`); } return (intents // Filter for setApp() calls to the kernel .filter((intent) => kernel_1.isKernelSetAppIntent(kernel, intent)) // Try to decode setApp() params .map((intent) => { try { return kernel_1.decodeKernelSetAppParameters(intent.data); // eslint-disable-next-line no-empty } catch (_) { } return []; }) // Filter for changes to APP_BASES_NAMESPACE .filter((result) => kernel_1.isKernelAppCodeNamespace(result['namesapce']))); } exports.filterAndDecodeAppUpgradeIntents = filterAndDecodeAppUpgradeIntents; //# sourceMappingURL=intent.js.map