Skip to content

Commit

Permalink
fix: 1 input/output per ui block in json mode
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbackspace committed Oct 24, 2023
1 parent ae0af89 commit 4016da4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/commands/tx/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const registerTxCommand = (app: App<StringIndexed>) => {

await say({ blocks: [...formattedOutputs] });
} catch (error) {
const errorResponse = BlockfrostClient.handleError(error, 'no');
const errorResponse = BlockfrostClient.handleError(error, txHash);

await say(errorResponse);
}
Expand Down
40 changes: 18 additions & 22 deletions src/utils/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,15 @@ export const formatInputs = (inputs: Responses['tx_content_utxo']['inputs'], jso
} else {
// JSON mode
return [
{
type: 'section',
text: {
type: 'mrkdwn',
text: `*Inputs*\n\`\`\`${JSON.stringify(
inputs.map(input => truncateLongStrings(input)),
undefined,
2,
)}\`\`\``,
},
},
...inputs.map((input, index) => {
return {
type: 'section',
text: {
type: 'mrkdwn',
text: `*Input #${index + 1}*\n\`\`\`${JSON.stringify(input, undefined, 2)}\`\`\``,
},
};
}),
{
type: 'divider',
},
Expand Down Expand Up @@ -173,17 +171,15 @@ export const formatOutputs = (
.flat();
} else {
return [
{
type: 'section',
text: {
type: 'mrkdwn',
text: `*Outputs*\n\`\`\`${JSON.stringify(
outputs.map(output => truncateLongStrings(output)),
undefined,
2,
)}\`\`\``,
},
},
...outputs.map((output, index) => {
return {
type: 'section',
text: {
type: 'mrkdwn',
text: `*Output #${index + 1}*\n\`\`\`${JSON.stringify(output, undefined, 2)}\`\`\``,
},
};
}),
{
type: 'divider',
},
Expand Down

0 comments on commit 4016da4

Please sign in to comment.