Fix build issues
This commit is contained in:
29
readme.md
29
readme.md
@@ -5,10 +5,11 @@
|
||||
### Full Installation
|
||||
```bash
|
||||
# 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
|
||||
git clone git@gitlab.com:GeneralProtocols/xo/engine.git
|
||||
# ----- Start Engine Setup -----
|
||||
# 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
|
||||
cd engine
|
||||
@@ -21,10 +22,31 @@ npm ci
|
||||
|
||||
# Build the engine
|
||||
npm run build
|
||||
# ----- End Engine Setup -----
|
||||
|
||||
# Move back to the top level directory
|
||||
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
|
||||
git clone git@git.harvmaster.com:Harvmaster/xo-cli.git
|
||||
|
||||
@@ -36,6 +58,7 @@ npm ci
|
||||
|
||||
# Build the cli
|
||||
npm run build
|
||||
# ----- End CLI Setup -----
|
||||
```
|
||||
|
||||
### Install globally
|
||||
|
||||
@@ -138,7 +138,7 @@ export class HistoryService {
|
||||
utxo.outpointIndex,
|
||||
);
|
||||
ownOutpoints.add(outpointKey);
|
||||
ownLockingBytecodes.add(utxo.lockingBytecode);
|
||||
ownLockingBytecodes.add(utxo.scriptHash);
|
||||
outpointValueSatoshis.set(outpointKey, BigInt(utxo.valueSatoshis));
|
||||
}
|
||||
|
||||
@@ -521,7 +521,7 @@ export class HistoryService {
|
||||
const originKey = this.getUtxoOriginKey(
|
||||
utxo.templateIdentifier,
|
||||
utxo.outputIdentifier,
|
||||
utxo.lockingBytecode,
|
||||
utxo.scriptHash,
|
||||
);
|
||||
return invitationByUtxoOrigin.get(originKey)?.invitationIdentifier;
|
||||
}
|
||||
@@ -533,7 +533,7 @@ export class HistoryService {
|
||||
const originKey = this.getUtxoOriginKey(
|
||||
utxo.templateIdentifier,
|
||||
utxo.outputIdentifier,
|
||||
utxo.lockingBytecode,
|
||||
utxo.scriptHash,
|
||||
);
|
||||
return invitationByUtxoOrigin.get(originKey)?.roleIdentifier;
|
||||
}
|
||||
|
||||
@@ -100,8 +100,8 @@ export function TemplateListScreen(): React.ReactElement {
|
||||
for (const startingAction of rawStartingActions) {
|
||||
const existing = actionMap.get(startingAction.action);
|
||||
if (existing) {
|
||||
if (!existing.roles.includes(startingAction.role)) {
|
||||
existing.roles.push(startingAction.role);
|
||||
if (!existing.roles.includes(startingAction.role ?? '')) {
|
||||
existing.roles.push(startingAction.role ?? '');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ export function TemplateListScreen(): React.ReactElement {
|
||||
actionIdentifier: startingAction.action,
|
||||
name: actionDef?.name || startingAction.action,
|
||||
description: actionDef?.description,
|
||||
roles: [startingAction.role],
|
||||
roles: [startingAction.role ?? ''],
|
||||
source: 'starting',
|
||||
});
|
||||
}
|
||||
@@ -119,9 +119,9 @@ export function TemplateListScreen(): React.ReactElement {
|
||||
const ownedOutputIdentifiers = ownedOutputsByTemplate.get(templateIdentifier) ?? new Set<string>();
|
||||
for (const outputIdentifier of ownedOutputIdentifiers) {
|
||||
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> }> }
|
||||
| undefined;
|
||||
if (!lockingScriptDefinition?.roles) continue;
|
||||
|
||||
@@ -15,7 +15,7 @@ export { DataWizardFlow } from "./DataWizardFlow.js";
|
||||
*/
|
||||
export function createWizardFlow(action: XOTemplateAction): WizardFlow {
|
||||
if (action.data?.length && !action.transaction) {
|
||||
return new DataWizardFlow(action.data);
|
||||
return new DataWizardFlow([action.data]);
|
||||
}
|
||||
return new TransactionWizardFlow();
|
||||
}
|
||||
|
||||
@@ -61,13 +61,16 @@ export function RoleSelectStep({
|
||||
{availableRoles.length === 0 ? (
|
||||
<Text color={colors.textMuted}>No roles available</Text>
|
||||
) : (
|
||||
availableRoles.map((roleId, index) => {
|
||||
availableRoles.map((roleId: string, index: number) => {
|
||||
const isCursor =
|
||||
selectedRoleIndex === index && focusArea === 'content';
|
||||
const roleDef = template.roles?.[roleId];
|
||||
const actionRole = action?.roles?.[roleId];
|
||||
const requirements = actionRole?.requirements;
|
||||
|
||||
const actionRequirements = action?.requirements;
|
||||
const actionRoleRequirements = actionRole && actionRequirements && actionRequirements.participants?.find((participant) => participant.role === roleId);
|
||||
|
||||
return (
|
||||
<Box key={roleId} flexDirection="column" marginY={0}>
|
||||
<Text
|
||||
@@ -96,10 +99,10 @@ export function RoleSelectStep({
|
||||
{' '}
|
||||
</Text>
|
||||
)}
|
||||
{requirements.slots && requirements.slots.min > 0 && (
|
||||
{actionRoleRequirements && actionRoleRequirements.slots && actionRoleRequirements.slots.min > 0 && (
|
||||
<Text color={colors.textMuted} dimColor>
|
||||
{requirements.slots.min} input slot
|
||||
{requirements.slots.min !== 1 ? 's' : ''}
|
||||
{actionRoleRequirements.slots.min} input slot
|
||||
{actionRoleRequirements.slots.min !== 1 ? 's' : ''}
|
||||
</Text>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -351,10 +351,10 @@ export function InvitationScreen(): React.ReactElement {
|
||||
const seenLockingBytecodes = new Set<string>();
|
||||
|
||||
for (const utxo of utxos) {
|
||||
const lockingBytecodeHex = utxo.lockingBytecode
|
||||
? typeof utxo.lockingBytecode === 'string'
|
||||
? utxo.lockingBytecode
|
||||
: Buffer.from(utxo.lockingBytecode).toString('hex')
|
||||
const lockingBytecodeHex = utxo.scriptHash
|
||||
? typeof utxo.scriptHash === 'string'
|
||||
? utxo.scriptHash
|
||||
: Buffer.from(utxo.scriptHash).toString('hex')
|
||||
: undefined;
|
||||
|
||||
if (lockingBytecodeHex && seenLockingBytecodes.has(lockingBytecodeHex)) continue;
|
||||
|
||||
@@ -45,7 +45,8 @@ export const resolveActionRoles = (
|
||||
const starts = template.start ?? [];
|
||||
const roleIds = starts
|
||||
.filter((entry) => entry.action === actionIdentifier)
|
||||
.map((entry) => entry.role);
|
||||
.map((entry) => entry.role)
|
||||
.filter((roleId) => roleId !== undefined);
|
||||
|
||||
return [...new Set(roleIds)];
|
||||
};
|
||||
@@ -60,17 +61,11 @@ export const roleRequiresInputs = (
|
||||
if (!action) return false;
|
||||
|
||||
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;
|
||||
|
||||
// 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 transaction = transactionIdentifier
|
||||
? template.transactions?.[transactionIdentifier]
|
||||
|
||||
@@ -188,11 +188,13 @@ export function getRolesForAction(
|
||||
);
|
||||
|
||||
return startEntries.map((entry) => {
|
||||
const roleDef = template.roles?.[entry.role];
|
||||
const roleDef = template.roles?.[entry.role || ''];
|
||||
const roleObj = typeof roleDef === "object" ? roleDef : null;
|
||||
|
||||
// TODO: This is ugly. Lot of conditionals. Need to take a much closer look at this.
|
||||
return {
|
||||
roleId: entry.role,
|
||||
name: roleObj?.name || entry.role,
|
||||
roleId: entry.role || '',
|
||||
name: roleObj?.name || entry.role || '',
|
||||
description: roleObj?.description,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user