sonic_callreq/
lib.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
24// TODO: Activate no_std once StrictEncoding will support it
25// #![cfg_attr(not(feature = "std"), no_std)]
26#![deny(
27    unsafe_code,
28    dead_code,
29    // TODO: Complete documentation
30    // missing_docs,
31    unused_variables,
32    unused_mut,
33    unused_imports,
34    non_upper_case_globals,
35    non_camel_case_types,
36    non_snake_case
37)]
38#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
39#![cfg_attr(docsrs, feature(doc_auto_cfg))]
40
41//! _Request_ (or _transaction request_) is a specification on constructing a transaction for a
42//! SONARE contract.
43//!
44//! # URL Representation
45//!
46//! `contract:[//USER@NODE:PORT/]CONTRACT_ID[/API][/METHOD[/STATE]]/[VALUE][?ARGS]`
47//!
48//! A contract calls are URIs and URLS, which may have multiple forms (depending on the backend).
49//! Here are the examples for the `castVote` call for the DAO contract from the examples directory:
50//! - Using SONARE runtime:
51//!   `contract:DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
52//! - Using a server providing SONIC API:
53//!   `contract://any.sonicapi.node/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,
54//!   hash)&vote=pro`
55//! - Using a server providing HTTP REST SONIC API: `https://contract@any.sonicapi.node/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
56//! - Using a websocket connection:
57//!   `wws://contract@any.sonicapi.node/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&
58//!   next=(id,hash)&vote=pro`
59//! - Using a Storm node server which contains SONARE runtime:
60//!   `storm://any.storm.node/contract:DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,
61//!   hash)&vote=pro`
62
63extern crate alloc;
64#[macro_use]
65extern crate amplify;
66#[macro_use]
67extern crate strict_encoding;
68
69#[cfg(feature = "serde")]
70#[macro_use]
71extern crate serde;
72extern crate core;
73
74mod data;
75#[cfg(feature = "uri")]
76pub mod uri;
77mod builder;
78
79pub use data::{CallRequest, CallScope, CallState, Endpoint, Layer1, MethodName, ParseLayer1Error, StateName};
80
81pub const LIB_NAME_SONIC: &str = "SONIC";