Skip to content

Commit

Permalink
azimuth: add missing getManagementProxy
Browse files Browse the repository at this point in the history
  • Loading branch information
pkova committed Feb 7, 2022
1 parent 07b950f commit 97d227f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
29 changes: 24 additions & 5 deletions azimuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,13 +461,32 @@ const getOwnedPointCount = internal.getOwnedPointCount;
const getOwnedPointAtIndex = internal.getOwnedPointAtIndex;

/**
* Check if an address is a manager for an owner.
* Check if an address is a management proxy for a point.
* @param {Object} contracts - An Urbit contracts object.
* @param {String} owner - The owner's address.
* @param {String} manager - The manager's address.
* @return {Promise<Bool>} True if the address is a manager, false otherwise.
* @param {Number | Object} point - Point number or point object.
* @param {String} address - Target address.
* @return {Promise<Bool>} True if address is management proxy, false otherwise.
*/
function isManagementProxy(contracts, point, address) {
if (typeof point === 'object') {
return utils.addressEquals(point.managementProxy, address);
}
return internal.isManagementProxy(contracts, point, address);
}

/**
* Get the management proxy for a point.
* @param {Object} contracts - An Urbit contracts object.
* @param {Number | Object} point - Point number or point object.
* @return {Promise<String>} The management proxy's address.
*/
const isManagementProxy = internal.isManagementProxy;
function getManagementProxy(contracts, point) {
if (typeof point === 'object') {
return point.managementProxy;
}
return internal.getManagementProxy(contracts, point);
}


/**
* Check if an address can manage a point.
Expand Down
3 changes: 3 additions & 0 deletions internal/azimuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ module.exports.getOwner = (contracts, point) =>
module.exports.isManagementProxy = (contracts, owner, manager) =>
contracts.azimuth.methods.isManagementProxy(owner, manager).call()

module.exports.getManagementProxy = (contracts, point) =>
contracts.azimuth.methods.getManagementProxy(point).call()

module.exports.canManage = (contracts, point, address) =>
contracts.azimuth.methods.canManage(point, address).call()

Expand Down
1 change: 1 addition & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ function main() {
await sendTransaction(web3, tx, pk0);

can(await check.canConfigureKeys(contracts, galaxy, ac1));
assert.isTrue(await azimuth.isManagementProxy(contracts, galaxy, ac1));
});

});
Expand Down

0 comments on commit 97d227f

Please sign in to comment.