pub trait BroadcastRequestForStateTransition: Send + Debug + Clone {
    // Required methods
    fn broadcast_request_for_state_transition(
        &self,
    ) -> Result<BroadcastStateTransitionRequest, Error>;
    fn wait_for_state_transition_result_request(
        &self,
    ) -> Result<WaitForStateTransitionResultRequest, Error>;
}
Expand description

Trait implemented by objects that can be used to broadcast new identity state transitions.

[BroadcastRequestForNewIdentity] trait is used when a new identity needs to be created and broadcasted on Platform. It encapsulates the data, the signing process, and the logic required to perform the broadcast operation.

Implementors of this trait will typically be responsible for creating an identity state transition, signing it with the provided private key and signer, and preparing it for transport to Platform.

§Example

To broadcast a new Identity state transition, you would typically create an IdentityCreateTransition, sign it, and use the broadcast_new_identity method provided by this trait:


use dash_sdk::{Sdk, platform::{BroadcastNewIdentity, IdentityCreateTransition}};
use dpp::identity::signer::Signer;
use dpp::prelude::{AssetLockProof, PrivateKey};
use dpp::version::PlatformVersion;

let mut sdk = Sdk::new_mock();
let asset_lock_proof = AssetLockProof::new(/* parameters for the asset lock proof */);
let private_key = PrivateKey::from(/* private key data */);
let signer = /* implementation of Signer trait */;
let platform_version = PlatformVersion::latest();

let identity_transition = IdentityCreateTransition::new(/* parameters for the transition */);
let result = identity_transition.broadcast_new_identity(asset_lock_proof, private_key, &signer, &platform_version);

match result {
    Ok(transport_request) => {
        // The transport_request can now be sent to Platform to broadcast the new identity.
    }
    Err(e) => {
        // Handle the error
    }
}

As BroadcastRequestForStateTransition is a trait, it can be implemented for any type that represents a new identity creation operation, allowing for flexibility in how new identities are broadcasted.

Required Methods§

source

fn broadcast_request_for_state_transition( &self, ) -> Result<BroadcastStateTransitionRequest, Error>

Converts the current instance into an instance of the TransportRequest type, ready for broadcasting.

This method takes ownership of the instance upon which it’s called (hence self), and attempts to perform the conversion, including signing the state transition with the provided private key and signer.

§Arguments
  • asset_lock_proof - The proof that locks the asset which is used to create the identity.
  • asset_lock_proof_private_key - The private key associated with the asset lock proof.
  • signer - The signer to be used for signing the state transition.
  • platform_version - The version of Platform for which the state transition is intended.
§Returns

On success, this method yields an instance of the TransportRequest type (T), which can be used to broadcast the new identity state transition to Platform. On failure, it yields an Error.

§Error Handling

This method propagates any errors encountered during the signing or conversion process. These are returned as Error instances.

source

fn wait_for_state_transition_result_request( &self, ) -> Result<WaitForStateTransitionResultRequest, Error>

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl BroadcastRequestForStateTransition for StateTransition

Implementors§