-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat/162/add wallet endpoints (#239)
Signed-off-by: Moriarty <[email protected]>
- Loading branch information
1 parent
5e6f8bf
commit c563262
Showing
14 changed files
with
472 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
use crate::error::Result; | ||
use async_trait::async_trait; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Options that are supplied when querying a wallet for DIDs | ||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct Did { | ||
/// The DID of interest | ||
pub did: Option<String>, | ||
|
||
// TODO: enum | ||
/// The key type to query for eg. ed25519, bls12381g2 | ||
pub key_type: Option<String>, | ||
|
||
// TODO: enum | ||
/// DID method to query for. e.g. sov to only fetch indy/sov DIDs Available values : key, sov | ||
pub method: Option<String>, | ||
|
||
// TODO: enum | ||
/// The DID posture specifying whether the DID is | ||
/// the current public DID, | ||
/// posted to ledger but current public DID, | ||
/// or local to the wallet | ||
/// Available values : public, posted, wallet_only | ||
pub posture: Option<String>, | ||
|
||
/// The verification key of interest | ||
pub verkey: Option<String>, | ||
} | ||
|
||
/// Response from the cloudagent when requesting info about dids | ||
/// of a wallet | ||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct DidList(Vec<Did>); | ||
|
||
/// Response from the cloudagent when requesting info about dids | ||
/// of a wallet | ||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct DidResult(Did); | ||
|
||
/// Key type in a JSON format k,v pair | ||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct KeyType { | ||
// TODO: enum | ||
/// The key type to query for eg. ed25519, bls12381g2 | ||
pub key_type: String, | ||
} | ||
|
||
/// Options that are supplied when querying a wallet for DIDs | ||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct CreateLocalDidOptions { | ||
/// DID method to query for. e.g. sov to only fetch indy/sov DIDs Available values : key, sov | ||
pub method: String, | ||
|
||
/// The key type to query for eg. ed25519, bls12381g2 | ||
pub options: KeyType, | ||
} | ||
|
||
/// Options that are supplied when querying a wallet for DIDs | ||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct DidEndpoint { | ||
/// The DID of interest | ||
pub did: String, | ||
|
||
/// The endpoint url | ||
pub endpoint: String, | ||
} | ||
|
||
/// Options that are supplied when querying a wallet for DIDs | ||
#[derive(Debug, Deserialize, Serialize)] | ||
pub struct SetDidEndpointOptions { | ||
/// The DID of interest | ||
pub did: String, | ||
|
||
/// The endpoint url | ||
pub endpoint: String, | ||
|
||
///The endpoint type eg. 'Endpoint' | ||
pub endpoint_type: String, | ||
} | ||
|
||
/// Generic cloudagent basic message module | ||
#[async_trait] | ||
pub trait WalletModule { | ||
/// Query a wallet for DIDs | ||
async fn get_wallet_dids(&self, options: Did) -> Result<DidList>; | ||
|
||
/// Create a local DID | ||
async fn create_local_did(&self, options: CreateLocalDidOptions) -> Result<Did>; | ||
|
||
/// Rotate key pair | ||
async fn rotate_keypair(&self, did: String) -> Result<()>; | ||
|
||
/// Fetch public did | ||
async fn fetch_public_did(&self) -> Result<Did>; | ||
|
||
/// Assign the current public DID | ||
async fn assign_public_did(&self, did: String) -> Result<Did>; | ||
|
||
/// Query DID endpoint of wallet | ||
async fn fetch_did_endpoint(&self, did: String) -> Result<DidEndpoint>; | ||
|
||
/// Set DID endpoint of wallet | ||
async fn set_did_endpoint(&self, options: SetDidEndpointOptions) -> Result<()>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.