IdentityClient

Struct IdentityClient 

Source
pub struct IdentityClient<S = NoSigner> { /* private fields */ }
Expand description

A client for interacting with the IOTA Identity framework.

Implementations§

Source§

impl IdentityClient

Source

pub async fn from_iota_client( iota_client: IotaClient, custom_package_id: impl Into<Option<ObjectID>>, ) -> Result<IdentityClient, FromIotaClientError>

Creates a new IdentityClient, with no signing capabilities, from the given [IotaClient].

§Warning

Passing a custom_package_id is only required when connecting to a custom IOTA network.

Relying on a custom Identity package when connected to an official IOTA network is highly discouraged and is sure to result in compatibility issues when interacting with other official IOTA Trust Framework’s products.

§Examples

let iota_client = iota_sdk::IotaClientBuilder::default()
  .build_testnet()
  .await?;
// No package ID is required since we are connecting to an official IOTA network.
let identity_client = IdentityClient::from_iota_client(iota_client, None).await?;
Source§

impl<S> IdentityClient<S>
where S: Signer<IotaKeySignature>,

Source

pub async fn new( client: IdentityClientReadOnly, signer: S, ) -> Result<IdentityClient<S>, Error>

👎Deprecated since 1.9.0: Use IdentityClient::from_iota_client instead

Creates a new IdentityClient.

Source

pub fn public_key(&self) -> &PublicKey

Returns a reference to the [PublicKey] wrapped by this client.

Source

pub fn address(&self) -> IotaAddress

Returns the [IotaAddress] wrapped by this client.

Source

pub async fn controlled_dids( &self, ) -> Result<Vec<IotaDID>, QueryControlledDidsError>

Returns the list of all unique DIDs the address wrapped by this client can access as a controller.

Source§

impl<S> IdentityClient<S>

Source

pub fn create_identity(&self, iota_document: IotaDocument) -> IdentityBuilder

Returns a new IdentityBuilder in order to build a new crate::rebased::migration::OnChainIdentity.

Source

pub fn create_authenticated_asset<T>( &self, content: T, ) -> AuthenticatedAssetBuilder<T>
where T: MoveType + DeserializeOwned + Send + Sync + PartialEq,

Returns a new IdentityBuilder in order to build a new crate::rebased::migration::OnChainIdentity.

Source

pub async fn with_signer<NewS>( self, signer: NewS, ) -> Result<IdentityClient<NewS>, Error>
where NewS: Signer<IotaKeySignature>,

Sets a new signer for this client.

Source§

impl<S> IdentityClient<S>
where S: Signer<IotaKeySignature> + OptionalSync,

Source

pub fn publish_did_document( &self, document: IotaDocument, ) -> TransactionBuilder<PublishDidDocument>

Returns a PublishDidDocument transaction wrapped by a [TransactionBuilder].

Source

pub async fn publish_did_document_update( &self, document: IotaDocument, gas_budget: u64, ) -> Result<IotaDocument, Error>

Updates a DID Document.

Source

pub async fn deactivate_did_output( &self, did: &IotaDID, gas_budget: u64, ) -> Result<(), Error>

Deactivates a DID document.

Source

pub async fn publish_did_update( &self, did_document: IotaDocument, ) -> Result<TransactionBuilder<ShorthandDidUpdate>, MakeUpdateDidDocTxError>

A shorthand for OnChainIdentity::update_did_document’s DID Document.

This method makes the following assumptions:

  • The given did_document has already been published on-chain within an Identity.
  • This IdentityClient is a controller of the corresponding Identity with enough voting power to execute the transaction without any other controller approval.
Source

pub async fn find_owned_ref<P>( &self, tag: StructTag, predicate: P, ) -> Result<Option<(ObjectID, SequenceNumber, ObjectDigest)>, Error>
where P: Fn(&IotaObjectData) -> bool,

Query the objects owned by the address wrapped by this client to find the object of type tag and that satisfies predicate.

Methods from Deref<Target = IdentityClientReadOnly>§

Source

pub fn package_id(&self) -> ObjectID

Returns iota_identity’s package ID. The ID of the packages depends on the network the client is connected to.

Source

pub fn network(&self) -> &NetworkName

Returns the name of the network the client is currently connected to.

Source

pub fn chain_id(&self) -> &str

Returns the chain identifier for the network this client is connected to. This method differs from IdentityClientReadOnly::network as it doesn’t return the human-readable network ID when available.

Source

pub async fn resolve_did(&self, did: &IotaDID) -> Result<IotaDocument, Error>

Queries an IotaDocument DID Document through its did.

Source

pub async fn get_identity(&self, object_id: ObjectID) -> Result<Identity, Error>

Resolves an Identity from its ID object_id.

Source

pub async fn dids_controlled_by( &self, address: IotaAddress, ) -> Result<Vec<IotaDID>, QueryControlledDidsError>

Returns the list of all unique DIDs the given address has access to as a controller.

§Notes

For a streaming version of this API see dids_controlled_by_streamed.

§Errors

This method might return a QueryControlledDidsError when the underlying RPC call fails. QueryControlledDidsError’s source can be downcasted to SDK’s Error in order to check whether calling this method again might return a successful result.

§Example
let address = "0x666638f5118b8f894c4e60052f9bc47d6fcfb04fdb990c9afbb988848b79c475".parse()?;
let controlled_dids = identity_client.dids_controlled_by(address).await?;
assert_eq!(
  controlled_dids,
  vec![IotaDID::parse(
    "did:iota:testnet:0x052cfb920024f7a640dc17f7f44c6042ea0038d26972c2cff5c7ba31c82fbb08"
  )?]
);

Trait Implementations§

Source§

impl<S> Clone for IdentityClient<S>
where S: Clone,

Source§

fn clone(&self) -> IdentityClient<S>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S> CoreClient<S> for IdentityClient<S>
where S: Signer<IotaKeySignature> + OptionalSync,

Source§

fn sender_address(&self) -> IotaAddress

Returns this Client’s sender address
Source§

fn signer(&self) -> &S

Returns the signer of the client.
Source§

fn sender_public_key(&self) -> &PublicKey

Returns the bytes of the sender’s public key.
Source§

impl<S> CoreClientReadOnly for IdentityClient<S>
where S: OptionalSync,

Source§

fn client_adapter(&self) -> &IotaClientRustSdk

Returns the underlying [IotaClientAdapter] used by this client. Read more
Source§

fn package_id(&self) -> ObjectID

Returns the package ID associated with the Client. Read more
Source§

fn package_history(&self) -> Vec<ObjectID>

Returns the IDs of all packages version, from initial to current.
Source§

fn network_name(&self) -> &NetworkName

Returns the name of the network the client is connected to. Read more
§

fn get_object_by_id<'life0, 'async_trait, T>( &'life0 self, object_id: ObjectID, ) -> Pin<Box<dyn Future<Output = Result<T, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, T: 'async_trait + DeserializeOwned, Self: Sync + 'async_trait,

Retrieves a Move Object by its ID. Read more
§

fn get_object_ref_by_id<'life0, 'async_trait>( &'life0 self, object_id: ObjectID, ) -> Pin<Box<dyn Future<Output = Result<Option<OwnedObjectRef>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sync + 'async_trait,

Retrieves an object’s [OwnedObjectRef], if any. Read more
§

fn find_object_for_address<'life0, 'async_trait, T, P>( &'life0 self, address: IotaAddress, predicate: P, ) -> Pin<Box<dyn Future<Output = Result<Option<T>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, T: MoveType + DeserializeOwned + 'async_trait, P: Fn(&T) -> bool + Send + 'async_trait, Self: Sync + 'async_trait,

Retrieves an object owned by the specified address that matches the given predicate. Read more
§

fn get_iota_coins_with_at_least_balance<'life0, 'async_trait>( &'life0 self, owner: IotaAddress, balance: u64, ) -> Pin<Box<dyn Future<Output = Result<Vec<(ObjectID, SequenceNumber, ObjectDigest)>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sync + 'async_trait,

Retrieves coins owned by the specified address with a balance of at least balance. Read more
§

fn find_owned_ref_for_address<'life0, 'async_trait, P>( &'life0 self, address: IotaAddress, tag: StructTag, predicate: P, ) -> Pin<Box<dyn Future<Output = Result<Option<(ObjectID, SequenceNumber, ObjectDigest)>, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, P: Fn(&IotaObjectData) -> bool + Send + 'async_trait, Self: Sync + 'async_trait,

Queries the object owned by this sender address and returns the first one that matches tag and for which predicate returns true.
Source§

impl<S> Deref for IdentityClient<S>

Source§

type Target = IdentityClientReadOnly

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<IdentityClient<S> as Deref>::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<S> Freeze for IdentityClient<S>
where S: Freeze,

§

impl<S = NoSigner> !RefUnwindSafe for IdentityClient<S>

§

impl<S> Send for IdentityClient<S>
where S: Send,

§

impl<S> Sync for IdentityClient<S>
where S: Sync,

§

impl<S> Unpin for IdentityClient<S>
where S: Unpin,

§

impl<S = NoSigner> !UnwindSafe for IdentityClient<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where T: CastFrom<U>,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Conv for T

§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<T> FmtForward for T

§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a Request
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pipe for T
where T: ?Sized,

§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Tap for T

§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> TryConv for T

§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> OptionalSend for T
where T: Send,

§

impl<T> OptionalSync for T
where T: Sync,