A couple of drive-by comments:
-
Candid is higher-order, so you can make SubscriptionRequest properly typed by passing real method handles of type
(PublisherMessage) → ()
instead of a canister/method records. -
Why have the indirection through the SubscriptionRequest type instead of two methods?
type Publisher = service { icrc6_subscribe : (handler : (PublisherMessage) → ()) → (SubscriptionResponse); icrc6_unsubscribe : (handler : (PublisherMessage) → ()) → (SubscriptionResponse); }
-
If you want the SubscriptionError type to be extensible in the future (without breaking clients), you need to wrap it in an option:
type SubscriptionResponse = variant { Ok; Err : opt SubscriptionError; };
This wat, when you later add a new case to the error type, an old client will continue to work and just see
null
. -
The same for PublisherNotification.