-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrapper: add installedRepos observable (#268)
Adds an `installedRepos` observable that emits an array of `InstalledRepos`.
- Loading branch information
Showing
5 changed files
with
338 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.