Massive changes. I dont know what happens. Rewrote the action wizard again. Fixed several bugs related to the utxo selection. QR codes were added for address. Add support for data results. Experiment with other methods of role extraction
This commit is contained in:
81
src/tui/screens/action-wizard/steps/DataResultStep.tsx
Normal file
81
src/tui/screens/action-wizard/steps/DataResultStep.tsx
Normal file
@@ -0,0 +1,81 @@
|
||||
import React from 'react';
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors } from '../../../theme.js';
|
||||
import type { VariableInput, DataResult } from '../types.js';
|
||||
|
||||
interface DataResultStepProps {
|
||||
actionName: string;
|
||||
variables: VariableInput[];
|
||||
dataResults: DataResult[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the result of a data-only action (e.g. sign, verify).
|
||||
*
|
||||
* NOTE: Engine-level data action execution is not yet implemented.
|
||||
* The computed values are stubbed until the engine supports evaluating
|
||||
* CashASM data expressions outside of a transaction context.
|
||||
*/
|
||||
export function DataResultStep({
|
||||
actionName,
|
||||
variables,
|
||||
dataResults,
|
||||
}: DataResultStepProps): React.ReactElement {
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Text color={colors.primary} bold>
|
||||
{actionName} — Result
|
||||
</Text>
|
||||
|
||||
{/* Variables that were provided */}
|
||||
{variables.length > 0 && (
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text color={colors.text}>Provided values:</Text>
|
||||
{variables.map((v) => (
|
||||
<Text key={v.id} color={colors.textMuted}>
|
||||
{' '}{v.name}: {v.value || '(empty)'}
|
||||
</Text>
|
||||
))}
|
||||
</Box>
|
||||
)}
|
||||
|
||||
{/* Computed data results */}
|
||||
<Box marginTop={1} flexDirection="column">
|
||||
<Text color={colors.text}>Output:</Text>
|
||||
{dataResults.length === 0 ? (
|
||||
<Text color={colors.warning}>
|
||||
{' '}Engine support for data actions is not yet implemented.
|
||||
</Text>
|
||||
) : (
|
||||
dataResults.map((result) => (
|
||||
<Box key={result.id} flexDirection="column" marginTop={0}>
|
||||
<Text color={colors.textMuted}>
|
||||
{' '}{result.name} ({result.type}):
|
||||
</Text>
|
||||
{result.value !== null ? (
|
||||
<Box
|
||||
borderStyle="single"
|
||||
borderColor={colors.primary}
|
||||
paddingX={1}
|
||||
marginLeft={2}
|
||||
>
|
||||
<Text color={colors.accent}>{result.value}</Text>
|
||||
</Box>
|
||||
) : (
|
||||
<Text color={colors.warning} dimColor>
|
||||
{' '}Pending — engine data execution not yet available
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
))
|
||||
)}
|
||||
</Box>
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text color={colors.textMuted} dimColor>
|
||||
Press Done to exit.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors } from '../../../theme.js';
|
||||
import type { WizardStepProps } from '../types.js';
|
||||
|
||||
type Props = Pick<
|
||||
WizardStepProps,
|
||||
'template' | 'actionIdentifier' | 'roleIdentifier' | 'actionName'
|
||||
>;
|
||||
|
||||
export function InfoStep({
|
||||
template,
|
||||
actionIdentifier,
|
||||
roleIdentifier,
|
||||
actionName,
|
||||
}: Props): React.ReactElement {
|
||||
const action = template?.actions?.[actionIdentifier];
|
||||
const role = action?.roles?.[roleIdentifier];
|
||||
|
||||
return (
|
||||
<Box flexDirection='column'>
|
||||
<Text color={colors.primary} bold>
|
||||
Action: {actionName}
|
||||
</Text>
|
||||
<Text color={colors.textMuted}>
|
||||
{action?.description || 'No description'}
|
||||
</Text>
|
||||
|
||||
<Box marginTop={1}>
|
||||
<Text color={colors.text}>Your Role: </Text>
|
||||
<Text color={colors.accent}>{roleIdentifier}</Text>
|
||||
</Box>
|
||||
|
||||
{role?.requirements && (
|
||||
<Box marginTop={1} flexDirection='column'>
|
||||
<Text color={colors.text}>Requirements:</Text>
|
||||
{role.requirements.variables?.map((v) => (
|
||||
<Text key={v} color={colors.textMuted}>
|
||||
{' '}• Variable: {v}
|
||||
</Text>
|
||||
))}
|
||||
{role.requirements.slots && (
|
||||
<Text color={colors.textMuted}>
|
||||
{' '}• Slots: {role.requirements.slots.min} min (UTXO selection
|
||||
required)
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
@@ -1,18 +1,17 @@
|
||||
import React from 'react';
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors, formatSatoshis, formatHex } from '../../../theme.js';
|
||||
import type { WizardStepProps } from '../types.js';
|
||||
import type { SelectableUTXO, FocusArea } from '../types.js';
|
||||
|
||||
type Props = Pick<
|
||||
WizardStepProps,
|
||||
| 'availableUtxos'
|
||||
| 'selectedUtxoIndex'
|
||||
| 'requiredAmount'
|
||||
| 'fee'
|
||||
| 'selectedAmount'
|
||||
| 'changeAmount'
|
||||
| 'focusArea'
|
||||
>;
|
||||
interface Props {
|
||||
availableUtxos: SelectableUTXO[];
|
||||
selectedUtxoIndex: number;
|
||||
requiredAmount: bigint;
|
||||
fee: bigint;
|
||||
selectedAmount: bigint;
|
||||
changeAmount: bigint;
|
||||
focusArea: FocusArea;
|
||||
}
|
||||
|
||||
export function InputsStep({
|
||||
availableUtxos,
|
||||
|
||||
@@ -2,16 +2,15 @@ import React from 'react';
|
||||
import { Box, Text } from 'ink';
|
||||
import { colors } from '../../../theme.js';
|
||||
import { VariableInputField } from '../../../components/VariableInputField.js';
|
||||
import type { WizardStepProps } from '../types.js';
|
||||
import type { VariableInput, FocusArea } from '../types.js';
|
||||
|
||||
type Props = Pick<
|
||||
WizardStepProps,
|
||||
| 'variables'
|
||||
| 'updateVariable'
|
||||
| 'handleTextInputSubmit'
|
||||
| 'focusArea'
|
||||
| 'focusedInput'
|
||||
>;
|
||||
interface Props {
|
||||
variables: VariableInput[];
|
||||
updateVariable: (index: number, value: string) => void;
|
||||
handleTextInputSubmit: () => void;
|
||||
focusArea: FocusArea;
|
||||
focusedInput: number;
|
||||
}
|
||||
|
||||
export function VariablesStep({
|
||||
variables,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export * from './InfoStep.js';
|
||||
export * from './RoleSelectStep.js';
|
||||
export * from './VariablesStep.js';
|
||||
export * from './InputsStep.js';
|
||||
export * from './ReviewStep.js';
|
||||
export * from './PublishStep.js';
|
||||
export * from './PublishStep.js';
|
||||
export * from './DataResultStep.js';
|
||||
|
||||
Reference in New Issue
Block a user