Format with prettier. Use screen mode for invitation import - dialog mode is broken.
This commit is contained in:
@@ -15,7 +15,6 @@ export function FetchInvitationStep({
|
||||
invitationId,
|
||||
appService,
|
||||
onComplete,
|
||||
onCancel,
|
||||
isActive,
|
||||
}: FetchStepProps): React.ReactElement {
|
||||
const [status, setStatus] = useState<'loading' | 'error'>('loading');
|
||||
|
||||
@@ -22,8 +22,6 @@ const DUST_THRESHOLD = 546n;
|
||||
|
||||
export function InputsSelectStep({
|
||||
invitation,
|
||||
template,
|
||||
selectedRole,
|
||||
appService,
|
||||
onComplete,
|
||||
onCancel,
|
||||
@@ -93,8 +91,6 @@ export function InputsSelectStep({
|
||||
outputIdentifiers.add(output.output);
|
||||
}
|
||||
|
||||
console.log('outputIdentifiers', Array.from(outputIdentifiers));
|
||||
|
||||
// Create a map of the utxoID to suitable resource
|
||||
const utxoIdToSuitableResource = new Map<string, UnspentOutputData>();
|
||||
for (const outputIdentifier of outputIdentifiers) {
|
||||
@@ -102,14 +98,11 @@ export function InputsSelectStep({
|
||||
|
||||
outputIdentifier,
|
||||
});
|
||||
console.log('suitableResources', outputIdentifier, JSON.stringify(suitableResources, null, 2));
|
||||
for (const suitableResource of suitableResources) {
|
||||
utxoIdToSuitableResource.set(suitableResource.outpointTransactionHash + ':' + suitableResource.outpointIndex, suitableResource);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('utxoIdToSuitableResource', JSON.stringify(utxoIdToSuitableResource, null, 2));
|
||||
|
||||
const selectable = mapUnspentOutputsToSelectable(Array.from(utxoIdToSuitableResource.values()));
|
||||
const autoSelected = autoSelectGreedyUtxos(selectable, required + fee);
|
||||
setUtxos(autoSelected as SelectableUTXO[]);
|
||||
@@ -155,7 +148,7 @@ export function InputsSelectStep({
|
||||
setUtxos(prev => prev.map(u => ({ ...u, selected: true })));
|
||||
} else if (input === 'n') {
|
||||
setUtxos(prev => prev.map(u => ({ ...u, selected: false })));
|
||||
} else if (key.tab) {
|
||||
} else if (key.return) {
|
||||
if (hasEnough) {
|
||||
onComplete(utxos.filter(u => u.selected));
|
||||
}
|
||||
@@ -239,7 +232,7 @@ export function InputsSelectStep({
|
||||
{/* Navigation hint */}
|
||||
<Box marginTop={1}>
|
||||
<Text color={colors.textMuted}>
|
||||
↑↓: Navigate • Space: Toggle • a: All • n: None • Tab: Confirm • Esc: Cancel
|
||||
↑↓: Navigate • Space: Toggle • a: All • n: None • return: Confirm • Esc: Cancel
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -108,21 +108,23 @@ export function PreviewInvitationStep({
|
||||
<Text color={colors.primary} bold>Roles Filled ({filledRoles.size}):</Text>
|
||||
</Box>
|
||||
|
||||
{filledRoles.size === 0 ? (
|
||||
<Box>
|
||||
<Text color={colors.textMuted}> None yet</Text>
|
||||
</Box>
|
||||
) : (
|
||||
Array.from(filledRoles).map(role => {
|
||||
const roleInfoRaw = template?.roles?.[role];
|
||||
const roleInfo = roleInfoRaw && typeof roleInfoRaw === 'object' ? roleInfoRaw : null;
|
||||
return (
|
||||
<Box key={role}>
|
||||
<Text color={colors.text}> • {roleInfo?.name ?? role}</Text>
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
<Box marginLeft={1}>
|
||||
{filledRoles.size === 0 ? (
|
||||
<Box>
|
||||
<Text color={colors.textMuted}> None yet</Text>
|
||||
</Box>
|
||||
) : (
|
||||
Array.from(filledRoles).map(role => {
|
||||
const roleInfoRaw = template?.roles?.[role];
|
||||
const roleInfo = roleInfoRaw && typeof roleInfoRaw === 'object' ? roleInfoRaw : null;
|
||||
return (
|
||||
<Box key={role}>
|
||||
<Text color={colors.text}> • {roleInfo?.name ?? role}</Text>
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Inputs */}
|
||||
@@ -131,48 +133,52 @@ export function PreviewInvitationStep({
|
||||
<Text color={colors.primary} bold>Inputs ({inputs.length}):</Text>
|
||||
</Box>
|
||||
|
||||
{inputs.length === 0 ? (
|
||||
<Box>
|
||||
<Text color={colors.textMuted}> None yet</Text>
|
||||
</Box>
|
||||
) : (
|
||||
inputs.map((input, idx) => {
|
||||
const inputTemplate = template?.inputs?.[input.inputIdentifier ?? ''];
|
||||
return (
|
||||
<Box key={`input-${idx}`}>
|
||||
<Text color={colors.text}>
|
||||
{' '}• {inputTemplate?.name ?? input.inputIdentifier ?? `Input ${idx}`}
|
||||
{input.roleIdentifier && ` (${input.roleIdentifier})`}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
<Box marginLeft={1}>
|
||||
{inputs.length === 0 ? (
|
||||
<Box>
|
||||
<Text color={colors.textMuted}> None yet</Text>
|
||||
</Box>
|
||||
) : (
|
||||
inputs.map((input, idx) => {
|
||||
const inputTemplate = template?.inputs?.[input.inputIdentifier ?? ''];
|
||||
return (
|
||||
<Box key={`input-${idx}`}>
|
||||
<Text color={colors.text}>
|
||||
{' '}• {inputTemplate?.name ?? input.inputIdentifier ?? `Input ${idx}`}
|
||||
{input.roleIdentifier && ` (${input.roleIdentifier})`}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Outputs */}
|
||||
<Box flexDirection="column" marginBottom={1}>
|
||||
<Box flexDirection="column" marginBottom={1} marginLeft={1}>
|
||||
<Box>
|
||||
<Text color={colors.primary} bold>Outputs ({outputs.length}):</Text>
|
||||
</Box>
|
||||
|
||||
{outputs.length === 0 ? (
|
||||
<Box>
|
||||
<Text color={colors.textMuted}> None yet</Text>
|
||||
</Box>
|
||||
) : (
|
||||
outputs.map((output, idx) => {
|
||||
const outputTemplate = template?.outputs?.[output.outputIdentifier ?? ''];
|
||||
return (
|
||||
<Box key={`output-${idx}`}>
|
||||
<Text color={colors.text}>
|
||||
{' '}• {outputTemplate?.name ?? output.outputIdentifier ?? `Output ${idx}`}
|
||||
{output.valueSatoshis !== undefined && ` (${formatSatoshis(output.valueSatoshis)})`}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
<Box marginLeft={1}>
|
||||
{outputs.length === 0 ? (
|
||||
<Box>
|
||||
<Text color={colors.textMuted}>None yet</Text>
|
||||
</Box>
|
||||
) : (
|
||||
outputs.map((output, idx) => {
|
||||
const outputTemplate = template?.outputs?.[output.outputIdentifier ?? ''];
|
||||
return (
|
||||
<Box key={`output-${idx}`}>
|
||||
<Text color={colors.text}>
|
||||
{' '}• {outputTemplate?.name ?? output.outputIdentifier ?? `Output ${idx}`}
|
||||
{output.valueSatoshis !== undefined && ` (${formatSatoshis(output.valueSatoshis)})`}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Variables */}
|
||||
@@ -181,25 +187,27 @@ export function PreviewInvitationStep({
|
||||
<Text color={colors.primary} bold>Variables ({variables.length}):</Text>
|
||||
</Box>
|
||||
|
||||
{variables.length === 0 ? (
|
||||
<Box>
|
||||
<Text color={colors.textMuted}> None set</Text>
|
||||
</Box>
|
||||
) : (
|
||||
variables.map((variable, idx) => {
|
||||
const varTemplate = template?.variables?.[variable.variableIdentifier];
|
||||
const displayValue = typeof variable.value === 'bigint'
|
||||
? variable.value.toString()
|
||||
: String(variable.value);
|
||||
return (
|
||||
<Box key={`var-${idx}`}>
|
||||
<Text color={colors.text}>
|
||||
{' '}• {varTemplate?.name ?? variable.variableIdentifier}: {displayValue}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
<Box marginLeft={1}>
|
||||
{variables.length === 0 ? (
|
||||
<Box>
|
||||
<Text color={colors.textMuted}> None set</Text>
|
||||
</Box>
|
||||
) : (
|
||||
variables.map((variable, idx) => {
|
||||
const varTemplate = template?.variables?.[variable.variableIdentifier];
|
||||
const displayValue = typeof variable.value === 'bigint'
|
||||
? variable.value.toString()
|
||||
: String(variable.value);
|
||||
return (
|
||||
<Box key={`var-${idx}`}>
|
||||
<Text color={colors.text}>
|
||||
{' '}• {varTemplate?.name ?? variable.variableIdentifier}: {displayValue}
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Navigation hint */}
|
||||
|
||||
@@ -26,7 +26,6 @@ export function ReviewStep({
|
||||
selectedInputs,
|
||||
requiredAmount,
|
||||
changeAmount,
|
||||
appService,
|
||||
onComplete,
|
||||
onCancel,
|
||||
isActive,
|
||||
|
||||
Reference in New Issue
Block a user