package balius:odk; interface kv { type payload = list; type kv-error = u32; get-value: func(key: string) -> result; set-value: func(key: string, value: payload) -> result<_, kv-error>; list-values: func(prefix: string) -> result, kv-error>; } interface submit { type cbor = list; type submit-error = u32; submit-tx: func(tx: cbor) -> result<_, submit-error>; } interface broadcast { type msg = list; type broadcast-error = u32; publish-msg: func(topic: string, payload: msg) -> result<_, broadcast-error>; } interface driver { type handle-error = u32; type cbor = list; type json = list; type timestamp = u64; type params = json; variant event { utxo(cbor), utxo-undo(cbor), timer(timestamp), request(params), message(json), } type address = list; record token-pattern { policy: list, name: option>, } record utxo-pattern { address: option
, token: option, } type timer-interval = string; type method = string; type topic = string; variant event-pattern { utxo(utxo-pattern), utxo-undo(utxo-pattern), timer(timer-interval), request(method), message(topic), } variant response { acknowledge, json(json), cbor(cbor), partial-tx(cbor) } register-channel: func(id: u32, pattern: event-pattern); } world worker { import kv; import broadcast; import submit; use driver.{event, handle-error, response}; type env = list; export init: func(env: env); export handle: func(channel: u32, evt: event) -> result; }