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

Implement minor changes on change-admin command #51

Merged
merged 1 commit into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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