-
Notifications
You must be signed in to change notification settings - Fork 1
Description
After looking again at the interface for getting the different views on a Multikey, I think it makes sense to refactor that to be a Builder pattern. The general idea is to do the following:
- initialize a builder passing a reference to the multikey:
ViewBuilder::new(&multikey) - optionally add in the codec and view creation callback:
.with_local_codec(codec, |mk, view_id| -> Box<dyn View> => { .. }) - call the build function to get the view:
.build()
The main motivation for this comes from the proposal going into the multikey spec to support custom protocol keys: cryptidtech/provenance-specifications#4
By re-arranging the view building to a builder pattern we enable custom protocol implemenations to pass in callbacks that the builder will call to construct the view. This is how we can support user-defined custom protocol keys in the cleanest possible way. For the "standard" key types, the builder just calls the correct functions in the View interface implementation to construct the standard view.
This will be a breaking change since it will change the Multikey interface.