Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into simplify-get-acl-wi…
Browse files Browse the repository at this point in the history
…th-cache

* origin/master:
  @aragon/wrapper 5.0.0-rc.5
  fix: add back name and identifer to describe script (aragon#299)
  wrapper: return original step if radspec couldn't be evaluated (aragon#298)
  @aragon/wrapper 5.0.0-rc.3
  wrapper: handle intent baskets (aragon#286)
  @aragon/wrapper 5.0.0-rc.3
  Wrapper: add artifacts for aragonPM apps (aragon#273)
  Wrapper: override fetched app info with on-chain values (aragon#288)
  • Loading branch information
2color committed May 14, 2019
2 parents c6dd4b3 + 550b903 commit 4c0316c
Show file tree
Hide file tree
Showing 25 changed files with 983 additions and 313 deletions.
32 changes: 32 additions & 0 deletions packages/aragon-wrapper/artifacts/apm/APMRegistry.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"appName": "apm-registry.aragonpm.eth",
"roles": [
{
"id": "CREATE_REPO_ROLE",
"bytes": "0x2a9494d64846c9fdbf0158785aa330d8bc9caf45af27fa0e8898eb4d55adcea6",
"name": "Create repos",
"params": []
}
],
"functions": [
{
"sig": "initialize(address)",
"roles": [],
"notice": "Initialize this APMRegistry instance and set `_registrar` as the ENS subdomain registrar"
},
{
"sig": "newRepo(string,address)",
"roles": [
"CREATE_REPO_ROLE"
],
"notice": "Create new repo in registry with `_name`"
},
{
"sig": "newRepoWithVersion(string,address,uint16[3],address,bytes)",
"roles": [
"CREATE_REPO_ROLE"
],
"notice": "Create new repo in registry with `_name` and publish a first version with contract `_contractAddress` and content `@fromHex(_contentURI)`"
}
]
}
58 changes: 58 additions & 0 deletions packages/aragon-wrapper/artifacts/apm/ENSSubdomainRegistrar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"appName": "apm-enssub.aragonpm.eth",
"roles": [
{
"id": "CREATE_NAME_ROLE",
"bytes": "0xf86bc2abe0919ab91ef714b2bec7c148d94f61fdb069b91a6cfe9ecdee1799ba",
"name": "Create subdomains",
"params": []
},
{
"id": "DELETE_NAME_ROLE",
"bytes": "0x03d74c8724218ad4a99859bcb2d846d39999449fd18013dd8d69096627e68622",
"name": "Remove subdomains",
"params": []
},
{
"id": "POINT_ROOTNODE_ROLE",
"bytes": "0x9ecd0e7bddb2e241c41b595a436c4ea4fd33c9fa0caa8056acf084fc3aa3bfbe",
"name": "Point root domain",
"params": []
}
],
"functions": [
{
"sig": "initialize(address,bytes32)",
"roles": [],
"notice": "Initialize this ENSSubdomainRegistrar instance with `_ens` as the root ENS registry and `_rootNode` as the node to allocate subdomains under"
},
{
"sig": "createName(bytes32,address)",
"roles": [
"CREATE_NAME_ROLE"
],
"notice": "Create a new ENS subdomain record for `_label` and assign ownership to `_owner`"
},
{
"sig": "createNameAndPoint(bytes32,address)",
"roles": [
"CREATE_NAME_ROLE"
],
"notice": "Create a new ENS subdomain record for `_label` that resolves to `_target` and is owned by this ENSSubdomainRegistrar"
},
{
"sig": "deleteName(bytes32)",
"roles": [
"DELETE_NAME_ROLE"
],
"notice": "Deregister ENS subdomain record for `_label`"
},
{
"sig": "pointRootNode(address)",
"roles": [
"POINT_ROOTNODE_ROLE"
],
"notice": "Resolve this ENSSubdomainRegistrar's root node to `_target`"
}
]
}
25 changes: 25 additions & 0 deletions packages/aragon-wrapper/artifacts/apm/Repo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"appName": "apm-repo.aragonpm.eth",
"roles": [
{
"id": "CREATE_VERSION_ROLE",
"bytes": "0x1f56cfecd3595a2e6cc1a7e6cb0b20df84cdbd92eff2fee554e70e4e45a9a7d8",
"name": "Publish versions",
"params": []
}
],
"functions": [
{
"sig": "initialize()",
"roles": [],
"notice": "Initialize this Repo"
},
{
"sig": "newVersion(uint16[3],address,bytes)",
"roles": [
"CREATE_VERSION_ROLE"
],
"notice": "Create new version with contract `_contractAddress` and content `@fromHex(_contentURI)`"
}
]
}
3 changes: 2 additions & 1 deletion packages/aragon-wrapper/artifacts/aragon/ACL.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"appName": "acl.aragonpm.eth",
"roles": [
{
"name": "Create permissions",
Expand Down Expand Up @@ -71,4 +72,4 @@
"notice":null
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"appName": "evmreg.aragonpm.eth",
"roles": [
{
"name": "Add executors",
Expand Down Expand Up @@ -41,4 +42,4 @@
"notice":"Enable script executor with ID `_executorId`"
}
]
}
}
3 changes: 2 additions & 1 deletion packages/aragon-wrapper/artifacts/aragon/Kernel.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"appName": "kernel.aragonpm.eth",
"roles": [
{
"name": "Manage apps",
Expand Down Expand Up @@ -57,4 +58,4 @@
"notice":null
}
]
}
}
2 changes: 1 addition & 1 deletion packages/aragon-wrapper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aragon/wrapper",
"version": "5.0.0-rc.2",
"version": "5.0.0-rc.5",
"description": "Library for Aragon client implementations",
"main": "dist/index.js",
"scripts": {
Expand Down
31 changes: 3 additions & 28 deletions packages/aragon-wrapper/src/core/apm/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
import { makeProxy } from '../../utils'
import { getAppInfo } from '../../interfaces'

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()
}))
export function getApmAppInfo (appId) {
return getAppInfo(appId, 'apm')
}
27 changes: 27 additions & 0 deletions packages/aragon-wrapper/src/core/apm/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import test from 'ava'
import sinon from 'sinon'
import * as apm from './index'

test.afterEach.always(() => {
sinon.restore()
})

test('apm: getApmAppInfo', async (t) => {
t.plan(6)
// arrange
// namehash('apm-repo.aragonpm.eth')
const repoNamehash = '0x7b4f7602faf178a4a239b8b2ed4155358e256b08ee7c6b6b1b01ebec891ce1f1'
// namehash('apm-repo.open.aragonpm.eth')
const repoOpenNamehash = '0xf254443da20ea3d6bad4fa45ddd197dd713255675d3304106f889682e479f9c0'
// act
const result = apm.getApmAppInfo(repoNamehash)
const openResult = apm.getApmAppInfo(repoOpenNamehash)
const emptyResult = apm.getApmAppInfo()
// assert
t.is(result.name, 'Repo')
t.true(Array.isArray(result.abi))
t.is(openResult.name, 'Repo')
t.true(Array.isArray(openResult.abi))
t.deepEqual(result, openResult)
t.is(emptyResult, null)
})
31 changes: 31 additions & 0 deletions packages/aragon-wrapper/src/core/apm/repo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { getAbi } from '../../interfaces'
import { makeProxyFromABI } from '../../utils'

export async function makeRepoProxy (appId, apm, web3) {
const repoAddress = await apm.ensResolve(appId)
return makeProxyFromABI(repoAddress, getAbi('apm/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()
}))
}
44 changes: 6 additions & 38 deletions packages/aragon-wrapper/src/core/aragonOS/index.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,19 @@
import { hash as namehash } from 'eth-ens-namehash'
import { soliditySha3 } from 'web3-utils'
import { getAbi, getArtifact } from '../../interfaces'

const aragonpmAppId = appName => namehash(`${appName}.aragonpm.eth`)

const APP_MAPPINGS = new Map([
[aragonpmAppId('acl'), 'ACL'],
[aragonpmAppId('evmreg'), 'EVM Script Registry'],
[aragonpmAppId('kernel'), 'Kernel']
])

const KERNEL_NAMESPACES = new Map([
[soliditySha3('core'), 'Core'],
[soliditySha3('app'), 'Default apps'],
[soliditySha3('base'), 'App code']
])
import { getAppInfo, hasAppInfo } from '../../interfaces'

function getAragonOsInternalAppInfo (appId) {
const appName = APP_MAPPINGS.get(appId)

if (!appName) {
return
}

const abi = getAbi(`aragon/${appName}`)
const artifact = getArtifact(`aragon/${appName}`)

return {
abi,
name: appName,
isAragonOsInternalApp: true,
...artifact
}
}
const appInfo = getAppInfo(appId, 'aragon')

function getKernelNamespace (hash) {
if (KERNEL_NAMESPACES.has(hash)) {
return { name: KERNEL_NAMESPACES.get(hash), hash }
return appInfo && {
...appInfo,
isAragonOsInternalApp: true
}
}

function isAragonOsInternalApp (appId) {
return APP_MAPPINGS.has(appId)
return hasAppInfo(appId, 'aragon')
}

export {
getAragonOsInternalAppInfo,
getKernelNamespace,
isAragonOsInternalApp
}
36 changes: 18 additions & 18 deletions packages/aragon-wrapper/src/core/aragonOS/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ test.afterEach.always(() => {
sinon.restore()
})

test('aragonOS: getKernelNamespace', async (t) => {
t.plan(3)
test('aragonOS: getAragonOsInternalAppInfo', async (t) => {
t.plan(4)
// arrange
// soliditySha3('core')
const coreNamespaceHash = '0xc681a85306374a5ab27f0bbc385296a54bcd314a1948b6cf61c4ea1bc44bb9f8'
// namehash('acl.aragonpm.eth')
const aclNamehash = '0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a'
// act
const result = aragonOS.getKernelNamespace(coreNamespaceHash)
const emptyResult = aragonOS.getKernelNamespace()
const result = aragonOS.getAragonOsInternalAppInfo(aclNamehash)
const emptyResult = aragonOS.getAragonOsInternalAppInfo()
// assert
t.is(result.hash, coreNamespaceHash)
t.is(result.name, 'Core')
t.is(emptyResult, undefined)
t.is(result.name, 'ACL')
t.true(Array.isArray(result.abi))
t.is(result.isAragonOsInternalApp, true)
t.is(emptyResult, null)
})

test('aragonOS: getAragonOsInternalAppInfo', async (t) => {
t.plan(3)
test('aragonOS: isAragonOsInternalApp', async (t) => {
t.plan(2)
// arrange
// namehash(acl.aragonpm.eth)
const aclNameHash = '0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a'
// namehash('acl.aragonpm.eth')
const aclNamehash = '0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a'
// act
const result = aragonOS.getAragonOsInternalAppInfo(aclNameHash)
const emptyResult = aragonOS.getAragonOsInternalAppInfo()
const result = aragonOS.isAragonOsInternalApp(aclNamehash)
const emptyResult = aragonOS.isAragonOsInternalApp()
// assert
t.is(result.name, 'ACL')
t.is(result.isAragonOsInternalApp, true)
t.is(emptyResult, undefined)
t.true(result)
t.false(emptyResult)
})
Loading

0 comments on commit 4c0316c

Please sign in to comment.