Skip to content

Commit

Permalink
chore(agoric-cli): Condense agoric wallet show output (#10519)
Browse files Browse the repository at this point in the history
## Description
Render empty purses/usedInvitations/offers on one line rather than three:
```diff
 {
   "purses": [
     ["board0074",0]
   ],
-  "usedInvitations": [
-
-  ],
-  "offers": [
-
-  ]
+  "usedInvitations": [],
+  "offers": []
 }
```

### Security Considerations
n/a

### Scaling Considerations
n/a

### Documentation Considerations
n/a

### Testing Considerations
n/a

### Upgrade Considerations
We don't guarantee stability of the output AFAIK, and I'm not aware of anything that depends upon it.
  • Loading branch information
gibson042 authored Nov 20, 2024
1 parent 8c79835 commit 3ba7ca7
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 3ba7ca7

Please sign in to comment.