sonicapi/
state.rs

1// SONIC: Standard library for formally-verifiable distributed contracts
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Designed in 2019-2025 by Dr Maxim Orlovsky <orlovsky@ubideco.org>
6// Written in 2024-2025 by Dr Maxim Orlovsky <orlovsky@ubideco.org>
7//
8// Copyright (C) 2019-2024 LNP/BP Standards Association, Switzerland.
9// Copyright (C) 2024-2025 Laboratories for Ubiquitous Deterministic Computing (UBIDECO),
10//                         Institute for Distributed and Cognitive Systems (InDCS), Switzerland.
11// Copyright (C) 2019-2025 Dr Maxim Orlovsky.
12// All rights under the above copyrights are reserved.
13//
14// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
15// in compliance with the License. You may obtain a copy of the License at
16//
17//        http://www.apache.org/licenses/LICENSE-2.0
18//
19// Unless required by applicable law or agreed to in writing, software distributed under the License
20// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
21// or implied. See the License for the specific language governing permissions and limitations under
22// the License.
23
24use aluvm::LibSite;
25use amplify::num::u256;
26use strict_types::StrictVal;
27use ultrasonic::AuthToken;
28
29pub type StateTy = u256;
30
31#[derive(Clone, Eq, PartialEq, Debug)]
32#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
33pub struct StateAtom {
34    pub verified: StrictVal,
35    pub unverified: Option<StrictVal>,
36}
37
38#[derive(Clone, Eq, PartialEq, Debug)]
39#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
40pub struct StructData {
41    pub ty: StateTy,
42    /// Transformed and typefied value extracted from [`ultrasonic::StatData`] by an ApiAdaptor.
43    pub value: StrictVal,
44}
45
46#[derive(Clone, Eq, PartialEq, Debug)]
47#[cfg_attr(feature = "serde", derive(Serialize, Deserialize), serde(rename_all = "camelCase"))]
48pub struct DataCell {
49    pub data: StrictVal,
50    pub auth: AuthToken,
51    pub lock: Option<LibSite>,
52}