Skip to content

Commit

Permalink
chore(agoric-cli): Condense agoric wallet show output
Browse files Browse the repository at this point in the history
Render empty purses/usedInvitations/offers on one line rather than three:
```diff
 {
   "purses": [
     ["board0074",0]
   ],
-  "usedInvitations": [
-
-  ],
-  "offers": [
-
-  ]
+  "usedInvitations": [],
+  "offers": []
 }
```
  • Loading branch information
gibson042 committed Nov 19, 2024
1 parent 23e127e commit 83298e2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/agoric-cli/src/lib/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ export const purseBalanceTuples = (purses, assets) => {
*/
export const fmtRecordOfLines = record => {
const { stringify } = JSON;
/** @type {Array<[string, string[]]>} */
const groups = Object.entries(record).map(([key, items]) => [
key,
items.map(item => ` ${stringify(item)}`),
]);
const lineEntries = groups.map(
// @ts-expect-error ???
([key, lines]) => ` ${stringify(key)}: [\n${lines.join(',\n')}\n ]`,
);
const lineEntries = groups.map(([key, lines]) => {
const linesStr = lines.length === 0 ? `[]` : `[\n${lines.join(',\n')}\n ]`;
return ` ${stringify(key)}: ${linesStr}`;
});
return `{\n${lineEntries.join(',\n')}\n}`;
};

Expand Down

0 comments on commit 83298e2

Please sign in to comment.