magmo / apps

Proof of concept applications that use the Force Move Game framework.
9 stars 5 forks source link

Protocol locator type guards #604

Closed andrewgordstewart closed 5 years ago

andrewgordstewart commented 5 years ago

This PR changes type guards to be more strict, requiring that the next "entry" in the protocolLocator after the path it was given starts with the "descriptor". See the implementation of isCommonAction.

This is a draft PR since it would currently break the app: The reducers do not currently set the protocol locators. We should test the protocolLocator string as a part of itSendsTheseCommitments. To properly set the protocolLocator, one of two things is required: A) A state must store its current "path". When a reducer of a state wants to send an action, it should append its path with the appropriate descriptor. B) When a reducer calls a sub-reducer, and sees an outgoing message in the outbox, it pre-pends the protocolLocator with the appropriate description.

A seems like the simpler option.

In the meantime, I'd like some feedback about this protocolLocator design.

lalexgap commented 5 years ago

This looks good to me. I'd vote for option A as it seems a lot cleaner than trying to modify outgoing messages.