add locking bytecode to template
This commit is contained in:
Binary file not shown.
@@ -136,12 +136,7 @@ export class InvitationController extends EventEmitter {
|
|||||||
inputIdentifier?: string;
|
inputIdentifier?: string;
|
||||||
}>,
|
}>,
|
||||||
): Promise<TrackedInvitation> {
|
): Promise<TrackedInvitation> {
|
||||||
// Ensure each input has an inputIdentifier (sync server requires it)
|
return this.flowManager.appendToInvitation(invitationId, { inputs });
|
||||||
const inputsWithIds = inputs.map((input, index) => ({
|
|
||||||
...input,
|
|
||||||
inputIdentifier: input.inputIdentifier ?? `senderInput_${Date.now()}_${index}`,
|
|
||||||
}));
|
|
||||||
return this.flowManager.appendToInvitation(invitationId, { inputs: inputsWithIds });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -158,12 +153,7 @@ export class InvitationController extends EventEmitter {
|
|||||||
roleIdentifier?: string;
|
roleIdentifier?: string;
|
||||||
}>,
|
}>,
|
||||||
): Promise<TrackedInvitation> {
|
): Promise<TrackedInvitation> {
|
||||||
// Ensure each output has an outputIdentifier (sync server may require it)
|
return this.flowManager.appendToInvitation(invitationId, { outputs });
|
||||||
const outputsWithIds = outputs.map((output, index) => ({
|
|
||||||
...output,
|
|
||||||
outputIdentifier: output.outputIdentifier ?? `changeOutput_${Date.now()}_${index}`,
|
|
||||||
}));
|
|
||||||
return this.flowManager.appendToInvitation(invitationId, { outputs: outputsWithIds });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ export function ActionWizardScreen(): React.ReactElement {
|
|||||||
* Create invitation and add variables.
|
* Create invitation and add variables.
|
||||||
*/
|
*/
|
||||||
const createInvitationWithVariables = useCallback(async () => {
|
const createInvitationWithVariables = useCallback(async () => {
|
||||||
if (!templateIdentifier || !actionIdentifier || !roleIdentifier) return;
|
if (!templateIdentifier || !actionIdentifier || !roleIdentifier || !template) return;
|
||||||
|
|
||||||
setIsProcessing(true);
|
setIsProcessing(true);
|
||||||
setStatus('Creating invitation...');
|
setStatus('Creating invitation...');
|
||||||
@@ -305,6 +305,25 @@ export function ActionWizardScreen(): React.ReactElement {
|
|||||||
inv = updated.invitation;
|
inv = updated.invitation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add template-required outputs for the current role
|
||||||
|
// This is critical - the template defines which outputs the initiator must create
|
||||||
|
const action = template.actions?.[actionIdentifier];
|
||||||
|
const transaction = action?.transaction ? template.transactions?.[action.transaction] : null;
|
||||||
|
|
||||||
|
if (transaction?.outputs && transaction.outputs.length > 0) {
|
||||||
|
setStatus('Adding required outputs...');
|
||||||
|
|
||||||
|
// Add each required output with its identifier
|
||||||
|
// The engine will automatically generate the locking bytecode based on the template
|
||||||
|
const outputsToAdd = transaction.outputs.map((outputId: string) => ({
|
||||||
|
outputIdentifier: outputId,
|
||||||
|
roleIdentifier: roleIdentifier,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const updated = await invitationController.addOutputs(invId, outputsToAdd);
|
||||||
|
inv = updated.invitation;
|
||||||
|
}
|
||||||
|
|
||||||
setInvitation(inv);
|
setInvitation(inv);
|
||||||
|
|
||||||
// Check if next step is inputs
|
// Check if next step is inputs
|
||||||
@@ -323,7 +342,7 @@ export function ActionWizardScreen(): React.ReactElement {
|
|||||||
} finally {
|
} finally {
|
||||||
setIsProcessing(false);
|
setIsProcessing(false);
|
||||||
}
|
}
|
||||||
}, [templateIdentifier, actionIdentifier, roleIdentifier, variables, invitationController, steps, currentStep, showError, setStatus, loadAvailableUtxos]);
|
}, [templateIdentifier, actionIdentifier, roleIdentifier, template, variables, invitationController, steps, currentStep, showError, setStatus, loadAvailableUtxos]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add selected inputs and change output to invitation.
|
* Add selected inputs and change output to invitation.
|
||||||
|
|||||||
Reference in New Issue
Block a user