Skip to content

Commit

Permalink
Merge dc9d207 into 25bf3dd
Browse files Browse the repository at this point in the history
  • Loading branch information
FroVolod authored Jun 23, 2021
2 parents 25bf3dd + dc9d207 commit 0dcaaa6
Show file tree
Hide file tree
Showing 24 changed files with 540 additions and 351 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.3" >> $GITHUB_ENV
echo "NEAR_CLI_VERSION=0.1.4" >> $GITHUB_ENV
echo "version is: ${{ env.NEAR_CLI_VERSION }}"
- name: Create GitHub release
Expand Down
9 changes: 9 additions & 0 deletions docs/GUIDE.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -847,3 +847,12 @@ Given a base64-encoded string, we should be able to view the human-readable repr
<img src="https://asciinema.org/a/Gtb4M13a8QW5VaVmfgBLEcq3X.png" width="836"/>
</a>
</details>

#### Send signed transaction

Given the base64 encoded string, we should be able to send it for execution.
<details><summary><i>Demonstration of the command in interactive mode</i></summary>
<a href="https://asciinema.org/a/4g9yN7PFBdBSeQRxPc8ydfpWs?autoplay=1&t=1&speed=2">
<img src="https://asciinema.org/a/4g9yN7PFBdBSeQRxPc8ydfpWs.png" width="836"/>
</a>
</details>
9 changes: 9 additions & 0 deletions docs/GUIDE.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -858,3 +858,12 @@ https://explorer.wallet.testnet.near.org/EhhLMtUEmLHV4bzdvSmzv9pLyUbKChGgtWKhuPR
<img src="https://asciinema.org/a/Gtb4M13a8QW5VaVmfgBLEcq3X.png" width="836"/>
</a>
</details>

#### Send signed transaction

Данная утилита позволяет закодированную в Base64 подписанную транзакцию отправить в обработку.
<details><summary><i>Демонстрация работы команды в интерактивном режиме</i></summary>
<a href="https://asciinema.org/a/4g9yN7PFBdBSeQRxPc8ydfpWs?autoplay=1&t=1&speed=2">
<img src="https://asciinema.org/a/4g9yN7PFBdBSeQRxPc8ydfpWs.png" width="836"/>
</a>
</details>
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,11 @@ impl FullAccessType {
.await?
{
Some(transaction_info) => {
match transaction_info.status {
near_primitives::views::FinalExecutionStatus::NotStarted
| near_primitives::views::FinalExecutionStatus::Started => unreachable!(),
near_primitives::views::FinalExecutionStatus::Failure(tx_execution_error) => {
crate::common::print_transaction_error(tx_execution_error).await
}
near_primitives::views::FinalExecutionStatus::SuccessValue(_) => {
match transaction_info.transaction.actions[0].clone() {
near_primitives::views::ActionView::AddKey {
public_key,
access_key: _,
} => {
println!(
"Added full access key = {:?} to {}.",
public_key, transaction_info.transaction.signer_id,
);
}
_ => unreachable!("Error"),
}
}
}
let transaction_explorer: url::Url = match network_connection_config {
Some(connection_config) => connection_config.transaction_explorer(),
None => unreachable!("Error"),
};
println!("\nTransaction Id {id}.\n\nTo see the transaction in the transaction explorer, please open this url in your browser:
\n{path}{id}\n", id=transaction_info.transaction_outcome.id, path=transaction_explorer);
crate::common::print_transaction_status(
transaction_info,
network_connection_config,
)
.await;
}
None => {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,18 @@ impl FunctionCallType {
};
match self
.sign_option
.process(unsigned_transaction.clone(), network_connection_config)
.process(
unsigned_transaction.clone(),
network_connection_config.clone(),
)
.await?
{
Some(transaction_info) => {
println!(
"Added function access key = {:?} to {}.",
public_key, unsigned_transaction.signer_id,
);
println!("\nTransaction Id {id}.\n\nTo see the transaction in the transaction explorer, please open this url in your browser:
\nhttps://explorer.testnet.near.org/transactions/{id}\n", id=transaction_info.transaction_outcome.id);
crate::common::print_transaction_status(
transaction_info,
network_connection_config,
)
.await;
}
None => {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ impl CallFunctionAction {
self,
prepopulated_unsigned_transaction: near_primitives::transaction::Transaction,
network_connection_config: Option<crate::common::ConnectionConfig>,
file_path: std::path::PathBuf,
) -> crate::CliResult {
let action = near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
Expand All @@ -135,30 +134,11 @@ impl CallFunctionAction {
.await?
{
Some(transaction_info) => {
match transaction_info.status {
near_primitives::views::FinalExecutionStatus::NotStarted
| near_primitives::views::FinalExecutionStatus::Started => unreachable!(),
near_primitives::views::FinalExecutionStatus::Failure(tx_execution_error) => {
crate::common::print_transaction_error(tx_execution_error).await
}
near_primitives::views::FinalExecutionStatus::SuccessValue(_) => {
match transaction_info.transaction.actions[0] {
near_primitives::views::ActionView::DeployContract { code: _ } => {
println!(
"\n Contract code {:?} has been successfully deployed.",
file_path
);
}
_ => unreachable!("Error"),
}
}
}
let transaction_explorer: url::Url = match network_connection_config {
Some(connection_config) => connection_config.transaction_explorer(),
None => unreachable!("Error"),
};
println!("\nTransaction Id {id}.\n\nTo see the transaction in the transaction explorer, please open this url in your browser:
\n{path}{id}\n", id=transaction_info.transaction_outcome.id, path=transaction_explorer);
crate::common::print_transaction_status(
transaction_info,
network_connection_config,
)
.await;
}
None => {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,16 @@ impl NextAction {
self,
prepopulated_unsigned_transaction: near_primitives::transaction::Transaction,
network_connection_config: Option<crate::common::ConnectionConfig>,
file_path: std::path::PathBuf,
) -> crate::CliResult {
match self {
NextAction::Initialize(call_function_action) => {
call_function_action
.process(
prepopulated_unsigned_transaction,
network_connection_config,
file_path,
)
.process(prepopulated_unsigned_transaction, network_connection_config)
.await
}
NextAction::NoInitialize(no_initialize) => {
no_initialize
.process(
prepopulated_unsigned_transaction,
network_connection_config,
file_path,
)
.process(prepopulated_unsigned_transaction, network_connection_config)
.await
}
}
Expand Down Expand Up @@ -115,7 +106,6 @@ impl NoInitialize {
self,
prepopulated_unsigned_transaction: near_primitives::transaction::Transaction,
network_connection_config: Option<crate::common::ConnectionConfig>,
file_path: std::path::PathBuf,
) -> crate::CliResult {
match self
.sign_option
Expand All @@ -126,30 +116,11 @@ impl NoInitialize {
.await?
{
Some(transaction_info) => {
match transaction_info.status {
near_primitives::views::FinalExecutionStatus::NotStarted
| near_primitives::views::FinalExecutionStatus::Started => unreachable!(),
near_primitives::views::FinalExecutionStatus::Failure(tx_execution_error) => {
crate::common::print_transaction_error(tx_execution_error).await
}
near_primitives::views::FinalExecutionStatus::SuccessValue(_) => {
match transaction_info.transaction.actions[0] {
near_primitives::views::ActionView::DeployContract { code: _ } => {
println!(
"\n Contract code {:?} has been successfully deployed.",
file_path
);
}
_ => unreachable!("Error"),
}
}
}
let transaction_explorer: url::Url = match network_connection_config {
Some(connection_config) => connection_config.transaction_explorer(),
None => unreachable!("Error"),
};
println!("\nTransaction Id {id}.\n\nTo see the transaction in the transaction explorer, please open this url in your browser:
\n{path}{id}\n", id=transaction_info.transaction_outcome.id, path=transaction_explorer);
crate::common::print_transaction_status(
transaction_info,
network_connection_config,
)
.await;
}
None => {}
};
Expand Down
6 changes: 1 addition & 5 deletions src/commands/add_command/contract_code/contract/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ impl ContractFile {
..prepopulated_unsigned_transaction
};
self.next_action
.process(
unsigned_transaction,
network_connection_config,
self.file_path,
)
.process(unsigned_transaction, network_connection_config)
.await
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,34 +115,11 @@ impl TransactionsSigningAction {
.await?
{
Some(transaction_info) => {
match transaction_info.status {
near_primitives::views::FinalExecutionStatus::NotStarted
| near_primitives::views::FinalExecutionStatus::Started => unreachable!(),
near_primitives::views::FinalExecutionStatus::Failure(tx_execution_error) => {
crate::common::print_transaction_error(tx_execution_error).await
}
near_primitives::views::FinalExecutionStatus::SuccessValue(_) => {
match transaction_info.transaction.actions[0] {
near_primitives::views::ActionView::Stake {
stake,
public_key: _,
} => {
println!(
"\nValidator <{}> has successfully staked {}.",
transaction_info.transaction.signer_id,
crate::common::NearBalance::from_yoctonear(stake),
);
}
_ => unreachable!("Error"),
}
}
}
let transaction_explorer: url::Url = match network_connection_config {
Some(connection_config) => connection_config.transaction_explorer(),
None => unreachable!("Error"),
};
println!("\nTransaction Id {id}.\n\nTo see the transaction in the transaction explorer, please open this url in your browser:
\n{path}{id}\n", id=transaction_info.transaction_outcome.id, path=transaction_explorer);
crate::common::print_transaction_status(
transaction_info,
network_connection_config,
)
.await;
}
None => {}
};
Expand Down
24 changes: 5 additions & 19 deletions src/commands/add_command/sub_account/deposit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,11 @@ impl TransferNEARTokensAction {
.await?
{
Some(transaction_info) => {
match transaction_info.status {
near_primitives::views::FinalExecutionStatus::NotStarted
| near_primitives::views::FinalExecutionStatus::Started => unreachable!(),
near_primitives::views::FinalExecutionStatus::Failure(tx_execution_error) => {
crate::common::print_transaction_error(tx_execution_error).await
}
near_primitives::views::FinalExecutionStatus::SuccessValue(_) => {
println!(
"\nNew account <{}> has been successfully created.",
transaction_info.transaction.receiver_id,
);
}
}
let transaction_explorer: url::Url = match network_connection_config {
Some(connection_config) => connection_config.transaction_explorer(),
None => unreachable!("Error"),
};
println!("\nTransaction Id {id}.\n\nTo see the transaction in the transaction explorer, please open this url in your browser:
\n{path}{id}\n", id=transaction_info.transaction_outcome.id, path=transaction_explorer);
crate::common::print_transaction_status(
transaction_info,
network_connection_config,
)
.await;
}
None => {}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,7 @@ impl Submit {
) -> color_eyre::eyre::Result<Option<near_primitives::views::FinalExecutionOutcomeView>> {
match self {
Submit::Send => {
println!("\n\n\n========= SENT =========");
println!(
"\n\n--- Signed transaction: ---\n {:#?}",
&signed_transaction
);
println!(
"\n\n--- serialize_to_base64: --- \n {:#?}",
&serialize_to_base64
);
println!("Transaction sent ...");
let json_rcp_client =
near_jsonrpc_client::new_client(network_connection_config.rpc_url().as_str());
let transaction_info = loop {
Expand Down Expand Up @@ -312,7 +304,6 @@ impl Submit {
}
};
};
println!("\n\n--- Transaction execution: ---\n");
Ok(Some(transaction_info))
}
Submit::Display => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl Submit {
) -> color_eyre::eyre::Result<Option<near_primitives::views::FinalExecutionOutcomeView>> {
match self {
Submit::Send => {
println!("\n\n\n--- Transaction sent ---");
println!("Transaction sent ...");
let json_rcp_client =
near_jsonrpc_client::new_client(network_connection_config.rpc_url().as_str());
let transaction_info = loop {
Expand Down Expand Up @@ -266,7 +266,6 @@ impl Submit {
}
};
};
println!("\n\n--- Transaction execution: ---\n");
Ok(Some(transaction_info))
}
Submit::Display => {
Expand Down
Loading

0 comments on commit 0dcaaa6

Please sign in to comment.