holochain-open-dev / holoom

Tools for weaving blockchain data into holochain
2 stars 1 forks source link

Recipes #12

Closed 8e8b2c closed 3 months ago

8e8b2c commented 3 months ago

The recipes feature is intended to allow for more sophisticated customisable programs that draw multiple resources together. In contrast to the existing JqExecution entry, which takes a single resource specifier as an input, a RecipeExecution would be able to dynamically request resources, specified in the form of instructions.

Take the following pseudo definition for selecting a players percentage of match wins:

{
  match_ids: { doc: 'championships/123/match_ids_final' },
  matches: { doc_list: '$match_ids' },
  player_win_counts: { in: '$matches', jq: '# matches into player_id: win_count' },
  player_ids: { in: '$player_win_counts', jq: '# key of ^' },
  external_ids: { fetch_external_id_attestations: '$player_ids' }
  split: { in: ['$player_win_counts', '$external_ids'], jq: '# filter by external id and calc percentage' },
  caller: { get_pubkey },
  '$return': { in: ['$caller', '$split', '$recipient_evm_address'], jq: '# select percentage by pubkey' }
}

The corresponding RecipeExecution might take form

{
  match_ids: someDocActionHash,
  matches: listOfDocActionHashes,
  player_win_counts: someJqExecution,
  player_ids: someJqExecution,
  external_ids: someMapOfExternalIdsToAttestations,
  split: someJqExecution,
  caller: actionAuthor,
  '$return': someJqExecution
}
8e8b2c commented 3 months ago

WIP: https://github.com/holochain-open-dev/holoom/tree/8e8b2c/recipes