Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare public Identity interface for future wasm-bindings #1429

Open
wants to merge 2 commits into
base: feat/identity-rebased
Choose a base branch
from
Open
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
11 changes: 5 additions & 6 deletions identity_iota_core/src/rebased/assets/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use iota_sdk::types::base_types::SequenceNumber;
use iota_sdk::types::id::UID;
use iota_sdk::types::object::Owner;
use iota_sdk::types::TypeTag;
use iota_sdk::IotaClient;
use move_core_types::ident_str;
use move_core_types::language_storage::StructTag;
use secret_storage::Signer;
Expand Down Expand Up @@ -69,7 +68,7 @@ where
T: DeserializeOwned,
{
/// Resolves an [`AuthenticatedAsset`] by its ID `id`.
pub async fn get_by_id(id: ObjectID, client: &IotaClient) -> Result<Self, Error> {
pub async fn get_by_id<S>(id: ObjectID, client: &IdentityClient<S>) -> Result<Self, Error> {
let res = client
.read_api()
.get_object_with_options(id, IotaObjectDataOptions::new().with_content())
Expand All @@ -89,7 +88,7 @@ where
}

impl<T> AuthenticatedAsset<T> {
async fn object_ref(&self, client: &IotaClient) -> Result<ObjectRef, Error> {
async fn object_ref<S>(&self, client: &IdentityClient<S>) -> Result<ObjectRef, Error> {
client
.read_api()
.get_object_with_options(self.id(), IotaObjectDataOptions::default())
Expand Down Expand Up @@ -259,7 +258,7 @@ impl MoveType for TransferProposal {

impl TransferProposal {
/// Resolves a [`TransferProposal`] by its ID `id`.
pub async fn get_by_id(id: ObjectID, client: &IotaClient) -> Result<Self, Error> {
pub async fn get_by_id<S>(id: ObjectID, client: &IdentityClient<S>) -> Result<Self, Error> {
let res = client
.read_api()
.get_object_with_options(id, IotaObjectDataOptions::new().with_content())
Expand Down Expand Up @@ -294,7 +293,7 @@ impl TransferProposal {
})
}

async fn asset_metadata(&self, client: &IotaClient) -> anyhow::Result<(ObjectRef, TypeTag)> {
async fn asset_metadata<S>(&self, client: &IdentityClient<S>) -> anyhow::Result<(ObjectRef, TypeTag)> {
let res = client
.read_api()
.get_object_with_options(self.asset_id, IotaObjectDataOptions::default().with_type())
Expand All @@ -318,7 +317,7 @@ impl TransferProposal {
Ok((asset_ref, param_type))
}

async fn initial_shared_version(&self, client: &IotaClient) -> anyhow::Result<SequenceNumber> {
async fn initial_shared_version<S>(&self, client: &IdentityClient<S>) -> anyhow::Result<SequenceNumber> {
let owner = client
.read_api()
.get_object_with_options(*self.id.object_id(), IotaObjectDataOptions::default().with_owner())
Expand Down
2 changes: 1 addition & 1 deletion identity_iota_core/src/rebased/client/full_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<S> Deref for IdentityClient<S> {

impl<S> IdentityClient<S>
where
S: Signer<IotaKeySignature>,
S: Signer<IotaKeySignature> + Sync,
{
pub async fn new(client: IdentityClientReadOnly, signer: S) -> Result<Self, Error> {
let public_key = signer
Expand Down
3 changes: 3 additions & 0 deletions identity_iota_core/src/rebased/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,7 @@ pub enum Error {
/// An error caused by either a connection issue or an invalid RPC call.
#[error("RPC error: {0}")]
RpcError(String),
/// An error caused by a bcs serialization or deserialization.
#[error("BCS error: {0}")]
BcsError(#[from] bcs::Error),
}