Skip to content

Commit

Permalink
Merge 496cbee into 012872a
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod authored Jul 26, 2021
2 parents 012872a + 496cbee commit 3d12e8b
Show file tree
Hide file tree
Showing 26 changed files with 681 additions and 218 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Get the release version from the tag
# if: env.NEAR_CLI_VERSION == ''
run: |
echo "NEAR_CLI_VERSION=0.1.9" >> $GITHUB_ENV
echo "NEAR_CLI_VERSION=0.1.10" >> $GITHUB_ENV
echo "version is: ${{ env.NEAR_CLI_VERSION }}"
- name: Create GitHub release
Expand Down
42 changes: 34 additions & 8 deletions src/commands/add_command/access_key/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ impl Sender {
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<Self> {
let sender_account_id: String = match item.sender_account_id {
Some(cli_sender_account_id) => cli_sender_account_id,
None => Sender::input_sender_account_id(),
Some(cli_sender_account_id) => match &connection_config {
Some(network_connection_config) => match crate::common::check_account_id(
network_connection_config.clone(),
cli_sender_account_id.clone(),
)? {
Some(_) => cli_sender_account_id,
None => {
println!("Account <{}> doesn't exist", cli_sender_account_id);
Sender::input_sender_account_id(connection_config.clone())?
}
},
None => cli_sender_account_id,
},
None => Sender::input_sender_account_id(connection_config.clone())?,
};
let public_key_mode = match item.public_key_mode {
Some(cli_public_key_mode) => super::public_key_mode::PublicKeyMode::from(
Expand All @@ -47,12 +59,26 @@ impl Sender {
}

impl Sender {
pub fn input_sender_account_id() -> String {
println!();
Input::new()
.with_prompt("What is the account ID of the sender?")
.interact_text()
.unwrap()
fn input_sender_account_id(
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<String> {
loop {
let account_id: String = Input::new()
.with_prompt("What account ID do you need to add a key?")
.interact_text()
.unwrap();
if let Some(connection_config) = &connection_config {
if let Some(_) =
crate::common::check_account_id(connection_config.clone(), account_id.clone())?
{
break Ok(account_id);
} else {
println!("Account <{}> doesn't exist", account_id);
}
} else {
break Ok(account_id);
}
}
}

pub async fn process(
Expand Down
42 changes: 34 additions & 8 deletions src/commands/add_command/contract_code/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ impl Sender {
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<Self> {
let sender_account_id: String = match item.sender_account_id {
Some(cli_sender_account_id) => cli_sender_account_id,
None => Sender::input_sender_account_id(),
Some(cli_sender_account_id) => match &connection_config {
Some(network_connection_config) => match crate::common::check_account_id(
network_connection_config.clone(),
cli_sender_account_id.clone(),
)? {
Some(_) => cli_sender_account_id,
None => {
println!("Account <{}> doesn't exist", cli_sender_account_id);
Sender::input_sender_account_id(connection_config.clone())?
}
},
None => cli_sender_account_id,
},
None => Sender::input_sender_account_id(connection_config.clone())?,
};
let contract = match item.contract {
Some(cli_contract) => super::contract::Contract::from(
Expand All @@ -47,12 +59,26 @@ impl Sender {
}

impl Sender {
pub fn input_sender_account_id() -> String {
println!();
Input::new()
.with_prompt("What is the account ID of the contract?")
.interact_text()
.unwrap()
fn input_sender_account_id(
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<String> {
loop {
let account_id: String = Input::new()
.with_prompt("What is the account ID of the contract?")
.interact_text()
.unwrap();
if let Some(connection_config) = &connection_config {
if let Some(_) =
crate::common::check_account_id(connection_config.clone(), account_id.clone())?
{
break Ok(account_id);
} else {
println!("Account <{}> doesn't exist", account_id);
}
} else {
break Ok(account_id);
}
}
}

pub async fn process(
Expand Down
42 changes: 34 additions & 8 deletions src/commands/add_command/stake_proposal/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ impl Sender {
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<Self> {
let sender_account_id: String = match item.sender_account_id {
Some(cli_sender_account_id) => cli_sender_account_id,
None => Sender::input_sender_account_id(),
Some(cli_sender_account_id) => match &connection_config {
Some(network_connection_config) => match crate::common::check_account_id(
network_connection_config.clone(),
cli_sender_account_id.clone(),
)? {
Some(_) => cli_sender_account_id,
None => {
println!("Account <{}> doesn't exist", cli_sender_account_id);
Sender::input_sender_account_id(connection_config.clone())?
}
},
None => cli_sender_account_id,
},
None => Sender::input_sender_account_id(connection_config.clone())?,
};
let transfer: super::transfer_near_tokens_type::Transfer = match item.transfer {
Some(cli_transfer) => super::transfer_near_tokens_type::Transfer::from(
Expand All @@ -47,12 +59,26 @@ impl Sender {
}

impl Sender {
fn input_sender_account_id() -> String {
println!();
Input::new()
.with_prompt("What is the account ID of the validator?")
.interact_text()
.unwrap()
fn input_sender_account_id(
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<String> {
loop {
let account_id: String = Input::new()
.with_prompt("What is the account ID of the validator?")
.interact_text()
.unwrap();
if let Some(connection_config) = &connection_config {
if let Some(_) =
crate::common::check_account_id(connection_config.clone(), account_id.clone())?
{
break Ok(account_id);
} else {
println!("Account <{}> doesn't exist", account_id);
}
} else {
break Ok(account_id);
}
}
}

pub async fn process(
Expand Down
42 changes: 34 additions & 8 deletions src/commands/add_command/sub_account/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ impl Sender {
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<Self> {
let owner_account_id: String = match item.owner_account_id {
Some(cli_owner_account_id) => cli_owner_account_id,
None => Sender::input_owner_account_id(),
Some(cli_owner_account_id) => match &connection_config {
Some(network_connection_config) => match crate::common::check_account_id(
network_connection_config.clone(),
cli_owner_account_id.clone(),
)? {
Some(_) => cli_owner_account_id,
None => {
println!("Account <{}> doesn't exist", cli_owner_account_id);
Sender::input_owner_account_id(connection_config.clone())?
}
},
None => cli_owner_account_id,
},
None => Sender::input_owner_account_id(connection_config.clone())?,
};
let send_to: super::receiver::SendTo = match item.send_to {
Some(cli_send_to) => super::receiver::SendTo::from(
Expand All @@ -44,12 +56,26 @@ impl Sender {
}

impl Sender {
fn input_owner_account_id() -> String {
println!();
Input::new()
.with_prompt("What is the owner account ID?")
.interact_text()
.unwrap()
fn input_owner_account_id(
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<String> {
loop {
let account_id: String = Input::new()
.with_prompt("What is the owner account ID?")
.interact_text()
.unwrap();
if let Some(connection_config) = &connection_config {
if let Some(_) =
crate::common::check_account_id(connection_config.clone(), account_id.clone())?
{
break Ok(account_id);
} else {
println!("Account <{}> doesn't exist", account_id);
}
} else {
break Ok(account_id);
}
}
}

pub async fn process(
Expand Down
42 changes: 34 additions & 8 deletions src/commands/construct_transaction_command/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ impl Sender {
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<Self> {
let sender_account_id: String = match item.sender_account_id {
Some(cli_sender_account_id) => cli_sender_account_id,
None => Sender::input_sender_account_id(),
Some(cli_sender_account_id) => match &connection_config {
Some(network_connection_config) => match crate::common::check_account_id(
network_connection_config.clone(),
cli_sender_account_id.clone(),
)? {
Some(_) => cli_sender_account_id,
None => {
println!("Account <{}> doesn't exist", cli_sender_account_id);
Sender::input_sender_account_id(connection_config.clone())?
}
},
None => cli_sender_account_id,
},
None => Sender::input_sender_account_id(connection_config.clone())?,
};
let send_to: super::receiver::SendTo = match item.send_to {
Some(cli_send_to) => super::receiver::SendTo::from(
Expand All @@ -44,12 +56,26 @@ impl Sender {
}

impl Sender {
pub fn input_sender_account_id() -> String {
println!();
Input::new()
.with_prompt("What is the account ID of the sender?")
.interact_text()
.unwrap()
fn input_sender_account_id(
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<String> {
loop {
let account_id: String = Input::new()
.with_prompt("What is the account ID of the sender?")
.interact_text()
.unwrap();
if let Some(connection_config) = &connection_config {
if let Some(_) =
crate::common::check_account_id(connection_config.clone(), account_id.clone())?
{
break Ok(account_id);
} else {
println!("Account <{}> doesn't exist", account_id);
}
} else {
break Ok(account_id);
}
}
}

pub async fn process(
Expand Down
42 changes: 34 additions & 8 deletions src/commands/delete_command/access_key/sender/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ impl Sender {
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<Self> {
let sender_account_id: String = match item.sender_account_id {
Some(cli_sender_account_id) => cli_sender_account_id,
None => Sender::input_sender_account_id(),
Some(cli_sender_account_id) => match &connection_config {
Some(network_connection_config) => match crate::common::check_account_id(
network_connection_config.clone(),
cli_sender_account_id.clone(),
)? {
Some(_) => cli_sender_account_id,
None => {
println!("Account <{}> doesn't exist", cli_sender_account_id);
Sender::input_sender_account_id(connection_config.clone())?
}
},
None => cli_sender_account_id,
},
None => Sender::input_sender_account_id(connection_config.clone())?,
};
let public_key = match item.public_key {
Some(cli_delete_access_key) => super::DeleteAccessKeyAction::from(
Expand All @@ -47,12 +59,26 @@ impl Sender {
}

impl Sender {
fn input_sender_account_id() -> String {
println!();
Input::new()
.with_prompt("Which account ID do you need to remove the key from?")
.interact_text()
.unwrap()
fn input_sender_account_id(
connection_config: Option<crate::common::ConnectionConfig>,
) -> color_eyre::eyre::Result<String> {
loop {
let account_id: String = Input::new()
.with_prompt("Which account ID do you need to remove the key from?")
.interact_text()
.unwrap();
if let Some(connection_config) = &connection_config {
if let Some(_) =
crate::common::check_account_id(connection_config.clone(), account_id.clone())?
{
break Ok(account_id);
} else {
println!("Account <{}> doesn't exist", account_id);
}
} else {
break Ok(account_id);
}
}
}

pub async fn process(
Expand Down
Loading

0 comments on commit 3d12e8b

Please sign in to comment.