Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,7 @@ pub trait TokenTransitionV0Methods {
token_history_contract: &'a DataContract,
) -> Result<DocumentTypeRef<'a>, ProtocolError>;
/// Historical document id
fn historical_document_id(
&self,
owner_id: Identifier,
owner_nonce: IdentityNonce,
) -> Identifier;
fn historical_document_id(&self, owner_id: Identifier) -> Identifier;
fn associated_token_event(
&self,
token_configuration: &TokenConfiguration,
Expand All @@ -213,7 +209,6 @@ pub trait TokenTransitionV0Methods {
/// Historical document id
fn build_historical_document(
&self,
token_historical_contract: &DataContract,
token_id: Identifier,
owner_id: Identifier,
owner_nonce: IdentityNonce,
Expand Down Expand Up @@ -327,24 +322,21 @@ impl TokenTransitionV0Methods for TokenTransition {
}

/// Historical document id
fn historical_document_id(
&self,
owner_id: Identifier,
owner_nonce: IdentityNonce,
) -> Identifier {
fn historical_document_id(&self, owner_id: Identifier) -> Identifier {
let token_id = self.token_id();
let name = self.historical_document_type_name();
let owner_nonce = self.identity_contract_nonce();
Document::generate_document_id_v0(
&(TOKEN_HISTORY_ID_BYTES.into()),
&token_id,
&owner_id,
name,
format!("history_{}", name).as_str(),
owner_nonce.to_be_bytes().as_slice(),
)
}

/// Historical document id
fn build_historical_document(
&self,
token_historical_contract: &DataContract,
token_id: Identifier,
owner_id: Identifier,
owner_nonce: IdentityNonce,
Expand All @@ -354,7 +346,6 @@ impl TokenTransitionV0Methods for TokenTransition {
) -> Result<Document, ProtocolError> {
self.associated_token_event(token_configuration, owner_id)?
.build_historical_document_owned(
token_historical_contract,
token_id,
owner_id,
owner_nonce,
Expand Down
5 changes: 2 additions & 3 deletions packages/rs-dpp/src/tokens/token_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,16 @@ impl TokenEvent {

pub fn build_historical_document_owned(
self,
token_history_contract: &DataContract,
token_id: Identifier,
owner_id: Identifier,
owner_nonce: IdentityNonce,
block_info: &BlockInfo,
platform_version: &PlatformVersion,
) -> Result<Document, ProtocolError> {
let document_id = Document::generate_document_id_v0(
&token_history_contract.id(),
&token_id,
&owner_id,
self.associated_document_type_name(),
format!("history_{}", self.associated_document_type_name()).as_str(),
owner_nonce.to_be_bytes().as_slice(),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ use drive_abci::platform_types::platform::PlatformRef;
use drive_abci::rpc::core::MockCoreRPCLike;
use tenderdash_abci::proto::abci::ExecTxResult;
use dpp::block::extended_block_info::v0::ExtendedBlockInfoV0Getters;
use dpp::data_contract::associated_token::token_configuration::accessors::v0::TokenConfigurationV0Getters;
use dpp::data_contracts::SystemDataContract;
use dpp::document::serialization_traits::DocumentPlatformConversionMethodsV0;
use dpp::prelude::Identifier;
use dpp::voting::votes::Vote;
use drive::drive::votes::resolved::vote_polls::ResolvedVotePoll;
use drive::drive::votes::resolved::votes::resolved_resource_vote::accessors::v0::ResolvedResourceVoteGettersV0;
Expand Down Expand Up @@ -285,12 +283,7 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed(
.to_string(),
document_type_keeps_history: false,
document_id: token_transition_action
.historical_document_id(
batch_transition.owner_id(),
token_transition_action
.base()
.identity_contract_nonce(),
)
.historical_document_id(batch_transition.owner_id())
.to_vec(),
document_contested_status: 0,
},
Expand Down Expand Up @@ -532,12 +525,7 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed(
document_type_name,
document_type_keeps_history: false,
document_id: token_transition_action
.historical_document_id(
batch_transition.owner_id(),
token_transition_action
.base()
.identity_contract_nonce(),
)
.historical_document_id(batch_transition.owner_id())
.to_buffer(),
block_time_ms: None, //None because we want latest
contested_status:
Expand Down Expand Up @@ -566,7 +554,6 @@ pub(crate) fn verify_state_transitions_were_or_were_not_executed(

let expected_document = token_transition_action
.build_historical_document(
&token_history,
token_id,
batch_transition.owner_id(),
token_transition_action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl Drive {
let document_type = event.associated_document_type(&contract)?;

let document = event.build_historical_document_owned(
&contract,
token_id,
owner_id,
owner_nonce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,24 +128,21 @@ impl TokenTransitionAction {
}

/// Historical document id
pub fn historical_document_id(
&self,
owner_id: Identifier,
owner_nonce: IdentityNonce,
) -> Identifier {
pub fn historical_document_id(&self, owner_id: Identifier) -> Identifier {
let token_id = self.base().token_id();
let name = self.historical_document_type_name();
let owner_nonce = self.base().identity_contract_nonce();
Document::generate_document_id_v0(
&SystemDataContract::TokenHistory.id(),
&token_id,
&owner_id,
name,
format!("history_{}", name).as_str(),
owner_nonce.to_be_bytes().as_slice(),
)
}

/// Historical document id
pub fn build_historical_document(
&self,
token_historical_contract: &DataContract,
token_id: Identifier,
owner_id: Identifier,
owner_nonce: IdentityNonce,
Expand All @@ -154,7 +151,6 @@ impl TokenTransitionAction {
) -> Result<Document, Error> {
self.associated_token_event()
.build_historical_document_owned(
token_historical_contract,
token_id,
owner_id,
owner_nonce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl Drive {
document_type_name: token_history_document_type_name,
document_type_keeps_history: false,
document_id: token_transition
.historical_document_id(owner_id, identity_contract_nonce)
.historical_document_id(owner_id)
.to_buffer(),
block_time_ms: None, //None because we want latest
contested_status:
Expand All @@ -352,7 +352,6 @@ impl Drive {
let document = document.ok_or(Error::Proof(ProofError::IncorrectProof(format!("proof did not contain document with id {} expected to exist because the token keeps historical documents", token_transition.historical_document_type_name()))))?;

let expected_document = token_transition.build_historical_document(
&token_history_contract,
token_id,
owner_id,
identity_contract_nonce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,8 @@ impl TokenTransitionWasm {
}

#[wasm_bindgen(js_name=getHistoricalDocumentId)]
pub fn historical_document_id(
&self,
owner_id: IdentifierWrapper,
owner_nonce: IdentityNonce,
) -> IdentifierWrapper {
self.0
.historical_document_id(owner_id.into(), owner_nonce)
.into()
pub fn historical_document_id(&self, owner_id: IdentifierWrapper) -> IdentifierWrapper {
self.0.historical_document_id(owner_id.into()).into()
}

#[wasm_bindgen(js_name=getIdentityContractNonce)]
Expand Down