Blyx Nest Blyx language
Registry / Framework
framework · v0.1.2

Auction Close

Drive a single-item ascending auction with a reserve, strictly increasing bids and a settlement handoff.

Source repository · Package JSON

Use Auction Close

use vendor::auction_close::auction_close;

Run the example

nest demo auction_close@0.1.2
blyxc native-run auction_close-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::auction_close::auction_close;

fn main() {
    let arguments = cli_args();
    if args_len(arguments) > 0 {
        if args_len(arguments) % 2 != 0 {
            stderr_line("Expected event and value pairs");
            process_exit(2);
        }
        let mut live = auction_close_start();
        let mut i = 0;
        while i < args_len(arguments) {
            let input = args_at(arguments, i + 1);
            if !text_is_number(input) {
                stderr_line("Expected a whole numeric event value");
                process_exit(2);
            }
            live = auction_close_step(live, args_at(arguments, i), text_number(input));
            let command = auction_close_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = auction_close_start();
    state = auction_close_step(state, "open", 20.0);
    println!(auction_close_command(state));
    state = auction_close_step(state, "bid", 19.0);
    println!(auction_close_command(state));
    state = auction_close_step(state, "bid", 20.0);
    println!(auction_close_command(state));
    state = auction_close_step(state, "bid", 23.0);
    println!(auction_close_command(state));
    state = auction_close_step(state, "close", 0.0);
    println!(auction_close_command(state));
    state = auction_close_step(state, "paid", 23.0);
    println!(auction_close_command(state));
}

Expected output

set_reserve
reject
accept_bid
replace_high_bid
invoice_winner
release_item

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse filesbf6fda9c2df3a0181599181fc356ad0e33ec7f48863635ef5ce1ada8a2ed51f786b3e4a791
0.1.1Download ZIP · Browse files7af31d2332421c7e6901b23fe09b361cbc014db02eaf2ebdc0a7c5ce72183ed8ae6351499a
0.1.0Download ZIP · Browse files6349f23784bda581ace79425c85e054cf50ac606b4d41ce139b37bbcc67c1128af5b239c99