-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added a new command to manage BOS profile in SocialDB (#231)
- Loading branch information
Showing
29 changed files
with
1,431 additions
and
169 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,46 @@ | ||
mod profile_args_type; | ||
mod sign_as; | ||
|
||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] | ||
pub struct TransactionFunctionArgs { | ||
pub data: near_socialdb_client::types::socialdb_types::SocialDb, | ||
} | ||
|
||
#[derive(Debug, Clone, interactive_clap::InteractiveClap)] | ||
#[interactive_clap(input_context = crate::GlobalContext)] | ||
#[interactive_clap(output_context = UpdateSocialProfileContext)] | ||
pub struct UpdateSocialProfile { | ||
#[interactive_clap(skip_default_input_arg)] | ||
account_id: crate::types::account_id::AccountId, | ||
#[interactive_clap(subcommand)] | ||
profile_args_type: self::profile_args_type::ProfileArgsType, | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct UpdateSocialProfileContext { | ||
pub global_context: crate::GlobalContext, | ||
pub account_id: near_primitives::types::AccountId, | ||
} | ||
|
||
impl UpdateSocialProfileContext { | ||
pub fn from_previous_context( | ||
previous_context: crate::GlobalContext, | ||
scope: &<UpdateSocialProfile as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope, | ||
) -> color_eyre::eyre::Result<Self> { | ||
Ok(Self { | ||
global_context: previous_context, | ||
account_id: scope.account_id.clone().into(), | ||
}) | ||
} | ||
} | ||
|
||
impl UpdateSocialProfile { | ||
pub fn input_account_id( | ||
context: &crate::GlobalContext, | ||
) -> color_eyre::eyre::Result<Option<crate::types::account_id::AccountId>> { | ||
crate::common::input_non_signer_account_id_from_used_account_list( | ||
&context.config.credentials_home_dir, | ||
"Which account do you want to update the profile for?", | ||
) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/commands/account/update_social_profile/profile_args_type/base64_args.rs
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,32 @@ | ||
#[derive(Debug, Clone, interactive_clap::InteractiveClap)] | ||
#[interactive_clap(input_context = super::super::UpdateSocialProfileContext)] | ||
#[interactive_clap(output_context = Base64ArgsContext)] | ||
pub struct Base64Args { | ||
/// Enter valid Base64-encoded string (e.g. e30=): | ||
data: crate::types::base64_bytes::Base64Bytes, | ||
#[interactive_clap(named_arg)] | ||
/// Specify signer account ID | ||
sign_as: super::super::sign_as::Signer, | ||
} | ||
|
||
#[derive(Clone)] | ||
pub struct Base64ArgsContext(super::ArgsContext); | ||
|
||
impl Base64ArgsContext { | ||
pub fn from_previous_context( | ||
previous_context: super::super::UpdateSocialProfileContext, | ||
scope: &<Base64Args as interactive_clap::ToInteractiveClapContextScope>::InteractiveClapContextScope, | ||
) -> color_eyre::eyre::Result<Self> { | ||
Ok(Self(super::ArgsContext { | ||
global_context: previous_context.global_context, | ||
account_id: previous_context.account_id, | ||
data: scope.data.clone().into_bytes(), | ||
})) | ||
} | ||
} | ||
|
||
impl From<Base64ArgsContext> for super::ArgsContext { | ||
fn from(item: Base64ArgsContext) -> Self { | ||
item.0 | ||
} | ||
} |
Oops, something went wrong.