Skip to content

Commit

Permalink
feat(rs-dpp): add entropy getter in the rs dpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pshenmic committed Dec 27, 2024
1 parent 701d1b5 commit d77e1aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ pub trait DocumentTransitionV0Methods {
fn get_dynamic_property(&self, path: &str) -> Option<&Value>;
/// get the id
fn get_id(&self) -> Identifier;
/// get the document type
/// get the entropy
fn entropy(&self) -> Vec<u8>;
fn document_type_name(&self) -> &String;
/// get the data contract id
fn data_contract_id(&self) -> Identifier;
Expand Down Expand Up @@ -167,6 +168,10 @@ impl DocumentTransitionV0Methods for DocumentTransition {
self.base().document_type_name()
}

fn entropy(&self) -> Vec<u8> {

Check warning on line 171 in packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (dpp) / Linting

function cannot return without recursing

warning: function cannot return without recursing --> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:171:5 | 171 | fn entropy(&self) -> Vec<u8> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing 172 | self.entropy() | -------------- recursive call site | = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default

Check warning on line 171 in packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (dash-sdk) / Linting

function cannot return without recursing

warning: function cannot return without recursing --> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:171:5 | 171 | fn entropy(&self) -> Vec<u8> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing 172 | self.entropy() | -------------- recursive call site | = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default

Check warning on line 171 in packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (drive) / Linting

function cannot return without recursing

warning: function cannot return without recursing --> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:171:5 | 171 | fn entropy(&self) -> Vec<u8> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing 172 | self.entropy() | -------------- recursive call site | = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default

Check warning on line 171 in packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (wasm-dpp) / Linting

function cannot return without recursing

warning: function cannot return without recursing --> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:171:5 | 171 | fn entropy(&self) -> Vec<u8> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing 172 | self.entropy() | -------------- recursive call site | = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default

Check warning on line 171 in packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs

View workflow job for this annotation

GitHub Actions / Rust packages (drive-abci) / Linting

function cannot return without recursing

warning: function cannot return without recursing --> packages/rs-dpp/src/state_transition/state_transitions/document/documents_batch_transition/document_transition/mod.rs:171:5 | 171 | fn entropy(&self) -> Vec<u8> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing 172 | self.entropy() | -------------- recursive call site | = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default
self.entropy()
}

fn data_contract_id(&self) -> Identifier {
self.base().data_contract_id()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,8 @@ impl DocumentTransitionWasm {
}
}
#[wasm_bindgen(js_name=getEntropy)]
pub fn get_revision(&self) -> Vec<u8> {
match self.0.clone() {
DocumentTransition::Create(document_transition) => Vec::from(document_transition.entropy()),
DocumentTransition::Replace(document_transition) => Vec::from(document_transition.entropy()),
DocumentTransition::Delete(document_transition) => Vec::from(document_transition.entropy()),
DocumentTransition::Transfer(document_transition) => Vec::from(document_transition.entropy()),
DocumentTransition::UpdatePrice(document_transition) => Vec::from(document_transition.entropy()),
DocumentTransition::Purchase(document_transition) => Vec::from(document_transition.entropy()),
}
pub fn get_entropy(&self) -> Vec<u8> {
self.0.entropy()
}

#[wasm_bindgen(js_name=setRevision)]
Expand Down

0 comments on commit d77e1aa

Please sign in to comment.