    if action.is_err() {
        // cannot pass any data from action.error here - ends up with
        // "FnOnce called more than once" error from wasm-bindgen for
        // "foreign_call" testcase.
        result = Err(RuntimeError("Error while parsing input".to_string()));
    } else {
        // not sure about clone here
        let current_state = STATE.with(|service| service.borrow().clone());

        result = match action.unwrap() {
            Action::Transfer { qty, target } => transfer(current_state, qty, target),