Skip to content

ICRC-12: Canister Events #12

@SuddenlyHazel

Description

@SuddenlyHazel
icrc: 12
title: ICRC-12 Canister Events 
author: Hazel Rowell <hazel@departure.dev>,
discussions-to: https://github.com/dfinity/ICRC/issues/12
status: Deliberating 
category: ICRC
requires: None
created: 2023-02-26
updated: 2023-02-26

Moving from the forum to continue discussion.

Summary

A minimum set of types and methods to facilitate the development of event driven systems on the IC.

Introduction

This proposal aims to enable the development of event-driven systems on the IC by introducing a set of types and methods. Our approach in this proposal is omnibus. We propose the use of the PublisherMessage, which can contain either a PublisherNotification or an Event. The Event is loosely self-describing with the help of the event_schema property. Our goal is to provide a framework that is tight enough to allow developers to start publishing and subscribing immediately while being flexible enough to accommodate future scaling needs.

Publisher

icrc12_subscribe & icrc12_unsubscribe

type SubscriptionError = variant {
    NotAuthorized;
};

type SubscriptionResponse = variant {
    Ok : null;
    Err : opt SubscriptionError;
};

type Publisher = service {
  icrc12_subscribe : (handler : (PublisherMessage) → ()) → (SubscriptionResponse);
  icrc12_unsubscribe : (handler : (PublisherMessage) → ()) → (SubscriptionResponse);
}

Subscriber

icrc12_handler


type Event = record {
    event_schema : text;
    event_type : text;
    created_at : nat64;
    data : vec nat8;
};

type PublisherNotification = variant {
    NewSender  : record {p : principal};
};

type PublisherMessage = variant {
    Event : Event;
    Notification : opt PublisherNotification;
};

type Subscriber  = service : {
    icrc12_handler: (PublisherMessage) -> ();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionCommunity discussion is encouraged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions