Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/submitclaims claims #582

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions contracts/axone-dataverse/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@ pub fn execute(
) -> Result<Response, ContractError> {
nonpayable(&info)?;
match msg {
ExecuteMsg::SubmitClaims {
metadata,
format: _,
} => execute::submit_claims(deps, info, metadata),
ExecuteMsg::SubmitClaims { claims, format: _ } => {
execute::submit_claims(deps, info, claims)
}
_ => Err(StdError::generic_err("Not implemented").into()),
}
}
Expand All @@ -94,9 +93,9 @@ pub mod execute {
pub fn submit_claims(
deps: DepsMut<'_>,
info: MessageInfo,
data: Binary,
claims: Binary,
) -> Result<Response, ContractError> {
let buf = BufReader::new(data.as_slice());
let buf = BufReader::new(claims.as_slice());
let mut reader = NQuadsReader::new(buf);
let rdf_quads = reader.read_all()?;
let vc_dataset = Dataset::from(rdf_quads.as_slice());
Expand Down Expand Up @@ -275,7 +274,7 @@ mod tests {
let info = message_info(&addr(SENDER), &coins(10, "uaxone"));

let msg = ExecuteMsg::SubmitClaims {
metadata: Binary::from("data".as_bytes()),
claims: Binary::from("data".as_bytes()),
format: Some(RdfDatasetFormat::NQuads),
};

Expand Down Expand Up @@ -345,7 +344,7 @@ mod tests {
&[],
),
ExecuteMsg::SubmitClaims {
metadata: Binary::new(read_test_data("vc-eddsa-2020-ok.nq")),
claims: Binary::new(read_test_data("vc-eddsa-2020-ok.nq")),
format: Some(RdfDatasetFormat::NQuads),
},
);
Expand Down Expand Up @@ -410,7 +409,7 @@ _:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://example.org/exam
&[],
),
ExecuteMsg::SubmitClaims {
metadata: Binary::new("notrdf".as_bytes().to_vec()),
claims: Binary::new("notrdf".as_bytes().to_vec()),
format: Some(RdfDatasetFormat::NQuads),
},
);
Expand All @@ -429,7 +428,7 @@ _:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://example.org/exam
&[],
),
ExecuteMsg::SubmitClaims {
metadata: Binary::new(vec![]),
claims: Binary::new(vec![]),
format: Some(RdfDatasetFormat::NQuads),
},
);
Expand All @@ -451,7 +450,7 @@ _:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://example.org/exam
&[],
),
ExecuteMsg::SubmitClaims {
metadata: Binary::new(read_test_data("vc-eddsa-2020-ok-unsecured.nq")),
claims: Binary::new(read_test_data("vc-eddsa-2020-ok-unsecured.nq")),
format: Some(RdfDatasetFormat::NQuads),
},
);
Expand All @@ -473,7 +472,7 @@ _:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://example.org/exam
&[],
),
ExecuteMsg::SubmitClaims {
metadata: Binary::new(read_test_data("vc-unsupported-1.nq")),
claims: Binary::new(read_test_data("vc-unsupported-1.nq")),
format: Some(RdfDatasetFormat::NQuads),
},
);
Expand Down Expand Up @@ -524,7 +523,7 @@ _:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://example.org/exam
&[],
),
ExecuteMsg::SubmitClaims {
metadata: Binary::new(read_test_data("vc-eddsa-2020-ok.nq")),
claims: Binary::new(read_test_data("vc-eddsa-2020-ok.nq")),
format: Some(RdfDatasetFormat::NQuads),
},
);
Expand Down
8 changes: 4 additions & 4 deletions contracts/axone-dataverse/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ pub enum ExecuteMsg {
/// - `DataIntegrity` with the following cryptosuites: `eddsa-2022`, `eddsa-rdfc-2022`.
///
SubmitClaims {
/// The serialized metadata intended for attachment.
/// This metadata should adhere to the format specified in the `format` field.
metadata: Binary,
/// RDF dataset serialization format for the metadata.
/// The Verifiable Credential containing the claims.
/// The claims must be serialized in the format specified by the `format` field.
claims: Binary,
/// RDF dataset serialization format for the claims.
/// If not provided, the default format is [N-Quads](https://www.w3.org/TR/n-quads/) format.
format: Option<RdfDatasetFormat>,
},
Expand Down
12 changes: 6 additions & 6 deletions docs/axone-dataverse.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ To maintain integrity and coherence in the dataverse, several preconditions are

- `DataIntegrity` with the following cryptosuites: `eddsa-2022`, `eddsa-rdfc-2022`.

| parameter | description |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `submit_claims` | _(Required.) _ **object**. |
| `submit_claims.format` | **[RdfDatasetFormat](#rdfdatasetformat)\|null**. RDF dataset serialization format for the metadata. If not provided, the default format is [N-Quads](https://www.w3.org/TR/n-quads/) format. |
| `submit_claims.metadata` | _(Required.) _ **[Binary](#binary)**. The serialized metadata intended for attachment. This metadata should adhere to the format specified in the `format` field. |
| parameter | description |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `submit_claims` | _(Required.) _ **object**. |
| `submit_claims.claims` | _(Required.) _ **[Binary](#binary)**. The Verifiable Credential containing the claims. The claims must be serialized in the format specified by the `format` field. |
| `submit_claims.format` | **[RdfDatasetFormat](#rdfdatasetformat)\|null**. RDF dataset serialization format for the claims. If not provided, the default format is [N-Quads](https://www.w3.org/TR/n-quads/) format. |

### ExecuteMsg::RevokeClaims

Expand Down Expand Up @@ -238,5 +238,5 @@ let b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```

---

*Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `axone-dataverse.json` (`70aa81be19dd58f9`)*
*Rendered by [Fadroma](https://fadroma.tech) ([@fadroma/schema 1.1.0](https://www.npmjs.com/package/@fadroma/schema)) from `axone-dataverse.json` (`13c4a7b5af578887`)*
````
Loading