forked from aragon/aragon.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into simplify-get-acl-wi…
…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
Showing
25 changed files
with
983 additions
and
313 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,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
58
packages/aragon-wrapper/artifacts/apm/ENSSubdomainRegistrar.json
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,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`" | ||
} | ||
] | ||
} |
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,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)`" | ||
} | ||
] | ||
} |
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
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
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
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
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 |
---|---|---|
@@ -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') | ||
} |
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,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) | ||
}) |
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,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() | ||
})) | ||
} |
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 |
---|---|---|
@@ -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 | ||
} |
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.