Skip to content

Commit

Permalink
chore: Remove redundant JqExecution and OracleDocumentListSnapshot (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
8e8b2c authored Aug 2, 2024
1 parent 42eeb8d commit fd8d453
Show file tree
Hide file tree
Showing 19 changed files with 7 additions and 542 deletions.
96 changes: 3 additions & 93 deletions crates/holoom_dna_tests/src/tests/username_registry/oracle.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
use hdk::prelude::*;

use holochain::conductor::api::error::ConductorApiResult;
use holoom_types::{
DocumentRelationTag, JqExecution, OracleDocument, OracleDocumentListSnapshot,
RefreshJqExecutionForNamedRelationPayload, SnapshotInput,
};
use username_registry_utils::deserialize_record_entry;
use holoom_types::{DocumentRelationTag, OracleDocument};

use crate::TestSetup;

#[tokio::test(flavor = "multi_thread")]
async fn can_fetch_documents_by_relation() {
let setup = TestSetup::authority_only().await;

let foo1_record: Record = setup
let _foo1_record: Record = setup
.authority_call(
"username_registry",
"create_oracle_document",
Expand All @@ -25,7 +21,7 @@ async fn can_fetch_documents_by_relation() {
.await
.unwrap();

let foo2_record: Record = setup
let _foo2_record: Record = setup
.authority_call(
"username_registry",
"create_oracle_document",
Expand Down Expand Up @@ -72,90 +68,4 @@ async fn can_fetch_documents_by_relation() {

let expected_identifiers = vec![String::from("foo/1"), String::from("foo/2")];
assert_eq!(identifiers, expected_identifiers);

let snapshot_record: Record = setup
.authority_call(
"username_registry",
"refresh_oracle_document_snapshot_for_relation",
String::from("foo"),
)
.await
.unwrap();

let snapshot: OracleDocumentListSnapshot = deserialize_record_entry(snapshot_record).unwrap();

assert_eq!(
snapshot.identifiers_input,
SnapshotInput::RelationSnapshot(expected_identifiers)
);
assert_eq!(
snapshot.resolved_documents,
vec![
foo1_record.action_address().clone(),
foo2_record.action_address().clone()
]
);

let jq_execution_record: Record = setup
.authority_call(
"username_registry",
"refresh_jq_execution_for_named_relation",
RefreshJqExecutionForNamedRelationPayload {
relation_name: "foo".into(),
program: "[.[].value]".into(),
},
)
.await
.unwrap();

let jq_execution: JqExecution = deserialize_record_entry(jq_execution_record).unwrap();
assert_eq!(jq_execution.output, String::from("[1,2]"));

let revised_foo2_record: Record = setup
.authority_call(
"username_registry",
"create_oracle_document",
OracleDocument {
name: "foo/2".into(),
json_data: "{\"type\":\"foo\",\"value\":\"two\"}".into(),
},
)
.await
.unwrap();

let revised_snapshot_record: Record = setup
.authority_call(
"username_registry",
"refresh_oracle_document_snapshot_for_relation",
String::from("foo"),
)
.await
.unwrap();

let revised_snapshot: OracleDocumentListSnapshot =
deserialize_record_entry(revised_snapshot_record).unwrap();

assert_eq!(
revised_snapshot.resolved_documents,
vec![
foo1_record.action_address().clone(),
revised_foo2_record.action_address().clone()
]
);

let revised_jq_execution_record: Record = setup
.authority_call(
"username_registry",
"refresh_jq_execution_for_named_relation",
RefreshJqExecutionForNamedRelationPayload {
relation_name: "foo".into(),
program: "[.[].value]".into(),
},
)
.await
.unwrap();

let revised_jq_execution: JqExecution =
deserialize_record_entry(revised_jq_execution_record).unwrap();
assert_eq!(revised_jq_execution.output, String::from("[1,\"two\"]"));
}
42 changes: 0 additions & 42 deletions crates/holoom_types/src/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,6 @@ pub struct OracleDocument {
pub json_data: String,
}

#[derive(Clone, PartialEq, Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub enum SnapshotInput {
JqExecution(#[ts(type = "ActionHash")] ActionHash),
OracleDocument(#[ts(type = "ActionHash")] ActionHash),
RelationSnapshot(Vec<String>),
}

#[hdk_entry_helper]
#[derive(Clone, PartialEq, TS)]
#[ts(export)]
pub struct OracleDocumentListSnapshot {
/// The action hash of an OracleDocument that gives a list of identifiers
pub identifiers_input: SnapshotInput,
#[ts(type = "ActionHash[]")]
pub resolved_documents: Vec<ActionHash>,
}

#[derive(Clone, PartialEq, Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub enum JqExecutionInput {
OracleDocument(#[ts(type = "ActionHash")] ActionHash),
OracleDocumentListSnapshot(#[ts(type = "ActionHash")] ActionHash),
JqExecution(#[ts(type = "ActionHash")] ActionHash),
}

#[hdk_entry_helper]
#[derive(Clone, PartialEq, TS)]
#[ts(export)]
pub struct JqExecution {
pub program: String,
pub input: JqExecutionInput,
pub output: String,
}

#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct RefreshJqExecutionForNamedRelationPayload {
pub relation_name: String,
pub program: String,
}

#[derive(Serialize, Deserialize, Debug, TS)]
#[ts(export)]
pub struct DocumentRelationTag {
Expand Down
45 changes: 0 additions & 45 deletions crates/username_registry_coordinator/src/jq_execution.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/username_registry_coordinator/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
pub mod evm_signing_offer;
pub mod external_id_attestation;
pub mod jq_execution;
pub mod oracle_document;
pub mod oracle_document_list_snapshot;
pub mod recipe;
pub mod recipe_execution;
pub mod user_metadata;
Expand Down

This file was deleted.

14 changes: 1 addition & 13 deletions crates/username_registry_integrity/src/entry_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use hdi::prelude::*;
use holoom_types::{
evm_signing_offer::EvmSigningOffer,
recipe::{Recipe, RecipeExecution},
ExternalIdAttestation, JqExecution, OracleDocument, OracleDocumentListSnapshot,
UsernameAttestation, WalletAttestation,
ExternalIdAttestation, OracleDocument, UsernameAttestation, WalletAttestation,
};
use username_registry_validation::*;

Expand All @@ -16,8 +15,6 @@ pub enum EntryTypes {
WalletAttestation(WalletAttestation),
ExternalIdAttestation(ExternalIdAttestation),
OracleDocument(OracleDocument),
OracleDocumentListSnapshot(OracleDocumentListSnapshot),
JqExecution(JqExecution),
Recipe(Recipe),
RecipeExecution(RecipeExecution),
EvmSigningOffer(EvmSigningOffer),
Expand Down Expand Up @@ -48,15 +45,6 @@ impl EntryTypes {
EntryCreationAction::Create(action),
oracle_document,
),
EntryTypes::OracleDocumentListSnapshot(oracle_document_list_snapshot) => {
validate_create_oracle_document_list_snapshot(
EntryCreationAction::Create(action),
oracle_document_list_snapshot,
)
}
EntryTypes::JqExecution(jq_execution) => {
validate_create_jq_execution(EntryCreationAction::Create(action), jq_execution)
}
EntryTypes::Recipe(recipe) => {
validate_create_recipe(EntryCreationAction::Create(action), recipe)
}
Expand Down
43 changes: 0 additions & 43 deletions crates/username_registry_validation/src/jq_execution.rs

This file was deleted.

Loading

0 comments on commit fd8d453

Please sign in to comment.