Sample Code
Below are various sample code that demonstrates various use-cases you may encounter writing custom actions:
Get a booth owner
Within the ++ action arm of your custom action handler, obtain booth information using the following hoon:
:: note that store and context are both provided in the outer/parent core in
:: which the 'on' arm resides
=/ booth (~(get by booths.store) booth-key.context)
:: the call above will return an object of type (unit json)
:: you'll want to ensure this is not null, and if not, grab the inner
:: json object using `need`
=/ booth ?~(booth ~ (need booth))
:: at this point, booth will either be null or a valid json object. however,
:: before you can work with the booth as json, you'll need to verify it's a valid
:: json type using the following code
=/ booth ?:(?=([%o *] booth) p.booth ~)
:: here, booth will be a (map @t json) instance or null (default of map). from this
:: point forward you can, manipulate/query the booth data using stdlib map functions
:: for example, if you wanted to get the booth owner:
=/ booth-owner (~(get by booth) 'owner')
=/ booth-owner ?~(booth-owner '' (so:dejs:format (need booth-owner)))
:: booth-owner here is either empty string (not found) or the owner
:: (ship name e.g. ~zod)
...Get a proposal's strategy
Within the ++ action arm of your custom action handler, obtain booth information using the following hoon. Remember that within the context of the custom-action handler (outer core's ++ on gate), you have both a booth-key and proposal-key in the context.
Therefore given booth-key and proposal-key (both in custom action context), you can obtain the detail of a proposal as follows:
Get a participant's role
Last updated