Skip to content
Logo

rollup.finish

Accepts or rejects the previous request, yields the machine, and blocks until the next request arrives. This is the low-level request cycle primitive — run calls it for you.

Usage

import {  } from "@cartesi/rollup";
 
const  = new ();
 
const  = .({ : true });
 
if (. === "advance") {
    requestArrow
;
} else { requestArrow
;
}

Returns

RollupRequest — a discriminated union, narrowed by type:

type  = {
    : "advance";
    /** Network chain id. */
    : bigint;
    /** Application contract address (0x-prefixed hex, 20 bytes). */
    : `0x${string}`;
    /** Input sender address (0x-prefixed hex, 20 bytes). */
    : `0x${string}`;
    /** L1 block number the input was included in. */
    : bigint;
    /** L1 block timestamp (UNIX epoch seconds). */
    : bigint;
    /** RANDAO mix of the post beacon state of the previous block. */
    : bigint;
    /** Input index among all inputs ever sent to the application. */
    : bigint;
    /** Input payload. */
    : ;
};
 
type  = {
    : "inspect";
    /** Query payload. */
    : ;
};

Parameters

options.accept

  • Type: boolean
  • Default: true

Whether to accept the request handled since the previous finish call. Inside the machine, rejecting reverts the application state to before that request and discards its outputs.

Behavior

The call is synchronous and blocking on purpose: yielding pauses the entire guest — including Node's event loop — until the next request, so nothing could run concurrently anyway. On the host mock it returns immediately with the next configured input.

Errors

ConditionError
No more inputs (mock)RollupError with -ENODATA after an accepted request, -ENOSYS after a rejected one
Device closedError (close() was called)

Both errnos mean the same thing — the CMT_INPUTS list is exhausted — and run treats either as the end of a host session.