sonic_callreq/lib.rs
1// SONIC: Toolchain 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#![cfg_attr(docsrs, feature(doc_auto_cfg))]
25#![cfg_attr(not(feature = "std"), no_std)]
26
27//! _Request_ (or _transaction request_) is a specification on constructing a transaction for a
28//! SONARE contract.
29//!
30//! # URL Representation
31//!
32//! `contract:[//USER@NODE:PORT/]CONTRACT_ID[/API][/METHOD[/STATE]]/[VALUE][?ARGS]`
33//!
34//! A contract calls are URIs and URLS, which may have multiple forms (depending on the backend).
35//! Here are the examples for the `castVote` call for the DAO contract from the examples directory:
36//! - Using SONARE runtime:
37//! `contract:DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
38//! - Using a server providing SONIC API:
39//! `contract://any.sonicapi.node/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,
40//! hash)&vote=pro`
41//! - 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`
42//! - Using a websocket connection:
43//! `wws://contract@any.sonicapi.node/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&
44//! next=(id,hash)&vote=pro`
45//! - Using a Storm node server which contains SONARE runtime:
46//! `storm://any.storm.node/contract:DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,
47//! hash)&vote=pro`
48
49extern crate alloc;
50#[macro_use]
51extern crate amplify;
52#[macro_use]
53extern crate strict_encoding;
54
55#[cfg(feature = "serde")]
56#[macro_use]
57extern crate serde;
58extern crate core;
59
60mod data;
61#[cfg(feature = "uri")]
62mod uri;
63mod builder;
64
65pub use data::{CallRequest, CallScope, CallState, Endpoint, MethodName, StateName};
66
67pub const LIB_NAME_SONIC: &str = "SONIC";