Skip to content

Commit

Permalink
Wrapper: add installedRepos observable (#268)
Browse files Browse the repository at this point in the history
Adds an `installedRepos` observable that emits an array of `InstalledRepos`.
  • Loading branch information
sohkai authored Apr 17, 2019
1 parent cb775a8 commit 60e0a61
Show file tree
Hide file tree
Showing 5 changed files with 338 additions and 9 deletions.
30 changes: 30 additions & 0 deletions packages/aragon-wrapper/src/core/apm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { makeProxy } from '../../utils'

export async function makeRepoProxy (appId, apm, web3) {
const repoAddress = await apm.ensResolve(appId)
return makeProxy(repoAddress, 'Repo', web3)
}

export async function getAllRepoVersions (repoProxy) {
const versions = []
const versionCount = await repoProxy.call('getVersionsCount')

// Versions index starts at 1
for (let versionId = 1; versionId <= versionCount; ++versionId) {
versions.push(await getRepoVersionById(repoProxy, versionId))
}

return Promise.all(versions)
}

export function getRepoVersionById (repoProxy, versionId) {
return repoProxy
.call('getByVersionId', versionId)
.then(({ contentURI, contractAddress, semanticVersion }) => ({
contentURI,
contractAddress,
version: semanticVersion.join('.'),
// Keeping this as a string makes comparisons a bit easier down the line
versionId: versionId.toString()
}))
}
10 changes: 9 additions & 1 deletion packages/aragon-wrapper/src/core/aragonOS/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@ function getKernelNamespace (hash) {
}
}

export { getAragonOsInternalAppInfo, getKernelNamespace }
function isAragonOsInternalApp (appId) {
return APP_MAPPINGS.has(appId)
}

export {
getAragonOsInternalAppInfo,
getKernelNamespace,
isAragonOsInternalApp
}
Loading

0 comments on commit 60e0a61

Please sign in to comment.