import Utils from "~/utils";

const state = {
  operateFuns: {},
};

const mutations = {
  /**
   *
   * @param {Object} state
   * @param {Object} funs
   * @returns
   */
  ADD_OPERATE_FUN(state, { id, funs }) {
    state.operateFuns[id] = funs;
  },
};

const actions = {
  setOperateFuns({ commit }, funs) {
    return new Promise(resolve => {
      // const id = Symbol("transaction-id");
      const id = Utils.generateUUID();
      commit('ADD_OPERATE_FUN', { id, funs })
      resolve(id)
    });
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
};
