axone_dataverse/msg.rs
1use cosmwasm_schema::{cw_serde, QueryResponses};
2use cosmwasm_std::{Addr, Binary, Uint128, Uint64};
3
4/// `InstantiateMsg` is used to initialize a new instance of the dataverse.
5#[cw_serde]
6pub struct InstantiateMsg {
7 /// A unique name to identify the dataverse instance.
8 pub name: String,
9
10 /// The configuration used to instantiate the triple store.
11 pub triplestore_config: TripleStoreConfig,
12}
13
14/// `ExecuteMsg` defines the set of possible actions that can be performed on the dataverse.
15///
16/// This enum provides variants for registering services, datasets, and other operations related to the dataverse.
17#[cw_serde]
18pub enum ExecuteMsg {
19 /// # SubmitClaims
20 /// Submits new claims about a resource to the dataverse.
21 ///
22 /// The SubmitClaims message is a pivotal component in the dataverse, enabling entities to contribute new claims about various
23 /// resources. A claim represents a statement made by an entity, referred to as the issuer, which could be a person, organization,
24 /// or service. These claims pertain to a diverse range of resources, including digital resources, services, zones, or individuals,
25 /// and are asserted as factual by the issuer.
26 ///
27 /// #### Format
28 ///
29 /// Claims are injected into the dataverse through Verifiable Credentials (VCs).
30 ///
31 /// Primarily, the claims leverage the AXONE ontology, which facilitates articulating assertions about widely acknowledged resources
32 /// in the dataverse, including digital services, digital resources, zones, governance, and more.
33 ///
34 /// Additionally, other schemas may also be employed to supplement and enhance the validated knowledge contributed to these resources.
35 ///
36 /// #### Preconditions
37 ///
38 /// To maintain integrity and coherence in the dataverse, several preconditions are set for the submission of claims:
39 ///
40 /// 1. **Format Requirement**: Claims must be encapsulated within Verifiable Credentials (VCs).
41 ///
42 /// 2. **Unique Identifier Mandate**: Each Verifiable Credential within the dataverse must possess a unique identifier.
43 ///
44 /// 3. **Issuer Verification**: Claims are accepted if they either:
45 /// - Bear a verifiable issuer's signature to ensure authenticity.
46 /// - Originate from the transaction sender, in which case the transaction signature serves as proof of authenticity.
47 ///
48 /// 4. **Content**: The actual implementation supports the submission of a single Verifiable Credential, containing a single claim.
49 ///
50 /// #### Supported cryptographic proofs
51 ///
52 /// - `Ed25519Signature2018`
53 ///
54 /// - `Ed25519Signature2020`
55 ///
56 /// - `EcdsaSecp256k1Signature2019`
57 ///
58 /// - `DataIntegrity` with the following cryptosuites: `eddsa-2022`, `eddsa-rdfc-2022`.
59 ///
60 SubmitClaims {
61 /// The Verifiable Credential containing the claims.
62 /// The claims must be serialized in the format specified by the `format` field.
63 claims: Binary,
64 /// RDF dataset serialization format for the claims.
65 /// If not provided, the default format is [N-Quads](https://www.w3.org/TR/n-quads/) format.
66 format: Option<RdfDatasetFormat>,
67 },
68
69 /// # RevokeClaims
70 /// Revoke or withdraw a previously submitted claims.
71 ///
72 /// #### Preconditions:
73 ///
74 /// 1. **Identifier Existance**: The identifier of the claims must exist in the dataverse.
75 RevokeClaims {
76 /// The unique identifier of the claims to be revoked.
77 identifier: Uri,
78 },
79}
80
81/// # TripleStoreConfig
82/// `TripleStoreConfig` represents the configuration related to the management of the triple store.
83#[cw_serde]
84pub struct TripleStoreConfig {
85 /// The code id that will be used to instantiate the triple store contract in which
86 /// to store dataverse semantic data. It must implement the cognitarium interface.
87 pub code_id: Uint64,
88
89 /// Limitations regarding triple store usage.
90 pub limits: TripleStoreLimitsInput,
91}
92
93/// # TripleStoreLimitsInput
94/// Contains requested limitations regarding store usages.
95#[cw_serde]
96#[derive(Default)]
97pub struct TripleStoreLimitsInput {
98 /// The maximum number of triples the store can contain.
99 /// Default to [Uint128::MAX] if not set, which can be considered as no limit.
100 pub max_triple_count: Option<Uint128>,
101 /// The maximum number of bytes the store can contain.
102 /// The size of a triple is counted as the sum of the size of its subject, predicate and object,
103 /// including the size of data types and language tags if any.
104 /// Default to [Uint128::MAX] if not set, which can be considered as no limit.
105 pub max_byte_size: Option<Uint128>,
106 /// The maximum number of bytes the store can contain for a single triple.
107 /// The size of a triple is counted as the sum of the size of its subject, predicate and object,
108 /// including the size of data types and language tags if any. The limit is used to prevent
109 /// storing very large triples, especially literals.
110 /// Default to [Uint128::MAX] if not set, which can be considered as no limit.
111 pub max_triple_byte_size: Option<Uint128>,
112 /// The maximum limit of a query, i.e. the maximum number of triples returned by a select query.
113 /// Default to 30 if not set.
114 pub max_query_limit: Option<u32>,
115 /// The maximum number of variables a query can select.
116 /// Default to 30 if not set.
117 pub max_query_variable_count: Option<u32>,
118 /// The maximum number of bytes an insert data query can contain.
119 /// Default to [Uint128::MAX] if not set, which can be considered as no limit.
120 pub max_insert_data_byte_size: Option<Uint128>,
121 /// The maximum number of triples an insert data query can contain (after parsing).
122 /// Default to [Uint128::MAX] if not set, which can be considered as no limit.
123 pub max_insert_data_triple_count: Option<Uint128>,
124}
125
126impl From<TripleStoreLimitsInput> for axone_cognitarium::msg::StoreLimitsInput {
127 fn from(value: TripleStoreLimitsInput) -> Self {
128 let mut limits = axone_cognitarium::msg::StoreLimitsInput::default();
129 if let Some(max_triple_count) = value.max_triple_count {
130 limits.max_triple_count = max_triple_count;
131 }
132 if let Some(max_byte_size) = value.max_byte_size {
133 limits.max_byte_size = max_byte_size;
134 }
135 if let Some(max_triple_byte_size) = value.max_triple_byte_size {
136 limits.max_triple_byte_size = max_triple_byte_size;
137 }
138 if let Some(max_query_limit) = value.max_query_limit {
139 limits.max_query_limit = max_query_limit;
140 }
141 if let Some(max_query_variable_count) = value.max_query_variable_count {
142 limits.max_query_variable_count = max_query_variable_count;
143 }
144 if let Some(max_insert_data_byte_size) = value.max_insert_data_byte_size {
145 limits.max_insert_data_byte_size = max_insert_data_byte_size;
146 }
147 if let Some(max_insert_data_triple_count) = value.max_insert_data_triple_count {
148 limits.max_insert_data_triple_count = max_insert_data_triple_count;
149 }
150
151 limits
152 }
153}
154
155/// # RdfDatasetFormat
156/// Represents the various serialization formats for an RDF dataset, i.e. a collection of RDF graphs
157/// ([RDF Dataset](https://www.w3.org/TR/rdf11-concepts/#section-dataset)).
158#[cw_serde]
159#[derive(Default)]
160pub enum RdfDatasetFormat {
161 /// # NQuads
162 /// N-Quads Format
163 ///
164 /// N-Quads is an extension of N-Triples to support RDF datasets by adding an optional fourth element to represent the graph name.
165 /// See the [official N-Quads specification](https://www.w3.org/TR/n-quads/).
166 #[serde(rename = "n_quads")]
167 #[default]
168 NQuads,
169}
170
171/// # Uri
172/// `Uri` represents a Uniform Resource Identifier (URI), a string of characters that provides a simple way
173/// to identify a resource.
174/// see https://en.wikipedia.org/wiki/Uniform_Resource_Identifier.
175type Uri = String;
176
177/// `QueryMsg` defines the set of possible queries that can be made to retrieve information about the dataverse.
178///
179/// This enum provides variants for querying the dataverse's details and other related information.
180#[cw_serde]
181#[derive(QueryResponses)]
182pub enum QueryMsg {
183 /// # Dataverse
184 /// Retrieves information about the current dataverse instance.
185 #[returns(DataverseResponse)]
186 Dataverse {},
187}
188
189/// # DataverseResponse
190/// DataverseResponse is the response of the Dataverse query.
191#[cw_serde]
192pub struct DataverseResponse {
193 /// The name of the dataverse.
194 pub name: String,
195 /// The cognitarium contract address.
196 pub triplestore_address: Addr,
197}