Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
Implement minor changes on change-admin command
Browse files Browse the repository at this point in the history
  • Loading branch information
spalladino committed Aug 29, 2018
1 parent b58a7ec commit 3664c24
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/commands/set-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import _ from 'lodash'

const name = 'set-admin'
const signature = `${name} [alias-or-address] [new-admin-address]`
const description = 'change upgradeability admin of a contract instance. Provide the [alias] or [package]/[alias] you added your contract with, or its [address]. Note that if you transfer to an incorrect address, you may irreversibly lose control over upgrading your contract.'
const description = 'change upgradeability admin of a contract instance. Provide the [alias] or [package]/[alias] of the contract to change the ownership of all its instances, or its [address] to change a single one. Note that if you transfer to an incorrect address, you may irreversibly lose control over upgrading your contract.'

const register = program => program
.command(signature, { noHelp: true })
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/models/files/ZosNetworkFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export default class ZosNetworkFile {
updateProxy({ package: proxyPackage, contract: proxyContract, address: proxyAddress }, fn) {
const fullname = toContractFullName(proxyPackage, proxyContract)
const index = _.findIndex(this.data.proxies[fullname], { address: proxyAddress })
if (index === -1) throw Error(`Proxy ${fullname} at ${proxyAddress} not found in network manifest`)
if (index === -1) throw Error(`Proxy ${fullname} at ${proxyAddress} not found in network file`)
this.data.proxies[fullname][index] = fn(this.data.proxies[fullname][index]);
}

Expand Down
9 changes: 6 additions & 3 deletions packages/cli/src/models/network/NetworkAppController.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,25 @@ export default class NetworkAppController extends NetworkBaseController {
}

_fetchOwnedProxies(packageName, contractAlias, proxyAddress) {
let criteriaDescription;
if (packageName || contractAlias) criteriaDescription += ` contract ${toContractFullName(packageName, contractAlias)}`
if (proxyAddress) criteriaDescription += ` address ${proxyAddress}`

const proxies = this.networkFile.getProxies({
package: packageName || (contractAlias ? this.packageFile.name : undefined),
contract: contractAlias,
address: proxyAddress
})

if (_.isEmpty(proxies)) {
log.info('No owned contract instances that match were found');
log.info(`No contract instances that match${criteriaDescription} were found`);
return [];
}

const ownedProxies = proxies.filter(proxy => !proxy.admin || proxy.admin === this.appAddress);

if (_.isEmpty(ownedProxies)) {
log.info('No matching contract instances are owned by this application');
return [];
log.info(`No contract instances that match${criteriaDescription} are owned by this application`);
}

return ownedProxies;
Expand Down

0 comments on commit 3664c24

Please sign in to comment.