diff --git a/cmds/list_cmds/details.js b/cmds/list_cmds/details.js new file mode 100644 index 0000000..1dc1171 --- /dev/null +++ b/cmds/list_cmds/details.js @@ -0,0 +1,52 @@ +const ob = require('urbit-ob') +const ajs = require('azimuth-js') +const {validate, eth} = require('../../utils') + +exports.command = 'details ' +exports.desc = 'Outputs various information about a . Such as owner and proxy addresses.' +exports.builder = (yargs) =>{ +} + +exports.handler = async function (argv) { + const ctx = await eth.createContext(argv); + const p = validate.point(argv.point, true); + const patp = ob.patp(p); + console.log(`urbit ID (patp): ${patp}`); + console.log(`urbit ID number (p): ${p}`); + + const shipType = ob.clan(patp); + console.log(`ship type: ${shipType}`); + + const parentPatp = ob.sein(patp); + const parentP = ob.patp2dec(parentPatp); + console.log(`parent: ${parentPatp}`); + + const sponsorP = await ajs.azimuth.getSponsor(ctx.contracts, p); + const sponsorPatp = ob.patp(sponsorP); + const hasSponsor = await ajs.azimuth.hasSponsor(ctx.contracts, p); + console.log(`sponsor: ${hasSponsor ? sponsorPatp : 'null'}`); + + const ownerAddress = sanitizeAddress(await ajs.azimuth.getOwner(ctx.contracts, p)); + console.log(`owner address: ${ownerAddress}`); + + const spawnProxyAddress = sanitizeAddress(await ajs.azimuth.getSpawnProxy(ctx.contracts, p)); + console.log(`spawn proxy address: ${spawnProxyAddress}`); + + const networkKeysSet = await ajs.azimuth.hasBeenLinked(ctx.contracts, p); + console.log(`network keys set: ${networkKeysSet}`); + const networkKeysRevision = await ajs.azimuth.getKeyRevisionNumber(ctx.contracts, p); + console.log(`network keys revision: ${networkKeysRevision}`); + + const continuityNumber = await ajs.azimuth.getContinuityNumber(ctx.contracts, p); + console.log(`continuity number: ${continuityNumber}`); + + const spawnedChildrenCount = await ajs.azimuth.getSpawnCount(ctx.contracts, p); + console.log(`spawned children: ${spawnedChildrenCount}`); +} + +function sanitizeAddress(address){ + if(address && !ajs.utils.addressEquals('0x0000000000000000000000000000000000000000', address)){ + return address.toLowerCase(); + } + return null; +} \ No newline at end of file diff --git a/cmds/list_cmds/owner-of.js b/cmds/list_cmds/owner-of.js deleted file mode 100644 index 7de030e..0000000 --- a/cmds/list_cmds/owner-of.js +++ /dev/null @@ -1,21 +0,0 @@ -const ob = require('urbit-ob') -const ajs = require('azimuth-js') -const {validate, eth} = require('../../utils') - -exports.command = 'owner-of ' -exports.desc = 'Outputs the owner address of the provided .' -exports.builder = (yargs) =>{ -} - -exports.handler = async function (argv) { - const point = validate.point(argv.point, true); - const ctx = await eth.createContext(argv); - const ownerAddress = await ajs.azimuth.getOwner(ctx.contracts, point); - - if(ownerAddress && !ajs.utils.addressEquals('0x0000000000000000000000000000000000000000', ownerAddress)){ - console.log(ownerAddress.toLowerCase()); - } - else{ - console.log(`Point ${ob.patp(point)} (${point}) not yet spawned.`) - } -} \ No newline at end of file diff --git a/cmds/list_cmds/spawn-proxy-of.js b/cmds/list_cmds/spawn-proxy-of.js deleted file mode 100644 index ca4d63f..0000000 --- a/cmds/list_cmds/spawn-proxy-of.js +++ /dev/null @@ -1,21 +0,0 @@ -const ob = require('urbit-ob') -const ajs = require('azimuth-js') -const {validate, eth} = require('../../utils') - -exports.command = 'spawn-proxy-of ' -exports.desc = 'Outputs the spawn proxy address of the provided .' -exports.builder = (yargs) =>{ -} - -exports.handler = async function (argv) { - const point = validate.point(argv.point, true); - const ctx = await eth.createContext(argv); - const spawnProxyAddress = await ajs.azimuth.getSpawnProxy(ctx.contracts, point); - - if(spawnProxyAddress && !ajs.utils.addressEquals('0x0000000000000000000000000000000000000000', spawnProxyAddress)){ - console.log(spawnProxyAddress.toLowerCase()); - } - else{ - console.log(`Point ${ob.patp(point)} (${point}) does not have a spawn proxy set.`) - } -} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 0a8de69..a0f01c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "azimuth-cli", - "version": "0.1.0", + "version": "0.1.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/test/test.js b/test/test.js index 25e0de5..6e768dd 100644 --- a/test/test.js +++ b/test/test.js @@ -211,27 +211,10 @@ describe('#list', async function() { }); }); - describe('owner-of zod', async function() { - it('should list owner address of zod', async function() { - let output = await execCliAndGetLines('list', 'owner-of', galaxy, ...baseArgs); - expect(output).to.have.lengthOf(1); - assert.isTrue(ajs.utils.addressEquals(output[0], ac0), `output addr: ${output[0]}, owner addr: ${ac0}`); - }); - }); - - describe('owner-of unspawned', async function() { - it('should say that there is no owner yet', async function() { - let output = await execCliAndGetLines('list', 'owner-of', planet1d, ...baseArgs); - expect(output).to.have.lengthOf(1); - assert.isTrue(output[0].startsWith('Point'), `output: ${output[0]}`); - }); - }); - - describe('spawn-proxy-of zod', async function() { - it('should say that there is no spawn proxy set', async function() { - let output = await execCliAndGetLines('list', 'spawn-proxy-of', galaxy, ...baseArgs); - expect(output).to.have.lengthOf(1); - assert.isTrue(output[0].startsWith('Point'), `output: ${output[0]}`); + describe('details zod', async function() { + it('should list details about zod', async function() { + let output = await execCliAndGetLines('list', 'details', galaxy, ...baseArgs); + expect(output).to.have.lengthOf.at.least(10); }); });