Skip to content

Commit 016a724

Browse files
committed
api: strict serializaiton and ids
1 parent 1bbc147 commit 016a724

File tree

22 files changed

+552
-217
lines changed

22 files changed

+552
-217
lines changed

Cargo.lock

Lines changed: 121 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = [".", "inmem", "request"]
2+
members = [".", "cli", "inmem", "request"]
33
default-members = [".", "inmem", "request"]
44

55
[workspace.package]

cli/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "sonare-cli"
3+
description = "SONARE command-line interface"
4+
categories = ["cryptography", "science", "command-line-interface"]
5+
version.workspace = true
6+
authors.workspace = true
7+
repository.workspace = true
8+
homepage.workspace = true
9+
keywords.workspace = true
10+
readme.workspace = true
11+
license.workspace = true
12+
edition.workspace = true
13+
rust-version.workspace = true
14+
15+
[dependencies]
16+
sonare = { version = "0.12.0-alpha.1", path = ".." }
17+
clap = { version = "4.5.21", features = ["derive", "env"] }

cli/src/cmd.rs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// SONARE: Runtime environment for formally-verifiable distributed software
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
// Designed in 2019-2024 by Dr Maxim Orlovsky <[email protected]>
6+
// Written in 2024-2025 by Dr Maxim Orlovsky <[email protected]>
7+
//
8+
// Copyright (C) 2019-2025 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+
use std::path::PathBuf;
25+
26+
use sonare::util::ContractRef;
27+
28+
pub enum Command {
29+
/// Import kit
30+
Import {
31+
path: PathBuf,
32+
},
33+
34+
/// List known objects
35+
List,
36+
37+
/// Issue a new contract
38+
Issue {
39+
/// Contract information
40+
///
41+
/// If not provided, read from the user input.
42+
path: Option<PathBuf>,
43+
},
44+
45+
/// Retrieve contract information
46+
Info {
47+
contract_id: ContractRef,
48+
},
49+
50+
/// Display contract state
51+
State {
52+
contract_id: ContractRef,
53+
},
54+
55+
/// Call contract read method
56+
Read {
57+
contract_id: ContractRef,
58+
},
59+
60+
/// Execute contract operation
61+
Exec {
62+
contract_id: ContractRef,
63+
},
64+
65+
/// Transfer contract state
66+
Transfer {
67+
contract_id: ContractRef,
68+
path: PathBuf,
69+
},
70+
71+
Validate {
72+
path: PathBuf,
73+
},
74+
75+
Accept {
76+
path: PathBuf,
77+
},
78+
}

cli/src/main.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SONARE: Runtime environment for formally-verifiable distributed software
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
// Designed in 2019-2024 by Dr Maxim Orlovsky <[email protected]>
6+
// Written in 2024-2025 by Dr Maxim Orlovsky <[email protected]>
7+
//
8+
// Copyright (C) 2019-2025 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+
mod cmd;
25+
26+
fn main() { todo!() }

examples/dao.con

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
{--
22
A smart contract written for SONIC runtime environment
33
SONIC stands for "State machine with ownership notation for indeterministic contracts"
4-
5-
A contract calls are URIs and URLS, which may have multiple forms (depending on the backend).
6-
Here are the examples for the `castVote` call:
7-
- Using SONARE runtime:
8-
`contract:DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
9-
- Using a server providing SONIC API:
10-
`contract://any.sonicapi.node/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
11-
- Using a server providing HTTP REST SONIC API:
12-
`https://[email protected]/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
13-
- Using a websocket connection:
14-
`wws://[email protected]/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
15-
- Using a Storm node server which contains SONARE runtime:
16-
`storm://any.storm.node/contract:DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
174
--}
185

196
data PartyId: U64

examples/dao.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate strict_types;
55

66
use amplify::confinement::{SmallString, TinyString};
77
use sonare::api::embedded::{EmbeddedAdaptors, EmbeddedArithm, EmbeddedProc, EmbeddedReaders, Source};
8-
use sonare::api::{Api, ApiVm, AppendApi, CollectionType, DestructibleApi};
8+
use sonare::api::{Api, ApiInner, AppendApi, CollectionType, DestructibleApi};
99
use sonare::containers::Ffv;
1010
use strict_types::stl::std_stl;
1111
use strict_types::{SemId, SymbolicSys, SystemBuilder, TypeSystem};
@@ -87,11 +87,12 @@ fn main() {
8787
reserved: default!(),
8888
};
8989

90-
let api = Api::<EmbeddedProc> {
90+
let api = Api::Embedded(ApiInner::<EmbeddedProc> {
9191
version: Ffv::default(),
9292
codex_id: codex.codex_id(),
93+
api_version: 0,
9394
name: None,
94-
vm: EmbeddedProc::TYPE,
95+
developer: tiny_s!("ssi:anonymous"),
9596
append_only: tiny_bmap! {
9697
vname!("parties") => AppendApi {
9798
published: true,
@@ -138,5 +139,5 @@ fn main() {
138139
vname!("castVote") => 2,
139140
},
140141
errors: Default::default(),
141-
};
142+
});
142143
}

request/src/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// the License.
2323

2424
use amplify::confinement::{TinyString, TinyVec};
25-
use sonare::containers::contract::ProofOfPubl;
25+
use sonare::containers::ProofOfPubl;
2626
use strict_types::StrictVal;
2727
use ultrasonic::ContractId;
2828

request/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@
3030
//! # URL Representation
3131
//!
3232
//! `contract:[//USER@NODE:PORT/]CONTRACT_ID[/API][/METHOD?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://[email protected]/DAO.indsc.org/castVote?voting=id&with=(id,preimage)&next=(id,hash)&vote=pro`
42+
//! - Using a websocket connection:
43+
//! `wws://[email protected]/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`
3348
3449
mod data;
3550

0 commit comments

Comments
 (0)