linera-execution 0.1.0

Persistent data and the corresponding logics used by the Linera protocol for runtime and execution of smart contracts / applications.
Documentation
chain-id: func() -> chain-id
application-id: func() -> application-id
application-parameters: func() -> list<u8>
read-system-balance: func() -> balance
read-system-timestamp: func() -> timestamp

log: func(message: string, level: log-level)

enum log-level {
    trace,
    debug,
    info,
    warn,
    error,
}

load: func() -> list<u8>
load-and-lock: func() -> option<list<u8>>
store-and-unlock: func(value: list<u8>) -> bool

resource lock {
    static new: func() -> lock
    poll: func() -> poll-lock
}

variant poll-lock {
    pending,
    ready-locked,
    ready-not-locked,
}

resource read-key-bytes {
    static new: func(key: list<u8>) -> read-key-bytes
    poll: func() -> poll-read-key-bytes
}

variant poll-read-key-bytes {
    pending,
    ready(option<list<u8>>),
}

resource find-keys {
    static new: func(prefix: list<u8>) -> find-keys
    poll: func() -> poll-find-keys
}

variant poll-find-keys {
    pending,
    ready(list<list<u8>>),
}

resource find-key-values {
    static new: func(prefix: list<u8>) -> find-key-values
    poll: func() -> poll-find-key-values
}

variant poll-find-key-values {
    pending,
    ready(list<tuple<list<u8>,list<u8>>>),
}

variant write-operation {
    delete(list<u8>),
    deleteprefix(list<u8>),
    put(tuple<list<u8>,list<u8>>),
}

resource write-batch {
    static new: func(key: list<write-operation>) -> write-batch
    poll: func() -> poll-unit
}

variant poll-unit {
    pending,
    ready,
}

try-call-application: func(
    authenticated: bool,
    application: application-id,
    argument: list<u8>,
    forwarded-sessions: list<session-id>,
) -> call-result

try-call-session: func(
    authenticated: bool,
    session: session-id,
    argument: list<u8>,
    forwarded-sessions: list<session-id>,
) -> call-result

record call-result {
    value: list<u8>,
    sessions: list<session-id>,
}

record session-id {
    application-id: application-id,
    kind: u64,
    index: u64,
}

record application-id {
    bytecode-id: bytecode-id,
    creation: effect-id,
}

type bytecode-id = effect-id

record effect-id {
    chain-id: chain-id,
    height: block-height,
    index: u32,
}

type chain-id = crypto-hash
type block-height = u64
type timestamp = u64

record crypto-hash {
    part1: u64,
    part2: u64,
    part3: u64,
    part4: u64,
}

record balance {
    lower-half: u64,
    upper-half: u64,
}