diff --git a/flake.lock b/flake.lock index b58db61..d6e39f9 100644 --- a/flake.lock +++ b/flake.lock @@ -123,16 +123,16 @@ "holochain": { "flake": false, "locked": { - "lastModified": 1715129891, - "narHash": "sha256-M+AoE56LNvtoP7EP+XBI9GaMEKoJ9aeslGHw3WKPB0I=", + "lastModified": 1719968525, + "narHash": "sha256-smpK/6bTj6rz4L5JE4LNEPXKS2FHX9TuMj2hg473ggI=", "owner": "holochain", "repo": "holochain", - "rev": "6e9dbbedc4879cf344c5fc9a324e5ce025048405", + "rev": "31c75c07234a573b18f07cb05c2961809bf1c0a1", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.3.1-rc.2", + "ref": "holochain-0.4.0-dev.11", "repo": "holochain", "type": "github" } @@ -172,11 +172,11 @@ ] }, "locked": { - "lastModified": 1719428453, - "narHash": "sha256-5D7P1kN0hSiWKdGzk6b2Zoi3bh+o2tHm9c7CVVbnIMk=", + "lastModified": 1721160188, + "narHash": "sha256-Qqofmd/S4hN4ONLzUB01OTjJB/P+3PzrXvmV4Y4v2Ww=", "owner": "holochain", "repo": "holochain", - "rev": "75af8c2b73d36bbb14b16a8834e19e7d884fbf04", + "rev": "2c02d515391e664918e8b2395a1dde9a1b1519fe", "type": "github" }, "original": { @@ -188,16 +188,16 @@ "lair": { "flake": false, "locked": { - "lastModified": 1709335027, - "narHash": "sha256-rKMhh7TLuR1lqze2YFWZCGYKZQoB4dZxjpX3sb7r7Jk=", + "lastModified": 1717684904, + "narHash": "sha256-vcXt67Tl1qwVUkx8CBevdQocqZXUEeoXjaYw86ljsYo=", "owner": "holochain", "repo": "lair", - "rev": "826be915efc839d1d1b8a2156b158999b8de8d5b", + "rev": "6a84ed490fc7074d107e38bbb4a8d707e9b8e066", "type": "github" }, "original": { "owner": "holochain", - "ref": "lair_keystore-v0.4.4", + "ref": "lair_keystore-v0.4.5", "repo": "lair", "type": "github" } @@ -205,16 +205,16 @@ "launcher": { "flake": false, "locked": { - "lastModified": 1717431387, - "narHash": "sha256-+VvWwBmxcgePV1L6kU2mSkg3emMiMgpdQnCqvQJkRPk=", + "lastModified": 1715106263, + "narHash": "sha256-a7iQ8pKGz6fghJrtXq0Xamp57GE8Hd3w5YQASzz5Wlk=", "owner": "holochain", "repo": "launcher", - "rev": "9d9cab5e6b57e1c278113921ff203e515c8bbd2e", + "rev": "92bd39e1c66912d61c35c4725d7b106959888670", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.3", + "ref": "holochain-weekly", "repo": "launcher", "type": "github" } @@ -317,11 +317,11 @@ ] }, "locked": { - "lastModified": 1719109180, - "narHash": "sha256-96dwGCV2yQxDozDATqbsM3YU0ft3Isw3cwVDO/eNCv8=", + "lastModified": 1720923816, + "narHash": "sha256-GrDL1nFYZrB/+Ah1hNoaNFfduB1agpfqL9QyEl12UOU=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "5fc5f3a0d7eabf7db86851e6423f9d7fbceaf89d", + "rev": "fb8c8be0313f0e6385b3d70151a04ea1d71e4b68", "type": "github" }, "original": { @@ -333,16 +333,16 @@ "scaffolding": { "flake": false, "locked": { - "lastModified": 1717661456, - "narHash": "sha256-e+9YRRFJg89rfHDWtumEa33rpa2vmij/zw7Uwl6BP/g=", + "lastModified": 1720709716, + "narHash": "sha256-JrUNDbAiSPl11L8JxtgNfKXV13bWgCD+Xd0hNy8nK9A=", "owner": "holochain", "repo": "scaffolding", - "rev": "1ffc9eb350b82784a8fb609073f1c7eccf2e0fc0", + "rev": "3241aaaf52589ced9e29bf616407b867f6927c44", "type": "github" }, "original": { "owner": "holochain", - "ref": "holochain-0.3", + "ref": "holochain-weekly", "repo": "scaffolding", "type": "github" } @@ -355,16 +355,16 @@ "scaffolding": "scaffolding" }, "locked": { - "dir": "versions/0_3_rc", - "lastModified": 1719428453, - "narHash": "sha256-5D7P1kN0hSiWKdGzk6b2Zoi3bh+o2tHm9c7CVVbnIMk=", + "dir": "versions/weekly", + "lastModified": 1721160188, + "narHash": "sha256-Qqofmd/S4hN4ONLzUB01OTjJB/P+3PzrXvmV4Y4v2Ww=", "owner": "holochain", "repo": "holochain", - "rev": "75af8c2b73d36bbb14b16a8834e19e7d884fbf04", + "rev": "2c02d515391e664918e8b2395a1dde9a1b1519fe", "type": "github" }, "original": { - "dir": "versions/0_3_rc", + "dir": "versions/weekly", "owner": "holochain", "repo": "holochain", "type": "github" diff --git a/flake.nix b/flake.nix index be81f6b..6180bf6 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,8 @@ description = "Template for Holochain app development"; inputs = { - versions.url = "github:holochain/holochain?dir=versions/0_3_rc"; - versions.inputs.holochain.url = "github:holochain/holochain/holochain-0.4.0-dev.2"; + versions.url = "github:holochain/holochain?dir=versions/weekly"; + versions.inputs.holochain.url = "github:holochain/holochain/holochain-0.4.0-dev.11"; holochain-flake.url = "github:holochain/holochain"; holochain-flake.inputs.versions.follows = "versions"; @@ -26,7 +26,7 @@ }: { devShells.default = pkgs.mkShell { - inputsFrom = [ inputs'.holochain-flake.devShells.holonix ]; + inputsFrom = [ inputs'.holochain-flake.devShells.holochainBinaries ]; packages = [ pkgs.nodejs-18_x pkgs.binaryen diff --git a/src/index.js b/src/index.js index 6062abd..612fbcf 100644 --- a/src/index.js +++ b/src/index.js @@ -11,6 +11,7 @@ import { installApp, enableApp, appInfo, + dumpNetworkStats, zomeCall } from './utils' import path from 'path' @@ -184,6 +185,22 @@ export async function getArgs () { logResult(result) }) + program + .command('dumpNetworkStats') + .alias('ns') + .description( + 'dump network state for app: calls dumpNetworkStats() -> [DumpNetworkStats: any]' + ) + .action(async () => { + const result = await call_admin_port( + dumpNetworkStats, + program.opts().adminPort, + ) + console.log('Network State Dump for DNA:') + logResult(result) + }) + + program .command('installApp ') .alias('b') diff --git a/src/utils.js b/src/utils.js index 63ef47e..b2ab147 100644 --- a/src/utils.js +++ b/src/utils.js @@ -204,67 +204,6 @@ export const listEnabledApps = async (adminWebsocket) => { return result } -/** - * Dumps state of holochain for given cell id in a pretty format - * @param {CellID | int} cellIdArg - * @returns string - */ -export const dumpState = async (adminWebsocket, cellIdArg) => { - console.log('cell Id Arg : ', cellIdArg) - if (!cellIdArg) throw new Error('No cell_id passed.') - let cellId - - const index = parseInt(cellIdArg) - if (`${index}` === cellIdArg) { - // arg is a index so get cell ID list from conductor - const result = await adminWebsocket.listCellIds() - if (Array.isArray(result)) { - if (index >= result.length) { - return `CellId index (zero based) provided was ${index}, but there are only ${result.length} cell(s)` - } - cellId = result[index] - } else { - return `Expected array from listCellIds() got: ${result}` - } - } else { - // Convert cellIdArg into array format to satisfy dumpState arg type - cellId = cellIdArg.split(',') - if (Array.isArray(cellId)) { - cellId[0] = Buffer.from(cellId[0], 'base64') - cellId[1] = Buffer.from(cellId[1], 'base64') - } else { - throw new Error( - 'Error parsing cell_id: cell_id should be an array [DnaHashBase64, AgentPubKeyBase64]' - ) - } - } - - console.log('CellId in Buffer format : ', cellId) - if (cellId.length !== 2) { - throw new Error( - 'cell_id is in improper format. Make sure both the dna and agent hash are passed as a single, non-spaced array.' - ) - } else if (cellId[0].length !== 39 || cellId[1].length !== 39) { - throw new Error( - 'cell_id contains a hash of improper length. Make sure both the dna and agent hash are passed as a single, non-spaced array.' - ) - } - let stateDump - try { - stateDump = await adminWebsocket.dumpState({ - cell_id: cellId - }) - } catch (error) { - throw new Error(`${JSON.stringify(error)}`) - } - // Replace all the buffers with byte64 representations - const result = stringifyBuffRec(stateDump) - return ( - JSON.stringify(result, null, 4) + - `\n\nTotal Elements in Dump: ${stateDump.length}` - ) -} - /** * Call installApp for app bundle * @param {obj} installAppArgs @@ -371,3 +310,17 @@ export const zomeCall = async (appWebsocket, args) => { } return result } + +/** + * Dumps network state of holochain + * @returns string + */ +export const dumpNetworkStats = async (adminWebsocket) => { + let result + try { + result = await adminWebsocket.dumpNetworkStats() + } catch (error) { + return error + } + return result +} \ No newline at end of file