@1hive/connect-core
Version:
Access and interact with Aragon Organizations and their apps.
42 lines • 1.78 kB
JavaScript
import { addressesEqual } from './address';
import { decodeKernelSetAppParameters, isKernelAppCodeNamespace, isKernelSetAppIntent, } from './kernel';
import { getForwardingPath, getACLForwardingPath } from './path/index';
import ForwardingPath from '../entities/ForwardingPath';
export async function appIntent(sender, destinationApp, methodSignature, params, installedApps, provider) {
const acl = installedApps.find((app) => app.name === 'acl');
if (acl && addressesEqual(destinationApp.address, acl.address)) {
try {
return getACLForwardingPath(sender, acl, methodSignature, params, installedApps, provider);
}
catch (_) {
// emtpy path
return new ForwardingPath({
destination: destinationApp,
path: [],
transactions: [],
}, installedApps, provider);
}
}
return getForwardingPath(sender, destinationApp, methodSignature, params, installedApps, provider);
}
export 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) => isKernelSetAppIntent(kernel, intent))
// Try to decode setApp() params
.map((intent) => {
try {
return decodeKernelSetAppParameters(intent.data);
// eslint-disable-next-line no-empty
}
catch (_) { }
return [];
})
// Filter for changes to APP_BASES_NAMESPACE
.filter((result) => isKernelAppCodeNamespace(result['namesapce'])));
}
//# sourceMappingURL=intent.js.map