Summary

Check your lib.rs matches this.

#![allow(unused)]
fn main() {
use anyhow::bail;
use essential_types::{
    solution::{Mutation, Solution, SolutionSet},
    Value, Word,
};

pint_abi::gen_from_file! {
    abi: "../contract/out/debug/counter-abi.json",
    contract: "../contract/out/debug/counter.json",
}

#[derive(Clone)]
pub struct CounterKey(pub Vec<Word>);

pub fn counter_key() -> CounterKey {
    let keys: Vec<_> = storage::keys().counter().into();
    CounterKey(keys.first().unwrap().clone())
}

pub fn increment_solution_set(count: Option<Value>) -> anyhow::Result<(SolutionSet, Word)> {
    let count = extract_count(count)?;
    let new_count = count + 1;
    Ok((create_solution_set(new_count), new_count))
}

/// Given a query of the current count, extract the count.
pub fn extract_count(count: Option<Value>) -> anyhow::Result<Word> {
    match count {
        Some(count) => match &count[..] {
            [] => Ok(0),
            [count] => Ok(*count),
            _ => bail!("Expected single word, got: {:?}", count),
        },
        None => Ok(0),
    }
}

pub fn create_solution_set(new_count: Word) -> SolutionSet {
    let state_mutations: Vec<Mutation> = storage::mutations().counter(new_count).into();
    SolutionSet {
        solutions: vec![Solution {
            predicate_to_solve: Increment::ADDRESS,
            predicate_data: Default::default(),
            state_mutations,
        }],
    }
}
}