Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(async (resolve, reject) => {
try {
// Look up registry address based on current network connection
const domain = name.indexOf('.') > -1 ? name : `${name}.aragonid.eth`
const options = {
provider: require('../../provider'),
apm: {
ipfs: {
gateway: 'https://ipfs.eth.aragon.network/ipfs'
},
ensRegistryAddress: registryAddress()
}
}
const address = await resolveAragon(domain, options.apm.ensRegistryAddress)
const wrap = new Wrapper(address, options)
await wrap.init()
const subscription = wrap.apps.subscribe(apps => {
subscription.unsubscribe()
const appsSummary = {}
apps.forEach(app => {
const { appId, proxyAddress } = app
const name = appNames[appId]
if (name) appsSummary[name] = { proxyAddress }
})
if (!appsSummary['kernel']) return reject(new Error('Unable to locate DAO kernel'))
if (!appsSummary['agent']) return reject(new Error('Unable to locate DAO agent, make sure it is installed'))
resolve({ name: domain.split('.')[0], domain, apps: appsSummary, ens: address, network: store('main.connection.network') })
})
} catch (e) {
reject(e)
}
module.exports = async function (to, web3) {
const proxy = new web3.eth.Contract(require('./AppProxyBase.json').abi, to)
const kernel = await proxy.methods.kernel().call()
const options = {
provider: require('../../../provider'),
apm: {
ipfs: {
gateway: 'https://ipfs.eth.aragon.network/ipfs'
},
ensRegistryAddress: registryAddress()
}
}
const wrap = new Wrapper(kernel, options)
await wrap.init()
const apps = await wrap.apps.pipe(first()).toPromise()
const app = apps.find((app) => addressesEqual(app.proxyAddress, to))
var detailed = {
abi: app.abi,
userdoc: {
methods: {}
}
}
app.functions.forEach(func => { detailed.userdoc.methods[func.sig] = { notice: func.notice } })
return detailed
}
setup () {
const connection = store('main.connection')
const status = [connection.local.status, connection.secondary.status]
if (status.indexOf('connected') > -1 && this.network === connection.network && !this.wrap && !this.inSetup) {
log.info('\n ** Setting Up Aragon DAO:', this.dao)
this.inSetup = true
this.provider = require('../../provider')
const options = {
provider: this.provider,
apm: { ipfs: { gateway: 'https://ipfs.eth.aragon.network/ipfs' }, ensRegistryAddress: registryAddress() }
}
const wrap = new Wrapper(this.dao, options)
wrap.init().then(() => {
this.wrap = wrap
this.inSetup = false
}).catch(err => {
log.error(err)
this.inSetup = false
})
}
}