Fix build issues

This commit is contained in:
2026-05-04 05:04:28 +00:00
parent ccfaf3fd70
commit 6196d33b2a
8 changed files with 56 additions and 33 deletions

View File

@@ -5,10 +5,11 @@
### Full Installation ### Full Installation
```bash ```bash
# Create a new directory since we are going to be pulling in engine too # Create a new directory since we are going to be pulling in engine too
mdkir xo-terminal && cd xo-terminal mkdir xo-terminal && cd xo-terminal
# Clone the Engine Repo # ----- Start Engine Setup -----
git clone git@gitlab.com:GeneralProtocols/xo/engine.git # Clone the Engine Repo (Note, this uses harvey's fork of the engine repo to access the cli-test branch)
git clone git@gitlab.com:Harvmaster/engine.git
# Move into teh engine directory # Move into teh engine directory
cd engine cd engine
@@ -21,10 +22,31 @@ npm ci
# Build the engine # Build the engine
npm run build npm run build
# ----- End Engine Setup -----
# Move back to the top level directory # Move back to the top level directory
cd .. cd ..
# ----- Start State Setup -----
# Clone the State Repo
git clone git@gitlab.com:Harvmaster/state.git
# Move into the state directory
cd state
git checkout in-memory-adapter
# Install the dependencies
npm ci
# Build the state
npm run build
# ----- End State Setup -----
# Move back to the top level directory
cd ..
# ----- Start CLI Setup -----
# Clone the CLI Repo # Clone the CLI Repo
git clone git@git.harvmaster.com:Harvmaster/xo-cli.git git clone git@git.harvmaster.com:Harvmaster/xo-cli.git
@@ -36,6 +58,7 @@ npm ci
# Build the cli # Build the cli
npm run build npm run build
# ----- End CLI Setup -----
``` ```
### Install globally ### Install globally

View File

@@ -138,7 +138,7 @@ export class HistoryService {
utxo.outpointIndex, utxo.outpointIndex,
); );
ownOutpoints.add(outpointKey); ownOutpoints.add(outpointKey);
ownLockingBytecodes.add(utxo.lockingBytecode); ownLockingBytecodes.add(utxo.scriptHash);
outpointValueSatoshis.set(outpointKey, BigInt(utxo.valueSatoshis)); outpointValueSatoshis.set(outpointKey, BigInt(utxo.valueSatoshis));
} }
@@ -521,7 +521,7 @@ export class HistoryService {
const originKey = this.getUtxoOriginKey( const originKey = this.getUtxoOriginKey(
utxo.templateIdentifier, utxo.templateIdentifier,
utxo.outputIdentifier, utxo.outputIdentifier,
utxo.lockingBytecode, utxo.scriptHash,
); );
return invitationByUtxoOrigin.get(originKey)?.invitationIdentifier; return invitationByUtxoOrigin.get(originKey)?.invitationIdentifier;
} }
@@ -533,7 +533,7 @@ export class HistoryService {
const originKey = this.getUtxoOriginKey( const originKey = this.getUtxoOriginKey(
utxo.templateIdentifier, utxo.templateIdentifier,
utxo.outputIdentifier, utxo.outputIdentifier,
utxo.lockingBytecode, utxo.scriptHash,
); );
return invitationByUtxoOrigin.get(originKey)?.roleIdentifier; return invitationByUtxoOrigin.get(originKey)?.roleIdentifier;
} }

View File

@@ -100,8 +100,8 @@ export function TemplateListScreen(): React.ReactElement {
for (const startingAction of rawStartingActions) { for (const startingAction of rawStartingActions) {
const existing = actionMap.get(startingAction.action); const existing = actionMap.get(startingAction.action);
if (existing) { if (existing) {
if (!existing.roles.includes(startingAction.role)) { if (!existing.roles.includes(startingAction.role ?? '')) {
existing.roles.push(startingAction.role); existing.roles.push(startingAction.role ?? '');
} }
continue; continue;
} }
@@ -111,7 +111,7 @@ export function TemplateListScreen(): React.ReactElement {
actionIdentifier: startingAction.action, actionIdentifier: startingAction.action,
name: actionDef?.name || startingAction.action, name: actionDef?.name || startingAction.action,
description: actionDef?.description, description: actionDef?.description,
roles: [startingAction.role], roles: [startingAction.role ?? ''],
source: 'starting', source: 'starting',
}); });
} }
@@ -119,9 +119,9 @@ export function TemplateListScreen(): React.ReactElement {
const ownedOutputIdentifiers = ownedOutputsByTemplate.get(templateIdentifier) ?? new Set<string>(); const ownedOutputIdentifiers = ownedOutputsByTemplate.get(templateIdentifier) ?? new Set<string>();
for (const outputIdentifier of ownedOutputIdentifiers) { for (const outputIdentifier of ownedOutputIdentifiers) {
const outputDef = template.outputs?.[outputIdentifier]; const outputDef = template.outputs?.[outputIdentifier];
if (!outputDef || typeof outputDef.lockscript !== 'string') continue; if (!outputDef || typeof outputDef.lockingScript !== 'string') continue;
const lockingScriptDefinition = (template.lockingScripts as Record<string, unknown> | undefined)?.[outputDef.lockscript] as const lockingScriptDefinition = (template.lockingScripts as Record<string, unknown> | undefined)?.[outputDef.lockingScript] as
| { roles?: Record<string, { actions?: Array<{ action?: string; role?: string } | string> }> } | { roles?: Record<string, { actions?: Array<{ action?: string; role?: string } | string> }> }
| undefined; | undefined;
if (!lockingScriptDefinition?.roles) continue; if (!lockingScriptDefinition?.roles) continue;

View File

@@ -15,7 +15,7 @@ export { DataWizardFlow } from "./DataWizardFlow.js";
*/ */
export function createWizardFlow(action: XOTemplateAction): WizardFlow { export function createWizardFlow(action: XOTemplateAction): WizardFlow {
if (action.data?.length && !action.transaction) { if (action.data?.length && !action.transaction) {
return new DataWizardFlow(action.data); return new DataWizardFlow([action.data]);
} }
return new TransactionWizardFlow(); return new TransactionWizardFlow();
} }

View File

@@ -61,13 +61,16 @@ export function RoleSelectStep({
{availableRoles.length === 0 ? ( {availableRoles.length === 0 ? (
<Text color={colors.textMuted}>No roles available</Text> <Text color={colors.textMuted}>No roles available</Text>
) : ( ) : (
availableRoles.map((roleId, index) => { availableRoles.map((roleId: string, index: number) => {
const isCursor = const isCursor =
selectedRoleIndex === index && focusArea === 'content'; selectedRoleIndex === index && focusArea === 'content';
const roleDef = template.roles?.[roleId]; const roleDef = template.roles?.[roleId];
const actionRole = action?.roles?.[roleId]; const actionRole = action?.roles?.[roleId];
const requirements = actionRole?.requirements; const requirements = actionRole?.requirements;
const actionRequirements = action?.requirements;
const actionRoleRequirements = actionRole && actionRequirements && actionRequirements.participants?.find((participant) => participant.role === roleId);
return ( return (
<Box key={roleId} flexDirection="column" marginY={0}> <Box key={roleId} flexDirection="column" marginY={0}>
<Text <Text
@@ -96,10 +99,10 @@ export function RoleSelectStep({
{' '} {' '}
</Text> </Text>
)} )}
{requirements.slots && requirements.slots.min > 0 && ( {actionRoleRequirements && actionRoleRequirements.slots && actionRoleRequirements.slots.min > 0 && (
<Text color={colors.textMuted} dimColor> <Text color={colors.textMuted} dimColor>
{requirements.slots.min} input slot {actionRoleRequirements.slots.min} input slot
{requirements.slots.min !== 1 ? 's' : ''} {actionRoleRequirements.slots.min !== 1 ? 's' : ''}
</Text> </Text>
)} )}
</Box> </Box>

View File

@@ -351,10 +351,10 @@ export function InvitationScreen(): React.ReactElement {
const seenLockingBytecodes = new Set<string>(); const seenLockingBytecodes = new Set<string>();
for (const utxo of utxos) { for (const utxo of utxos) {
const lockingBytecodeHex = utxo.lockingBytecode const lockingBytecodeHex = utxo.scriptHash
? typeof utxo.lockingBytecode === 'string' ? typeof utxo.scriptHash === 'string'
? utxo.lockingBytecode ? utxo.scriptHash
: Buffer.from(utxo.lockingBytecode).toString('hex') : Buffer.from(utxo.scriptHash).toString('hex')
: undefined; : undefined;
if (lockingBytecodeHex && seenLockingBytecodes.has(lockingBytecodeHex)) continue; if (lockingBytecodeHex && seenLockingBytecodes.has(lockingBytecodeHex)) continue;

View File

@@ -45,7 +45,8 @@ export const resolveActionRoles = (
const starts = template.start ?? []; const starts = template.start ?? [];
const roleIds = starts const roleIds = starts
.filter((entry) => entry.action === actionIdentifier) .filter((entry) => entry.action === actionIdentifier)
.map((entry) => entry.role); .map((entry) => entry.role)
.filter((roleId) => roleId !== undefined);
return [...new Set(roleIds)]; return [...new Set(roleIds)];
}; };
@@ -60,17 +61,11 @@ export const roleRequiresInputs = (
if (!action) return false; if (!action) return false;
const actionRole = action.roles?.[roleIdentifier]; const actionRole = action.roles?.[roleIdentifier];
const roleSlotsMin = actionRole?.requirements?.slots?.min ?? 0; const actionRequirements = action.requirements;
const actionRoleRequirements = actionRole && actionRequirements && actionRequirements.participants?.find((participant) => participant.role === roleIdentifier);
const roleSlotsMin = actionRoleRequirements && actionRoleRequirements.slots && actionRoleRequirements.slots.min > 0 ? actionRoleRequirements.slots.min : 0;
if (roleSlotsMin > 0) return true; if (roleSlotsMin > 0) return true;
// Some templates specify slot/input requirements at action.requirements.roles
// instead of role.requirements. Respect those as well.
const roleRequirement = action.requirements?.roles?.find(
(requirement) => requirement.role === roleIdentifier,
);
const actionLevelSlotsMin = roleRequirement?.slots?.min ?? 0;
if (actionLevelSlotsMin > 0) return true;
const transactionIdentifier = action.transaction; const transactionIdentifier = action.transaction;
const transaction = transactionIdentifier const transaction = transactionIdentifier
? template.transactions?.[transactionIdentifier] ? template.transactions?.[transactionIdentifier]

View File

@@ -188,11 +188,13 @@ export function getRolesForAction(
); );
return startEntries.map((entry) => { return startEntries.map((entry) => {
const roleDef = template.roles?.[entry.role]; const roleDef = template.roles?.[entry.role || ''];
const roleObj = typeof roleDef === "object" ? roleDef : null; const roleObj = typeof roleDef === "object" ? roleDef : null;
// TODO: This is ugly. Lot of conditionals. Need to take a much closer look at this.
return { return {
roleId: entry.role, roleId: entry.role || '',
name: roleObj?.name || entry.role, name: roleObj?.name || entry.role || '',
description: roleObj?.description, description: roleObj?.description,
}; };
}); });