add locking bytecode to template
This commit is contained in:
@@ -276,7 +276,7 @@ export function ActionWizardScreen(): React.ReactElement {
|
||||
* Create invitation and add variables.
|
||||
*/
|
||||
const createInvitationWithVariables = useCallback(async () => {
|
||||
if (!templateIdentifier || !actionIdentifier || !roleIdentifier) return;
|
||||
if (!templateIdentifier || !actionIdentifier || !roleIdentifier || !template) return;
|
||||
|
||||
setIsProcessing(true);
|
||||
setStatus('Creating invitation...');
|
||||
@@ -305,6 +305,25 @@ export function ActionWizardScreen(): React.ReactElement {
|
||||
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);
|
||||
|
||||
// Check if next step is inputs
|
||||
@@ -323,7 +342,7 @@ export function ActionWizardScreen(): React.ReactElement {
|
||||
} finally {
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user