-
Notifications
You must be signed in to change notification settings - Fork 1
/
interfaces.js
110 lines (98 loc) · 4.4 KB
/
interfaces.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { apmAppId } from './utils/apps'
// ABIs
import abiAragonACL from '@aragon/os/abi/ACL'
import abiAragonAppProxy from '@aragon/os/abi/AppProxyBase'
import abiAragonERCProxy from '@aragon/os/abi/ERCProxy'
import abiAragonForwarder from '@aragon/os/abi/IForwarder'
import abiAragonForwarderFee from '@aragon/os/abi/IForwarderFee'
import abiAragonKernel from '@aragon/os/abi/Kernel'
import abiAragonEVMScriptRegistry from '@aragon/os/abi/EVMScriptRegistry'
import abiERC20 from '@aragon/os/abi/ERC20'
import abiApmRegistry from '@aragon/os/abi/APMRegistry'
import abiApmRepo from '@aragon/os/abi/Repo'
import abiApmEnsSubdomainRegistrar from '@aragon/os/abi/ENSSubdomainRegistrar'
import abiAgentApp from '@aragon/os/abi/Agent' // added for data-fetching
import abiDAppWallApp from '@aragon/os/abi/DAppWall' // added for data-fetching
import abiFinanceApp from '@aragon/os/abi/Finance' // added for data-fetching
import abiPayrollApp from '@aragon/os/abi/Payroll' // added for data-fetching
import abiSurveyApp from '@aragon/os/abi/Survey' // added for data-fetching
import abiTokenManagerApp from '@aragon/os/abi/TokenManager' // added for data-fetching
import abiVaultApp from '@aragon/os/abi/Vault' // added for data-fetching
import abiVotingApp from '@aragon/os/abi/Voting' // added for data-fetching
// Artifacts
import artifactsAragonACL from '../artifacts/aragon/ACL.json'
import artifactsAragonKernel from '../artifacts/aragon/Kernel.json'
import artifactsAragonEVMScriptRegistry from '../artifacts/aragon/EVMScriptRegistry.json'
import artifactsApmRegistry from '../artifacts/apm/APMRegistry.json'
import artifactsApmRepo from '../artifacts/apm/Repo.json'
import artifactsApmEnsSubdomainRegistrar from '../artifacts/apm/ENSSubdomainRegistrar.json'
const ABIS = {
'aragon/ACL': abiAragonACL.abi,
'aragon/AppProxy': abiAragonAppProxy.abi,
'aragon/ERCProxy': abiAragonERCProxy.abi,
'aragon/Forwarder': abiAragonForwarder.abi,
'aragon/ForwarderFee': abiAragonForwarderFee.abi,
'aragon/Kernel': abiAragonKernel.abi,
'aragon/EVM Script Registry': abiAragonEVMScriptRegistry.abi,
'aragon/Agent': abiAgentApp.abi, // added for data-fetching
'aragon/DAppWall': abiDAppWallApp.abi, // added for data-fetching
'aragon/Finance': abiFinanceApp.abi, // added for data-fetching
'aragon/Payroll': abiPayrollApp.abi, // added for data-fetching
'aragon/Survey': abiSurveyApp.abi, // added for data-fetching
'aragon/TokenManager': abiTokenManagerApp.abi, // added for data-fetching
'aragon/Vault': abiVaultApp.abi, // added for data-fetching
'aragon/Voting': abiVotingApp.abi, // added for data-fetching
'apm/APM Registry': abiApmRegistry.abi,
'apm/Repo': abiApmRepo.abi,
'apm/ENS Subdomain Registrar': abiApmEnsSubdomainRegistrar.abi,
'standard/ERC20': abiERC20.abi
}
const ARTIFACTS = {
'aragon/ACL': artifactsAragonACL,
'aragon/Kernel': artifactsAragonKernel,
'aragon/EVM Script Registry': artifactsAragonEVMScriptRegistry,
'apm/APM Registry': artifactsApmRegistry,
'apm/Repo': artifactsApmRepo,
'apm/ENS Subdomain Registrar': artifactsApmEnsSubdomainRegistrar
}
const SYSTEM_APP_MAPPINGS = new Map([
[apmAppId('acl'), 'ACL'],
[apmAppId('evmreg'), 'EVM Script Registry'],
[apmAppId('kernel'), 'Kernel']
])
const APM_APP_MAPPINGS = new Map([
[apmAppId('apm-registry'), 'APM Registry'],
[apmAppId('apm-repo'), 'Repo'],
[apmAppId('apm-enssub'), 'ENS Subdomain Registrar'],
// Support open.aragonpm.eth's native packages
// Note that these were erroneously deployed on the open.aragonpm.eth instance rather than
// reusing the aragonpm.eth versions
[apmAppId('apm-registry.open'), 'APM Registry'],
[apmAppId('apm-repo.open'), 'Repo'],
[apmAppId('apm-enssub.open'), 'ENS Subdomain Registrar']
])
const APP_NAMESPACE_MAPPINGS = new Map([
['aragon', SYSTEM_APP_MAPPINGS],
['apm', APM_APP_MAPPINGS]
])
export const getAbi = name => ABIS[name] || null
export const getArtifact = name => ARTIFACTS[name] || null
export function getAppInfo (appId, namespace) {
const nameMapping = APP_NAMESPACE_MAPPINGS.get(namespace)
if (!nameMapping || !nameMapping.has(appId)) {
return null
}
const name = nameMapping.get(appId)
const app = `${namespace}/${name}`
const abi = getAbi(app)
const artifact = getArtifact(app)
return {
abi,
name,
...artifact
}
}
export function hasAppInfo (appId, namespace) {
const mapping = APP_NAMESPACE_MAPPINGS.get(namespace)
return Boolean(mapping) && mapping.has(appId)
}