Datapacks question: Craft Enchanted Items [duplicate]

How I have handled similar ideas:

  1. Set the recipe's "result" to a particular item that a player is not likely to ever have in their inventory (I usually use bat_spawn_egg).
  2. Create an advancement that a player achieves either by crafting your custom recipe or by acquiring a bat_spawn_egg into their inventory.
  3. Set the reward of the advancement to trigger a custom function.
  4. Have the custom function remove the bat_spawn_egg from the player's inventory and add the cursed item with the NBT data.