import { create } from 'zustand';
import { immer } from 'zustand/middleware/immer';
import { createTransactionTaskId, } from '../transaction-task/transactionTask.js';
export const useTransactionTaskStore = create(immer(set => ({
    taskEntryById: {},
    createTask: (task) => {
        set(state => {
            const id = createTransactionTaskId(task);
            state.taskEntryById[id] = {
                id,
                request: task,
                createdAt: new Date(),
            };
        });
    },
    completeTask: (id, hash) => {
        set(state => {
            if (state.taskEntryById[id]) {
                state.taskEntryById[id].hash = hash;
            }
        });
    },
})));
