diff --git a/docs/GUIDE.en.md b/docs/GUIDE.en.md
index 6299c78bc..fa01a37c7 100644
--- a/docs/GUIDE.en.md
+++ b/docs/GUIDE.en.md
@@ -5,10 +5,10 @@ overview of its capabilities. This guide assumes that _near CLI_ is
[installed](README.md#installation)
and that readers have passing familiarity with using command line tools. This
also assumes a Unix-like system, although most commands are probably easily
-translatable to any command line shell environment.
+translatable to any command line shell environment.
With _near CLI_ you can create, sign and send transactions in _online_ mode, which is enabled by default.
-In _offline_ mode, you can create and sign a transaction. The base64 encoding transaction can be [signed](#sign-transaction---sign-previously-prepared-unsigned-transaction) or [sent](#send-signed-transaction---send-a-signed-transaction) later (even from another computer). To enter the _offline_ mode, you need to set the ```--offline``` flag in the command:
+In _offline_ mode, you can create and sign a transaction. The base64 encoding transaction can be [signed](#sign-transaction---sign-previously-prepared-unsigned-transaction) or [sent](#send-signed-transaction---send-a-signed-transaction) later (even from another computer). To enter the _offline_ mode, you need to set the ```--offline``` flag in the command:
```txt
near --offline tokens \
fro_volod.testnet \
@@ -30,9 +30,9 @@ Before proceeding to the description of specific commands, it is necessary to co
- _sign-with-keychain - Sign the transaction with a key saved in legacy keychain (compatible with the old near CLI)_
- _near CLI_ will independently find access keys and sign the created transaction.
+ _near CLI_ will independently find access keys and sign the created transaction.
Directory with access keys defined in [config](#config---manage-connections-in-a-configuration-file).
- The access keys must be in the _public-key.json_ file located in _/Users/user/.near-credentials/network-name/user-name/_
+ The access keys must be in the _public-key.json_ file located in _/Users/user/.near-credentials/network-name/user-name/_
For example, _/Users/frovolod/.near-credentials/testnet/volodymyr.testnet/ed25519_8h7kFK4quSUJRkUwo3LLiK83sraEm2jnQTECuZhWu8HC.json_
Demonstration of the command in interactive mode
@@ -42,7 +42,7 @@ Before proceeding to the description of specific commands, it is necessary to co
- _sign-with-ledger - Sign the transaction with Ledger Nano device_
-
+
This option involves signing the created transaction using a ledger.
- _sign-with-plaintext-private-key - Sign the transaction with a plaintext private key_
@@ -65,11 +65,11 @@ Before proceeding to the description of specific commands, it is necessary to co
2. Actions with a signed transaction
- _near CLI_ support for meta transactions as specified in [NEP-366](https://near.github.io/nearcore/architecture/how/meta-tx.html#meta-transactions). To create it, you just need to specify a _network_ that supports meta transactions. You can find out about such support in [config](#show-connections---Show-a-list-of-network-connections). The *meta_transaction_relayer_url* field is responsible for the ability to support meta transactions. For example:
+ _near CLI_ support for meta transactions as specified in [NEP-366](https://near.github.io/nearcore/architecture/how/meta-tx.html#meta-transactions). To create it, you just need to specify a _network_ that supports meta transactions. You can find out about such support in [config](#show-connections---Show-a-list-of-network-connections). The *meta_transaction_relayer_url* field is responsible for the ability to support meta transactions. For example:
```txt
meta_transaction_relayer_url = "https://near-testnet.api.pagoda.co/relay"
```
-
+
A signed transaction / meta transactions can be sent for immediate execution:
- _send - Send the transaction to the network_
@@ -82,6 +82,7 @@ Before proceeding to the description of specific commands, it is necessary to co
- [account - Manage accounts](#account---Manage-accounts)
- [tokens - Manage token assets such as NEAR, FT, NFT](#tokens---Manage-token-assets-such-as-NEAR-FT-NFT)
+- [staking - Manage staking: view, add and withdraw stake](#staking---Manage-staking-view-add-and-withdraw-stake)
- [contract - Manage smart-contracts: deploy code, call functions](#contract---Manage-smart-contracts-deploy-code-call-functions)
- [transaction - Operate transactions](#transaction---Operate-transactions)
- [config - Manage connections in a configuration file](#config---Manage-connections-in-a-configuration-file)
@@ -245,7 +246,7 @@ near account \
network-config testnet
```
-You will be redirected to the browser for authorization.
+You will be redirected to the browser for authorization.
Default wallet url is https://app.mynearwallet.com/ (for testnet - https://testnet.mynearwallet.com/). But if you want to change to a different wallet url, you can use `--wallet-url` option:
```txt
near account \
@@ -333,7 +334,7 @@ near account \
network-config testnet
```
-You will be redirected to the browser for authorization.
+You will be redirected to the browser for authorization.
Default wallet url is https://app.mynearwallet.com/ (for testnet - https://testnet.mynearwallet.com/). But if you want to change to a different wallet url, you can use `--wallet-url` option:
```txt
near account \
@@ -391,9 +392,9 @@ Here is the private key for account : ed25519:4TKr1c7p...y7p8
#### sponsor-by-faucet-service - I would like the faucet service sponsor to cover the cost of creating an account (testnet only for now)
-testnet has a faucet (helper service) that can sponsor account creation.
-When adding your own network in the [add-connection](#add-connection---Add-a-network-connection) configurator, you can specify your service in the *faucet_url* field.
-Access keys to the created account can be added in several ways:
+testnet has a faucet (helper service) that can sponsor account creation.
+When adding your own network in the [add-connection](#add-connection---Add-a-network-connection) configurator, you can specify your service in the *faucet_url* field.
+Access keys to the created account can be added in several ways:
- [autogenerate-new-keypair](#autogenerate-new-keypair---Automatically-generate-a-key-pair)
- [use-manually-provided-seed-prase](#use-manually-provided-seed-prase---Use-the-provided-seed-phrase-manually)
- [use-manually-provided-public-key](#use-manually-provided-public-key---Use-the-provided-public-key-manually)
@@ -516,8 +517,8 @@ https://explorer.testnet.near.org/transactions/BStBXVisyR5FUj3ZfCAeQ1ohfwTnx2vTb
#### fund-myself - I would like fund myself to cover the cost of creating an account
-With this command, you can create both a sub account and a "short name" account.
-Access keys to the created account can be added in several ways:
+With this command, you can create both a sub account and a "short name" account.
+Access keys to the created account can be added in several ways:
- [autogenerate-new-keypair](#autogenerate-new-keypair---Automatically-generate-a-key-pair)
- [use-manually-provided-seed-prase](#use-manually-provided-seed-prase---Use-the-provided-seed-phrase-manually)
- [use-manually-provided-public-key](#use-manually-provided-public-key---Use-the-provided-public-key-manually)
@@ -546,7 +547,7 @@ Transaction ID: DRT3EpCK9iT5APyGgfcgSoLPCLCYYKtnrVgDhGLDEZFo
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/DRT3EpCK9iT5APyGgfcgSoLPCLCYYKtnrVgDhGLDEZFo
-The data for the access key is saved in a file /Users/frovolod/.near-credentials/testnet/new.fro_volod.testnet/ed25519_3ngtirechhepHKrzfkdgqqtwqSMtdbSLR6N1c4ivnzu6.json
+The data for the access key is saved in a file /Users/frovolod/.near-credentials/testnet/new.fro_volod.testnet/ed25519_3ngtirechhepHKrzfkdgqqtwqSMtdbSLR6N1c4ivnzu6.json
The data for the access key is saved in a file "/Users/frovolod/.near-credentials/testnet/new.fro_volod.testnet.json"
```
@@ -691,7 +692,7 @@ https://explorer.testnet.near.org/transactions/BKJp3QdaLtnXA8xwfqyk6JfrDsDxbxqAD
##### use-auto-generation - Use auto-generation to create an implicit account
This command automatically generates access keys and saves them to a file named _implicit-account-id_.
-In order to execute this command, in the terminal command line type:
+In order to execute this command, in the terminal command line type:
```txt
near account \
create-account \
@@ -891,7 +892,7 @@ https://explorer.testnet.near.org/transactions/EHvB47npN8Z46qhsrw5XpKmD3n3jDn4MG
#### list-keys - View a list of access keys of an account
-Viewing account access keys is possible at the current time (***now***) and at a certain point in the past by specifying a block (***at-block-height*** or ***at-block-hash***).
+Viewing account access keys is possible at the current time (***now***) and at a certain point in the past by specifying a block (***at-block-height*** or ***at-block-hash***).
Examples of the use of these parameters are discussed in the ([View properties for an account](#view-account-summary---view-properties-for-an-account)).
To view the list of access keys, type the following in the terminal command line:
@@ -1227,7 +1228,7 @@ https://explorer.testnet.near.org/transactions/9q2VbakZbj5ja6GAFXpFnbtbYHijEHyT7
#### view-near-balance - View the balance of Near tokens
-Viewing the account balance is possible at the current time (***now***) and at a certain moment in the past by specifying the block (***at-block-height*** or ***at-block-hash***).
+Viewing the account balance is possible at the current time (***now***) and at a certain moment in the past by specifying the block (***at-block-height*** or ***at-block-hash***).
Examples of the use of these parameters are discussed in the ([View properties for an account](#view-account-summary---view-properties-for-an-account)).
To view the amount in NEAR tokens on the account, type the following in the terminal command line:
@@ -1254,7 +1255,7 @@ fro_volod.testnet account has 169.589001320890476999999994 NEAR available for tr
#### view-ft-balance - View the balance of FT tokens
-Viewing the account balance is possible at the current time (***now***) and at a certain moment in the past by specifying the block (***at-block-height*** or ***at-block-hash***).
+Viewing the account balance is possible at the current time (***now***) and at a certain moment in the past by specifying the block (***at-block-height*** or ***at-block-hash***).
Examples of the use of these parameters are discussed in the ([View properties for an account](#view-account-summary---view-properties-for-an-account)).
To view funds in FT tokens on the account, type the following in the terminal command line:
@@ -1281,7 +1282,7 @@ fro_volod.testnet account has "31942967677775774595" FT tokens (FT-contract: usd
#### view-nft-assets - View the balance of NFT tokens
-Viewing the account balance is possible at the current time (***now***) and at a certain moment in the past by specifying the block (***at-block-height*** or ***at-block-hash***).
+Viewing the account balance is possible at the current time (***now***) and at a certain moment in the past by specifying the block (***at-block-height*** or ***at-block-hash***).
Examples of the use of these parameters are discussed in the ([View properties for an account](#view-account-summary---view-properties-for-an-account)).
To view funds in NFT tokens on the account, type the following in the terminal command line:
@@ -1327,6 +1328,267 @@ fro_volod.testnet account has NFT tokens:
+### staking - Manage staking: view, deposit, and withdraw delegated stake
+
+- [validator-list](#validator-list---View-the-list-of-validators-to-delegate)
+- [delegation](#delegation---Delegation-management)
+
+#### validator-list - View the list of validators to delegate
+
+To view a list of validators, enter at the terminal command line:
+```txt
+near staking \
+ validator-list \
+ network-config mainnet
+```
+
+The result of this command will be as follows:
+
+```txt
++-----+----------------------------------------------+----------+------------+----------------------------------------+
+| # | Validator Id | Fee | Delegators | Stake |
++-----+----------------------------------------------+----------+------------+----------------------------------------+
+| 1 | staked.poolv1.near | 10 % | 3207 | 44135674.18356215181482959363448 NEAR |
+| 2 | figment.poolv1.near | 10 % | 1911 | 43158696.364374348313201031661037 NEAR |
+| 3 | astro-stakers.poolv1.near | 1 % | 11528 | 26760042.204197815051321354819805 NEAR |
+| 4 | bzam6yjpnfnxsdmjf6pw.poolv1.near | 100 % | 772 | 23347900.996610021010359525969384 NEAR |
+| 5 | zavodil.poolv1.near | 1 % | 7116 | 20700903.223980192761611953425855 NEAR |
+| 6 | binancenode1.poolv1.near | 5 % | 1250 | 14209385.916611355199355410152982 NEAR |
+| 7 | staking_yes_protocol1.poolv1.near | 100 % | 65 | 13590245.381034035922399111793022 NEAR |
+| 8 | pinnacle1.poolv1.near | 100 % | 4 | 13509874.537453205747773186007329 NEAR |
+| 9 | priory.poolv1.near | 100 % | 15 | 12727257.514716521676379711750814 NEAR |
+| 10 | stake1.poolv1.near | 3 % | 754 | 12449700.095021989100340879377004 NEAR |
+| 11 | mockingbird.poolv1.near | 100 % | 28 | 11501759.018634341466180769487983 NEAR |
+| 12 | dqw9k3e4422cxt92masmy.poolv1.near | 100 % | 36 | 11122519.385245577197951932017032 NEAR |
+| 13 | flipside.pool.near | 100 % | 9 | 11087540.718366137730589600283212 NEAR |
+| 14 | sweat_validator.poolv1.near | 100 % | 112 | 10900424.272450229667472212076621 NEAR |
+| 15 | epic.poolv1.near | 1 % | 5363 | 10769900.629411406438519703653828 NEAR |
+| 16 | future_is_near.poolv1.near | 9 % | 355 | 10243082.132364573976720438585765 NEAR |
+| 17 | cosmose.poolv1.near | 100 % | 10 | 10064982.806109296980776431396738 NEAR |
+| 18 | aurora.pool.near | 99 % | 3301 | 9298278.181302142009939675438401 NEAR |
+...
+```
+
+
+Demonstration of the command in interactive mode
+
+
+
+
+
+#### delegation - Stake delegation management
+
+- [view-balance](#view-balance---View-the-delegated-stake-balance-for-a-given-account)
+- [deposit-and-stake](#deposit-and-stake---Delegate-NEAR-tokens-to-a-validator's-staking-pool)
+- [stake](#stake---Delegate-a-certain-amount-of-previously-deposited-or-unstaked-NEAR-tokens-to-a-validator's-staking-pool)
+- [stake-all](#stake-all---Delegate-all-previously-deposited-or-unstaked-NEAR-tokens-to-a-validator's-staking-pool)
+- [unstake](#unstake---Unstake-a-certain-amount-of-delegated-NEAR-tokens-from-a-avalidator's-staking-pool)
+- [unstake-all](#unstake-all---Unstake-all-delegated-NEAR-tokens-from-a-avalidator's-staking-pool)
+- [withdraw](#withdraw---Withdraw-a-certain-amount-of-unstaked-NEAR-tokens-from-a-avalidator's-staking-pool)
+- [withdraw-all](#withdraw-all---Withdraw-all-unstaked-NEAR-tokens-from-a-avalidator's-staking-pool)
+
+##### view-balance - View the delegated stake balance for a given account
+
+To view the delegated stake account balance on a validator staking pool, enter at the terminal command line:
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ view-balance aurora.pool.f863973.m0 \
+ network-config testnet \
+ now
+```
+
+The result of this command will be as follows:
+
+```txt
+Delegated stake balance with validator by :
+ Staked balance: 38.021465232511349340052266 NEAR
+ Unstaked balance: 0.000000000000000000000001 NEAR
+ Total balance: 38.021465232511349340052267 NEAR
+```
+
+
+Demonstration of the command in interactive mode
+
+
+
+
+
+##### deposit-and-stake - Delegate NEAR tokens to a validator's staking pool
+
+To delegate your NEAR tokens to a staking pool to support a validator and gain staking rewards, deposit NEAR tokens and stake with a selected staking pool, you may use the following command (note that you need to use your own account id, adjust the amount of NEAR tokens to deposit and stake, and choose the staking pool account id):
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ deposit-and-stake '15 NEAR' aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+The result of this command will be as follows:
+
+```txt
+ has successfully delegated 15 NEAR to stake with .
+```
+
+
+Demonstration of the command in interactive mode
+
+
+
+
+
+##### stake - Delegate a certain amount of previously deposited or unstaked NEAR tokens to a validator's staking pool
+
+To delegate your NEAR tokens to a staking pool to support a validator and gain staking rewards, stake deposited NEAR tokens with a selected staking pool. You may use the following command (note that you need to use your own account id, adjust the amount of NEAR tokens to stake, choose the staking pool account id, and use the appropriate network):
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ stake '5 NEAR' aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+The result of this command will be as follows:
+
+```txt
+ has successfully delegated 5 NEAR to stake with .
+```
+
+
+Demonstration of the command in interactive mode
+
+
+
+
+
+##### stake-all - Delegate all previously deposited or unstaked NEAR tokens to a validator's staking pool
+
+To delegate your NEAR tokens to a staking pool to support a validator and gain staking rewards, stake all previosly deposited or unstaked NEAR tokens with a selected staking pool. You may use the following command (note that you need to use your own account id, and choose the staking pool account id):
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ stake-all aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+The result of this command will be as follows:
+
+```txt
+ has successfully delegated all previously unstaked NEAR tokens to stake with .
+```
+
+
+Demonstration of the command in interactive mode
+
+
+
+
+
+##### unstake - Unstake a certain amount of delegated NEAR tokens from a avalidator's staking pool
+
+To unstake your delegated NEAR tokens from a staking pool, you can use the following command (note that you need to use your own account id, adjust the amount of NEAR tokens to unstake, and choose the staking pool account id):
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ unstake '7 NEAR' aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+The result of this command will be as follows:
+
+```txt
+ has successfully unstaked 7 NEAR from .
+```
+
+
+Demonstration of the command in interactive mode
+
+
+
+
+
+##### unstake-all - Unstake all delegated NEAR tokens from a avalidator's staking pool
+
+To unstake your delegated NEAR tokens from a staking pool, you can use the following command (note that you need to use your own account id, and choose the staking pool account id):
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ unstake-all aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+The result of this command will be as follows:
+
+```txt
+ has successfully unstaked the entire amount from .
+```
+
+
+Demonstration of the command in interactive mode
+
+
+
+
+
+##### withdraw - Withdraw a certain amount of unstaked NEAR tokens from a avalidator's staking pool
+
+To withdraw your delegated NEAR tokens from a staking pool after you unstaked and waited for 4 epochs, you can use the following command (note that you need to use your own account id, adjust the amount of NEAR tokens to withdraw, and choose the staking pool account id):
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ withdraw '3 NEAR' aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+The result of this command will be as follows:
+
+```txt
+ has successfully withdrawn 3 NEAR from .
+```
+
+
+Demonstration of the command in interactive mode
+
+
+
+
+
+##### withdraw-all - Withdraw all unstaked NEAR tokens from a avalidator's staking pool
+
+To withdraw all your delegated NEAR tokens from a staking pool after you unstaked them and waited for 4 epochs, you can use the following command (note that you need to use your own account id, and choose the staking pool account id):
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ withdraw-all aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+The result of this command will be as follows:
+
+```txt
+ has successfully withdrawn the entire amount from .
+```
+
+
+Demonstration of the command in interactive mode
+
+
+
+
+
### contract - Manage smart-contracts: deploy code, call functions
- [call-function](#call-function---Execute-function-contract-method)
@@ -1341,7 +1603,7 @@ fro_volod.testnet account has NFT tokens:
##### as-read-only - Calling a view method
-Viewing data is possible at the current time (***now***) and at a certain point in the past by specifying a block (***at-block-height*** or ***at-block-hash***).
+Viewing data is possible at the current time (***now***) and at a certain point in the past by specifying a block (***at-block-height*** or ***at-block-hash***).
Examples of the use of these parameters are discussed in the ([View properties for an account](#view-account-summary---view-properties-for-an-account)).
To run this command, type the following in the terminal command line:
@@ -1458,7 +1720,7 @@ https://explorer.testnet.near.org/transactions/4YGGhF88aevNGpF5uaXNGHfQprHRqkia7
#### download-wasm - Download wasm
-You can download the contract file for the current moment (***now***) and for a certain moment in the past by specifying the block (***at-block-height*** or ***at-block-hash***).
+You can download the contract file for the current moment (***now***) and for a certain moment in the past by specifying the block (***at-block-height*** or ***at-block-hash***).
Examples of the use of these parameters are discussed in the ([View properties for an account](#view-account-summary---view-properties-for-an-account)).
In order to get the contract file, type the following in the terminal command line:
@@ -1485,8 +1747,8 @@ The file "/Users/frovolod/Downloads/contract_262_volodymyr_testnet.wasm" was dow
#### view-storage - View contract storage state
-You can view the contract key values at the current moment in time (***now***) and at a certain point in the past by specifying a block (***at-block-height*** or ***at-block-hash***).
-Examples of the use of these parameters are discussed in the ([View properties for an account](#view-account-summary---view-properties-for-an-account)).
+You can view the contract key values at the current moment in time (***now***) and at a certain point in the past by specifying a block (***at-block-height*** or ***at-block-hash***).
+Examples of the use of these parameters are discussed in the ([View properties for an account](#view-account-summary---view-properties-for-an-account)).
The keys themselves can be viewed all (***all***) or filtered using ***keys-start-with-string*** or ***keys-start-with-bytes-as-base64***.
To view contract keys, enter at the terminal command line:
@@ -1712,7 +1974,7 @@ Transaction status: FinalExecutionOutcomeWithReceiptView {
#### construct-transaction - Construct a new transaction
-
+
Let's consider an example when it is necessary to perform several actions within one transaction:
1. Create an account
2. Add access keys to the created account
@@ -1727,7 +1989,7 @@ To do this, we will use the transaction constructor:
#### sign-transaction - Sign previously prepared unsigned transaction
-
+
Consider an example of using the ability to create a transaction in _offline_:
1. Create a transaction.
2. When choosing how to sign a transaction, select the _sign later_ option and follow the instructions.
@@ -1740,7 +2002,7 @@ Consider an example of using the ability to create a transaction in _offline_:
#### send-signed-transaction - Send a signed transaction
-
+
Let's look at the previous example, using the capabilities of sending a signed transaction:
1. Create a transaction.
2. Sign the transaction with your access keys.
@@ -1754,7 +2016,7 @@ Let's look at the previous example, using the capabilities of sending a signed t
#### send-meta-transaction - Act as a relayer to send a signed delegate action (meta-transaction)
-
+
Consider an example of using metatransaction functions:
1. Create a transaction.
2. Specify a _network_ that supports meta-transactions.
diff --git a/docs/GUIDE.ru.md b/docs/GUIDE.ru.md
index 0016cc0a1..1e19506ea 100644
--- a/docs/GUIDE.ru.md
+++ b/docs/GUIDE.ru.md
@@ -3,10 +3,10 @@
Это руководство предназначено для того, чтобы дать подробное описание утилиты _near CLI_ и
обзор её возможностей. Предполагается, что утилита _near CLI_
[установлена](README.ru.md#installation)
-и пользователи знакомы с использованием инструментов командной строки. Также предполагается Unix-подобная система, хотя большинство команд, вероятно, легко переводимы в любую среду оболочки командной строки.
+и пользователи знакомы с использованием инструментов командной строки. Также предполагается Unix-подобная система, хотя большинство команд, вероятно, легко переводимы в любую среду оболочки командной строки.
Спомощью _near CLI_ можно создать, подписать и отправить транзакцию в режиме _online_, который включен по умолчанию.
-В режиме _offline_ можно создать и подписать транзакцию. Транзакция, кодированная в base64 может быть [подписана](#sign-transaction---sign-previously-prepared-unsigned-transaction) или [отправлена](#send-signed-transaction---send-a-signed-transaction) позже (даже с другого компьютера). Для входа в режим _offline_ необходимо в команде установить флаг ```--offline```:
+В режиме _offline_ можно создать и подписать транзакцию. Транзакция, кодированная в base64 может быть [подписана](#sign-transaction---sign-previously-prepared-unsigned-transaction) или [отправлена](#send-signed-transaction---send-a-signed-transaction) позже (даже с другого компьютера). Для входа в режим _offline_ необходимо в команде установить флаг ```--offline```:
```txt
near --offline tokens \
fro_volod.testnet \
@@ -28,8 +28,8 @@ near --offline tokens \
- _sign-with-keychain - Sign the transaction with a key saved in legacy keychain (compatible with the old near CLI)_
_near CLI_ самостоятельно найдет ключи доступа и подпишет созданную транзакцию.
- Каталог с ключами доступа определен в [конфигурационном файле](#config---manage-connections-in-a-configuration-file).
- Ключи доступа должны находиться в файле _публичный-ключ.json_, расположенном в _/Users/user/.near-credentials/имя-сети/имя-пользователя/_.
+ Каталог с ключами доступа определен в [конфигурационном файле](#config---manage-connections-in-a-configuration-file).
+ Ключи доступа должны находиться в файле _публичный-ключ.json_, расположенном в _/Users/user/.near-credentials/имя-сети/имя-пользователя/_.
Например, _/Users/frovolod/.near-credentials/testnet/volodymyr.testnet/ed25519_8h7kFK4quSUJRkUwo3LLiK83sraEm2jnQTECuZhWu8HC.json_
Демонстрация работы команды в интерактивном режиме
@@ -63,7 +63,7 @@ near --offline tokens \
2. Действия с подписанной транзакцией
- _near CLI_ поддерживает мета-транзакции, описанные в спецификации [NEP-366](https://near.github.io/nearcore/architecture/how/meta-tx.html#meta-transactions). Для её создания достаточно указать _network_, поддерживающую мета-транзакции. Узнать о такой поддержке можно в [конфигурационном файле](#show-connections---Show-a-list-of-network-connections). За возможность поддержки мета-транзакции отвечает поле *meta_transaction_relayer_url*. Например:
+ _near CLI_ поддерживает мета-транзакции, описанные в спецификации [NEP-366](https://near.github.io/nearcore/architecture/how/meta-tx.html#meta-transactions). Для её создания достаточно указать _network_, поддерживающую мета-транзакции. Узнать о такой поддержке можно в [конфигурационном файле](#show-connections---Show-a-list-of-network-connections). За возможность поддержки мета-транзакции отвечает поле *meta_transaction_relayer_url*. Например:
```txt
meta_transaction_relayer_url = "https://near-testnet.api.pagoda.co/relay"
```
@@ -80,6 +80,7 @@ near --offline tokens \
- [account - Manage accounts](#account---Manage-accounts)
- [tokens - Manage token assets such as NEAR, FT, NFT](#tokens---Manage-token-assets-such-as-NEAR-FT-NFT)
+- [staking - Manage staking: view, add and withdraw stake](#staking---Manage-staking-view-add-and-withdraw-stake)
- [contract - Manage smart-contracts: deploy code, call functions](#contract---Manage-smart-contracts-deploy-code-call-functions)
- [transaction - Operate transactions](#transaction---Operate-transactions)
- [config - Manage connections in a configuration file](#config---Manage-connections-in-a-configuration-file)
@@ -245,7 +246,7 @@ near account \
network-config testnet
```
-Вы будете перенаправлены браузер для авторизации.
+Вы будете перенаправлены браузер для авторизации.
По умолчанию - это https://app.mynearwallet.com/ (для testnet - https://testnet.mynearwallet.com/). Но вы можете изменить адрес для авторизации с помощью флага `--wallet-url`:
```txt
near account \
@@ -333,7 +334,7 @@ near account \
network-config testnet
```
-Вы будете перенаправлены браузер.
+Вы будете перенаправлены браузер.
По умолчанию - это https://app.mynearwallet.com/ (для testnet - https://testnet.mynearwallet.com/). Но вы можете изменить адрес для авторизации с помощью флага `--wallet-url`:
```txt
near account \
@@ -391,9 +392,9 @@ Here is the private key for account : ed25519:4TKr1c7p...y7p8
#### sponsor-by-faucet-service - I would like the faucet service sponsor to cover the cost of creating an account (testnet only for now)
-С помощью этой команды можно создать аккаунт при помощи вспомогательного сервиса, который может спонсировать создание учетной записи (пока только testnet).
-При добавлении собственной сети в конфигураторе [add-connection](#add-connection---Add-a-network-connection) можете указать свой сервис в поле *faucet_url*.
-Ключи доступа к создаваемому аккаунту можно добавить несколькими способами:
+С помощью этой команды можно создать аккаунт при помощи вспомогательного сервиса, который может спонсировать создание учетной записи (пока только testnet).
+При добавлении собственной сети в конфигураторе [add-connection](#add-connection---Add-a-network-connection) можете указать свой сервис в поле *faucet_url*.
+Ключи доступа к создаваемому аккаунту можно добавить несколькими способами:
- [autogenerate-new-keypair](#autogenerate-new-keypair---Automatically-generate-a-key-pair)
- [use-manually-provided-seed-prase](#use-manually-provided-seed-prase---Use-the-provided-seed-phrase-manually)
- [use-manually-provided-public-key](#use-manually-provided-public-key---Use-the-provided-public-key-manually)
@@ -516,8 +517,8 @@ https://explorer.testnet.near.org/transactions/BStBXVisyR5FUj3ZfCAeQ1ohfwTnx2vTb
#### fund-myself - I would like fund myself to cover the cost of creating an account
-С помощью этой команды можно создать как суб-аккаунт, так и аккаунт с коротким именем, например, alice.near или alice.testnet (в сети testnet).
-Ключи доступа к создаваемому аккаунту можно добавить несколькими способами:
+С помощью этой команды можно создать как суб-аккаунт, так и аккаунт с коротким именем, например, alice.near или alice.testnet (в сети testnet).
+Ключи доступа к создаваемому аккаунту можно добавить несколькими способами:
- [autogenerate-new-keypair](#autogenerate-new-keypair---Automatically-generate-a-key-pair)
- [use-manually-provided-seed-prase](#use-manually-provided-seed-prase---Use-the-provided-seed-phrase-manually)
- [use-manually-provided-public-key](#use-manually-provided-public-key---Use-the-provided-public-key-manually)
@@ -546,7 +547,7 @@ Transaction ID: DRT3EpCK9iT5APyGgfcgSoLPCLCYYKtnrVgDhGLDEZFo
To see the transaction in the transaction explorer, please open this url in your browser:
https://explorer.testnet.near.org/transactions/DRT3EpCK9iT5APyGgfcgSoLPCLCYYKtnrVgDhGLDEZFo
-The data for the access key is saved in a file /Users/frovolod/.near-credentials/testnet/new.fro_volod.testnet/ed25519_3ngtirechhepHKrzfkdgqqtwqSMtdbSLR6N1c4ivnzu6.json
+The data for the access key is saved in a file /Users/frovolod/.near-credentials/testnet/new.fro_volod.testnet/ed25519_3ngtirechhepHKrzfkdgqqtwqSMtdbSLR6N1c4ivnzu6.json
The data for the access key is saved in a file "/Users/frovolod/.near-credentials/testnet/new.fro_volod.testnet.json"
```
@@ -891,7 +892,7 @@ https://explorer.testnet.near.org/transactions/EHvB47npN8Z46qhsrw5XpKmD3n3jDn4MG
#### list-keys - View a list of access keys of an account
-Просмотр ключей доступа аккаунта возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
+Просмотр ключей доступа аккаунта возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
Примеры использования этих параметров рассмотрены в разделе [View properties for an account](#view-account-summary---view-properties-for-an-account).
Для просмотра списка ключей доступа необходимо ввести в командной строке терминала:
@@ -1229,7 +1230,7 @@ https://explorer.testnet.near.org/transactions/9q2VbakZbj5ja6GAFXpFnbtbYHijEHyT7
#### view-near-balance - View the balance of Near tokens
-Просмотр баланса аккаунта возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
+Просмотр баланса аккаунта возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
Примеры использования этих параметров рассмотрены в разделе [View properties for an account](#view-account-summary---view-properties-for-an-account).
Для просмотра средств в NEAR токенах на счету аккаунта необходимо ввести в командной строке терминала:
@@ -1256,7 +1257,7 @@ fro_volod.testnet account has 169.589001320890476999999994 NEAR available for tr
#### view-ft-balance - View the balance of FT tokens
-Просмотр баланса аккаунта возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
+Просмотр баланса аккаунта возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
Примеры использования этих параметров рассмотрены в разделе [View properties for an account](#view-account-summary---view-properties-for-an-account).
Для просмотра средств в FT токенах на счету аккаунта необходимо ввести в командной строке терминала:
@@ -1283,7 +1284,7 @@ fro_volod.testnet account has "31942967677775774595" FT tokens (FT-contract: usd
#### view-nft-assets - View the balance of NFT tokens
-Просмотр баланса аккаунта возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
+Просмотр баланса аккаунта возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
Примеры использования этих параметров рассмотрены в разделе [View properties for an account](#view-account-summary---view-properties-for-an-account).
Для просмотра средств в NFT токенах на счету аккаунта необходимо ввести в командной строке терминала:
@@ -1329,6 +1330,276 @@ fro_volod.testnet account has NFT tokens:
+### staking - Manage staking: view, add and withdraw stake
+
+- [validator-list](#validator-list---View-the-list-of-validators-to-delegate)
+- [delegation](#delegation---Delegation-management)
+
+#### validator-list - View the list of validators to delegate
+
+Для просмотра списка валидаторов необходимо ввести в командной строке терминала:
+```txt
+near staking \
+ validator-list \
+ network-config mainnet
+```
+
+Результат выполнения команды
+
+```txt
++-----+----------------------------------------------+----------+------------+----------------------------------------+
+| # | Validator Id | Fee | Delegators | Stake |
++-----+----------------------------------------------+----------+------------+----------------------------------------+
+| 1 | staked.poolv1.near | 10 % | 3207 | 44135674.18356215181482959363448 NEAR |
+| 2 | figment.poolv1.near | 10 % | 1911 | 43158696.364374348313201031661037 NEAR |
+| 3 | astro-stakers.poolv1.near | 1 % | 11528 | 26760042.204197815051321354819805 NEAR |
+| 4 | bzam6yjpnfnxsdmjf6pw.poolv1.near | 100 % | 772 | 23347900.996610021010359525969384 NEAR |
+| 5 | zavodil.poolv1.near | 1 % | 7116 | 20700903.223980192761611953425855 NEAR |
+| 6 | binancenode1.poolv1.near | 5 % | 1250 | 14209385.916611355199355410152982 NEAR |
+| 7 | staking_yes_protocol1.poolv1.near | 100 % | 65 | 13590245.381034035922399111793022 NEAR |
+| 8 | pinnacle1.poolv1.near | 100 % | 4 | 13509874.537453205747773186007329 NEAR |
+| 9 | priory.poolv1.near | 100 % | 15 | 12727257.514716521676379711750814 NEAR |
+| 10 | stake1.poolv1.near | 3 % | 754 | 12449700.095021989100340879377004 NEAR |
+| 11 | mockingbird.poolv1.near | 100 % | 28 | 11501759.018634341466180769487983 NEAR |
+| 12 | dqw9k3e4422cxt92masmy.poolv1.near | 100 % | 36 | 11122519.385245577197951932017032 NEAR |
+| 13 | flipside.pool.near | 100 % | 9 | 11087540.718366137730589600283212 NEAR |
+| 14 | sweat_validator.poolv1.near | 100 % | 112 | 10900424.272450229667472212076621 NEAR |
+| 15 | epic.poolv1.near | 1 % | 5363 | 10769900.629411406438519703653828 NEAR |
+| 16 | future_is_near.poolv1.near | 9 % | 355 | 10243082.132364573976720438585765 NEAR |
+| 17 | cosmose.poolv1.near | 100 % | 10 | 10064982.806109296980776431396738 NEAR |
+| 18 | aurora.pool.near | 99 % | 3301 | 9298278.181302142009939675438401 NEAR |
+...
+```
+
+
+Демонстрация работы команды в интерактивном режиме
+
+
+
+
+
+#### delegation - Delegation management
+
+- [view-balance](#View-the-total-balance-for-a-given-account)
+- [deposit-and-stake](#deposit-and-stake---Deposits-the-attached-amount-into-the-inner-account-of-the-predecessor-and-stakes-it)
+- [stake](#stake---Staking-the-given-amount-from-the-inner-account-of-the-predecessor)
+- [stake-all](#stake-all---Staking-all-available-unstaked-balance-from-the-inner-account-of-the-predecessor)
+- [unstake](#unstake---Unstaking-the-given-amount-from-the-inner-account-of-the-predecessor)
+- [unstake-all](#unstake-all---Unstaking-all-staked-balance-from-the-inner-account-of-the-predecessor)
+- [withdraw](#withdraw---Withdrawing-the-non-staked-balance-for-given-account)
+- [withdraw-all](#withdraw-all---Withdrawing-the-entire-unstaked-balance-from-the-predecessor-account)
+
+##### view-balance - View the delegated stake balance for a given account
+
+Для просмотра порученного баланса аккаунта в общий фонд валидатора необходимо ввести в командной строке терминала:
+
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ view-balance aurora.pool.f863973.m0 \
+ network-config testnet \
+ now
+```
+
+Результат выполнения команды
+
+```txt
+Delegated stake balance with validator by :
+ Staked balance: 38.021465232511349340052266 NEAR
+ Unstaked balance: 0.000000000000000000000001 NEAR
+ Total balance: 38.021465232511349340052267 NEAR
+```
+
+
+Демонстрация работы команды в интерактивном режиме
+
+
+
+
+
+##### deposit-and-stake - Delegate NEAR tokens to a validator's staking pool
+
+Чтобы поручить ваши NEAR токены в общий фонд одного из валидаторов и получения наград, передайте ваши NEAR токены и переведите их в ставку валидатора, используя следующую командну в терминале (обратите внимание, что вам необходимо использовать свой собственный идентификатор аккаунта, указать желаемое количество NEAR токенов, а также выбрать идентификатор аккаунта валидатора):
+
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ deposit-and-stake '15 NEAR' aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+Результат выполнения команды
+
+```txt
+ has successfully deposited and staked 15 NEAR on .
+```
+
+
+Демонстрация работы команды в интерактивном режиме
+
+
+
+
+
+##### stake - Delegate a certain amount of previously deposited or unstaked NEAR tokens to a validator's staking pool
+
+Чтобы поручить ваши NEAR токены в общий фонд одного из валидаторов и получения наград, переведите раннее переданные NEAR токены в ставку валидатора, используя следующую командну в терминале (обратите внимание, что вам необходимо использовать свой собственный идентификатор аккаунта, указать желаемое количество NEAR токенов, а также выбрать идентификатор аккаунта валидатора):
+
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ stake '5 NEAR' aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+Результат выполнения команды
+
+```txt
+ has successfully stake 5 NEAR on .
+```
+
+
+Демонстрация работы команды в интерактивном режиме
+
+
+
+
+
+##### stake-all - Delegate all previously deposited or unstaked NEAR tokens to a validator's staking pool
+
+Чтобы поручить ваши NEAR токены в общий фонд одного из валидаторов и получения наград, переведите все раннее переданные NEAR токены в ставку валидатора, используя следующую командну в терминале (обратите внимание, что вам необходимо использовать свой собственный идентификатор аккаунта, а также выбрать идентификатор аккаунта валидатора):
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ stake-all aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+Результат выполнения команды
+
+```txt
+ has successfully stake the entire amount on .
+```
+
+
+Демонстрация работы команды в интерактивном режиме
+
+
+
+
+
+##### unstake - Unstake a certain amount of delegated NEAR tokens from a avalidator's staking pool
+
+Чтобы отменить определённую часть ставки, совершённую через общий фонд валидатора, используйте следующую командну в терминале (обратите внимание, что вам необходимо использовать свой собственный идентификатор аккаунта, указать желаемое количество NEAR токенов, а также выбрать идентификатор аккаунта валидатора):
+
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ unstake '7 NEAR' aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+Результат выполнения команды
+
+```txt
+ has successfully unstake 7 NEAR from .
+```
+
+
+Демонстрация работы команды в интерактивном режиме
+
+
+
+
+
+##### unstake-all - Unstake all delegated NEAR tokens from a avalidator's staking pool
+
+Чтобы отменить всю ставку, совершённую через общий фонд валидатора, используйте следующую командну в терминале (обратите внимание, что вам необходимо использовать свой собственный идентификатор аккаунта, а также выбрать идентификатор аккаунта валидатора):
+
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ unstake-all aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+Результат выполнения команды
+
+```txt
+ has successfully unstake the entire amount from .
+```
+
+
+Демонстрация работы команды в интерактивном режиме
+
+
+
+
+
+##### withdraw - Withdraw a certain amount of unstaked NEAR tokens from a avalidator's staking pool
+
+Чтобы получить ваши раннее порученные NEAR токены и награды из общего фонда валидатора после того как ставка была снята и прошло 4 эпохи, используйте следующую командну в терминале (обратите внимание, что вам необходимо использовать свой собственный идентификатор аккаунта, указать желаемое количество NEAR токенов, а также выбрать идентификатор аккаунта валидатора):
+
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ withdraw '3 NEAR' aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+Результат выполнения команды
+
+```txt
+Error:
+ 0: can't withdraw tokens in the current epoch.
+```
+
+
+Демонстрация работы команды в интерактивном режиме
+
+
+
+
+
+##### withdraw-all - Withdraw all unstaked NEAR tokens from a avalidator's staking pool
+
+Чтобы получить все ваши раннее порученные NEAR токены и награды из общего фонда валидатора после того как ставка была снята и прошло 4 эпохи, используйте следующую командну в терминале (обратите внимание, что вам необходимо использовать свой собственный идентификатор аккаунта, а также выбрать идентификатор аккаунта валидатора):
+
+```txt
+near staking \
+ delegation volodymyr.testnet \
+ withdraw-all aurora.pool.f863973.m0 \
+ network-config testnet \
+ sign-with-legacy-keychain \
+ send
+```
+
+Результат выполнения команды
+
+```txt
+Error:
+ 0: can't withdraw tokens in the current epoch.
+```
+
+
+Демонстрация работы команды в интерактивном режиме
+
+
+
+
+
### contract - Manage smart-contracts: deploy code, call functions
- [call-function](#call-function---Execute-function-contract-method)
@@ -1343,7 +1614,7 @@ fro_volod.testnet account has NFT tokens:
##### as-read-only - Calling a view method
-Просмотр данных возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
+Просмотр данных возможен на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
Примеры использования этих параметров рассмотрены в разделе [View properties for an account](#view-account-summary---view-properties-for-an-account).
Для выполнения этой команды необходимо ввести в командной строке терминала:
@@ -1460,7 +1731,7 @@ https://explorer.testnet.near.org/transactions/4YGGhF88aevNGpF5uaXNGHfQprHRqkia7
#### download-wasm - Download wasm
-Скачать файл контракта возможно на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
+Скачать файл контракта возможно на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
Примеры использования этих параметров рассмотрены в разделе [View properties for an account](#view-account-summary---view-properties-for-an-account).
Для получения файла контракта необходимо ввести в командной строке терминала:
@@ -1487,8 +1758,8 @@ The file "/Users/frovolod/Downloads/contract_262_volodymyr_testnet.wasm" was dow
#### view-storage - View contract storage state
-Просмотреть значения ключей контракта возможно на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
-Примеры использования этих параметров рассмотрены в разделе [View properties for an account](#view-account-summary---view-properties-for-an-account).
+Просмотреть значения ключей контракта возможно на текущий момент времени (***now***) и на определеный момент в прошлом, указав блок (***at-block-height*** или ***at-block-hash***).
+Примеры использования этих параметров рассмотрены в разделе [View properties for an account](#view-account-summary---view-properties-for-an-account).
Сами же ключи можно просмотреть все (***all***) или отфильтрованные с помощью ***keys-start-with-string*** или ***keys-start-with-bytes-as-base64***.
Для просмотра ключей контракта необходимо ввести в командной строке терминала:
@@ -1714,7 +1985,7 @@ Transaction status: FinalExecutionOutcomeWithReceiptView {
#### construct-transaction - Construct a new transaction
-
+
Рассмотрим пример, когда необходимо выполнить несколько действий в рамках одной транзакции:
1. Создать аккаунт
2. Добавить созданному аккаунту ключи доступа
@@ -1729,7 +2000,7 @@ Transaction status: FinalExecutionOutcomeWithReceiptView {
#### sign-transaction - Sign previously prepared unsigned transaction
-
+
Рассмотрим пример, применив возможность создания транзакции в режиме _offline_:
1. Создать транзакцию.
2. При выборе средств подписи транзакции указать пункт _sign-later_ и следовать дальнейшим инструкциям.
@@ -1742,7 +2013,7 @@ Transaction status: FinalExecutionOutcomeWithReceiptView {
#### send-signed-transaction - Send a signed transaction
-
+
Рассмотрим предыдущий пример, применив возможности отправки подписанной транзакции транзакции:
1. Создать транзакцию.
2. Подписать транзакцию своими ключами доступа.
@@ -1756,7 +2027,7 @@ Transaction status: FinalExecutionOutcomeWithReceiptView {
#### send-meta-transaction - Act as a relayer to send a signed delegate action (meta-transaction)
-
+
Рассмотрим пример, применив возможности мета-транзакции:
1. Создать транзакцию.
2. Указать _network_ с поддержкой мета-транзакции.
diff --git a/src/commands/account/create_account/fund_myself_create_account/sign_as/mod.rs b/src/commands/account/create_account/fund_myself_create_account/sign_as/mod.rs
index 64442d9d3..0490854c1 100644
--- a/src/commands/account/create_account/fund_myself_create_account/sign_as/mod.rs
+++ b/src/commands/account/create_account/fund_myself_create_account/sign_as/mod.rs
@@ -81,12 +81,10 @@ impl From for crate::commands::ActionContext {
],
new_account_id.clone())
} else {
- let args = json!({
+ let args = serde_json::to_vec(&json!({
"new_account_id": new_account_id.clone().to_string(),
"new_public_key": item.account_properties.public_key.to_string()
- })
- .to_string()
- .into_bytes();
+ }))?;
if let Some(linkdrop_account_id) = &network_config.linkdrop_account_id {
if new_account_id.is_sub_account_of(linkdrop_account_id)
diff --git a/src/commands/account/storage_management/storage_deposit.rs b/src/commands/account/storage_management/storage_deposit.rs
index e2cb82dbf..afc0fd97e 100644
--- a/src/commands/account/storage_management/storage_deposit.rs
+++ b/src/commands/account/storage_management/storage_deposit.rs
@@ -117,9 +117,9 @@ impl SignerAccountIdContext {
actions: vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
method_name: "storage_deposit".to_string(),
- args: serde_json::json!({ "account_id": &receiver_account_id })
- .to_string()
- .into_bytes(),
+ args: serde_json::to_vec(&serde_json::json!({
+ "account_id": &receiver_account_id
+ }))?,
gas: crate::common::NearGas::from_tgas(50).as_gas(),
deposit: deposit.as_yoctonear(),
},
diff --git a/src/commands/account/storage_management/storage_withdraw.rs b/src/commands/account/storage_management/storage_withdraw.rs
index ae666e2b0..e9306b349 100644
--- a/src/commands/account/storage_management/storage_withdraw.rs
+++ b/src/commands/account/storage_management/storage_withdraw.rs
@@ -63,11 +63,9 @@ impl SignerAccountIdContext {
actions: vec![near_primitives::transaction::Action::FunctionCall(
near_primitives::transaction::FunctionCallAction {
method_name: "storage_withdraw".to_string(),
- args: serde_json::json!({
+ args: serde_json::to_vec(&serde_json::json!({
"amount": amount.clone().as_yoctonear().to_string()
- })
- .to_string()
- .into_bytes(),
+ }))?,
gas: crate::common::NearGas::from_tgas(50).as_gas(),
deposit: near_token::NearToken::from_yoctonear(1).as_yoctonear(),
},
diff --git a/src/commands/account/storage_management/view_storage_balance.rs b/src/commands/account/storage_management/view_storage_balance.rs
index f6d75627d..5d11fc692 100644
--- a/src/commands/account/storage_management/view_storage_balance.rs
+++ b/src/commands/account/storage_management/view_storage_balance.rs
@@ -35,11 +35,9 @@ impl AccountContext {
.blocking_call_view_function(
&contract_account_id,
"storage_balance_of",
- serde_json::json!({
+ serde_json::to_vec(&serde_json::json!({
"account_id": account_id.to_string(),
- })
- .to_string()
- .into_bytes(),
+ }))?,
block_reference.clone(),
)
.wrap_err_with(|| {
diff --git a/src/commands/account/update_social_profile/sign_as.rs b/src/commands/account/update_social_profile/sign_as.rs
index 1629d4711..75ebb9490 100644
--- a/src/commands/account/update_social_profile/sign_as.rs
+++ b/src/commands/account/update_social_profile/sign_as.rs
@@ -64,11 +64,9 @@ impl From for crate::commands::ActionContext {
.blocking_call_view_function(
&contract_account_id,
"get",
- serde_json::json!({
+ serde_json::to_vec(&serde_json::json!({
"keys": vec![format!("{account_id}/profile/**")],
- })
- .to_string()
- .into_bytes(),
+ }))?,
near_primitives::types::Finality::Final.into(),
)
.wrap_err_with(|| {format!("Failed to fetch query for view method: 'get {account_id}/profile/**'")})?
diff --git a/src/commands/account/view_account_summary/mod.rs b/src/commands/account/view_account_summary/mod.rs
index 5a97715f8..9654663f0 100644
--- a/src/commands/account/view_account_summary/mod.rs
+++ b/src/commands/account/view_account_summary/mod.rs
@@ -1,4 +1,5 @@
use color_eyre::eyre::Context;
+use futures::{StreamExt, TryStreamExt};
use crate::common::{CallResultExt, JsonRpcClientExt, RpcQueryResponseExt};
@@ -26,9 +27,10 @@ impl ViewAccountSummaryContext {
let account_id: near_primitives::types::AccountId = scope.account_id.clone().into();
move |network_config, block_reference| {
- let rpc_query_response = network_config
- .json_rpc_client()
- .blocking_call_view_account(&account_id, block_reference.clone())
+ let json_rpc_client = network_config.json_rpc_client();
+
+ let rpc_query_response = json_rpc_client
+ .blocking_call_view_account(&account_id.clone(), block_reference.clone())
.wrap_err_with(|| {
format!(
"Failed to fetch query ViewAccount for <{}>",
@@ -51,6 +53,33 @@ impl ViewAccountSummaryContext {
})?
.access_key_list_view()?;
+ let validators_stake = crate::common::get_validators_stake(&json_rpc_client)?;
+
+ let runtime = tokio::runtime::Builder::new_multi_thread()
+ .enable_all()
+ .build()?;
+ let concurrency = 10;
+ let delegated_stake: std::collections::BTreeMap = runtime
+ .block_on(
+ futures::stream::iter(validators_stake.into_keys())
+ .map(|validator_account_id| async {
+ let balance = get_delegated_staked_balance(&json_rpc_client, block_reference, &validator_account_id, &account_id).await?;
+ Ok::<_, color_eyre::eyre::Report>((
+ validator_account_id,
+ balance,
+ ))
+ })
+ .buffer_unordered(concurrency)
+ .filter(|balance_result| futures::future::ready(
+ if let Ok((_, balance)) = balance_result {
+ !balance.is_zero()
+ } else {
+ true
+ }
+ ))
+ .try_collect(),
+ )?;
+
let contract_account_id = network_config.get_near_social_account_id_from_network()?;
let social_db = network_config
@@ -58,11 +87,9 @@ impl ViewAccountSummaryContext {
.blocking_call_view_function(
&contract_account_id,
"get",
- serde_json::json!({
+ serde_json::to_vec(&serde_json::json!({
"keys": vec![format!("{account_id}/profile/**")],
- })
- .to_string()
- .into_bytes(),
+ }))?,
block_reference.clone(),
)
.wrap_err_with(|| {format!("Failed to fetch query for view method: 'get {account_id}/profile/**'")})?
@@ -75,6 +102,7 @@ impl ViewAccountSummaryContext {
&rpc_query_response.block_hash,
&rpc_query_response.block_height,
&account_id,
+ &delegated_stake,
&account_view,
&access_key_list.keys,
social_db.accounts.get(&account_id)
@@ -107,3 +135,43 @@ impl ViewAccountSummary {
)
}
}
+
+async fn get_delegated_staked_balance(
+ json_rpc_client: &near_jsonrpc_client::JsonRpcClient,
+ block_reference: &near_primitives::types::BlockReference,
+ staking_pool_account_id: &near_primitives::types::AccountId,
+ account_id: &near_primitives::types::AccountId,
+) -> color_eyre::eyre::Result {
+ let account_staked_balance_response = json_rpc_client
+ .call(near_jsonrpc_client::methods::query::RpcQueryRequest {
+ block_reference: block_reference.clone(),
+ request: near_primitives::views::QueryRequest::CallFunction {
+ account_id: staking_pool_account_id.clone(),
+ method_name: "get_account_staked_balance".to_string(),
+ args: near_primitives::types::FunctionArgs::from(serde_json::to_vec(
+ &serde_json::json!({
+ "account_id": account_id,
+ }),
+ )?),
+ },
+ })
+ .await;
+ match account_staked_balance_response {
+ Ok(response) => Ok(near_token::NearToken::from_yoctonear(
+ response
+ .call_result()?
+ .parse_result_from_json::()
+ .wrap_err("Failed to parse return value of view function call for String.")?
+ .parse::()?,
+ )),
+ Err(near_jsonrpc_client::errors::JsonRpcError::ServerError(
+ near_jsonrpc_client::errors::JsonRpcServerError::HandlerError(
+ near_jsonrpc_client::methods::query::RpcQueryError::NoContractCode { .. }
+ | near_jsonrpc_client::methods::query::RpcQueryError::ContractExecutionError {
+ ..
+ },
+ ),
+ )) => Ok(near_token::NearToken::from_yoctonear(0)),
+ Err(err) => Err(err.into()),
+ }
+}
diff --git a/src/commands/contract/call_function/call_function_args_type/mod.rs b/src/commands/contract/call_function/call_function_args_type/mod.rs
index 4f8a706a3..c54e63e10 100644
--- a/src/commands/contract/call_function/call_function_args_type/mod.rs
+++ b/src/commands/contract/call_function/call_function_args_type/mod.rs
@@ -84,7 +84,7 @@ pub fn function_args(
super::call_function_args_type::FunctionArgsType::JsonArgs => {
let data_json =
serde_json::Value::from_str(&args).wrap_err("Data not in JSON format!")?;
- Ok(data_json.to_string().into_bytes())
+ serde_json::to_vec(&data_json).wrap_err("Internal error!")
}
super::call_function_args_type::FunctionArgsType::TextArgs => Ok(args.into_bytes()),
super::call_function_args_type::FunctionArgsType::Base64Args => {
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 719c6f7a1..374d31883 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -4,6 +4,7 @@ use strum::{EnumDiscriminants, EnumIter, EnumMessage};
pub mod account;
mod config;
pub mod contract;
+mod staking;
mod tokens;
mod transaction;
@@ -25,6 +26,11 @@ pub enum TopLevelCommand {
))]
/// Use this for token actions: send or view balances of NEAR, FT, or NFT
Tokens(self::tokens::TokensCommands),
+ #[strum_discriminants(strum(
+ message = "staking - Manage staking: view, add and withdraw stake"
+ ))]
+ /// Use this for manage staking: view, add and withdraw stake
+ Staking(self::staking::Staking),
#[strum_discriminants(strum(
message = "contract - Manage smart-contracts: deploy code, call functions"
))]
diff --git a/src/commands/staking/delegate/deposit_and_stake.rs b/src/commands/staking/delegate/deposit_and_stake.rs
new file mode 100644
index 000000000..2f3a87c55
--- /dev/null
+++ b/src/commands/staking/delegate/deposit_and_stake.rs
@@ -0,0 +1,89 @@
+#[derive(Debug, Clone, interactive_clap::InteractiveClap)]
+#[interactive_clap(input_context = super::StakeDelegationContext)]
+#[interactive_clap(output_context = DepositAndStakeContext)]
+pub struct DepositAndStake {
+ /// Enter the attached amount to be deposited and then staked into the predecessor's internal account (example: 10NEAR or 0.5near or 10000yoctonear):
+ amount: near_token::NearToken,
+ #[interactive_clap(skip_default_input_arg)]
+ /// What is validator account ID?
+ validator_account_id: crate::types::account_id::AccountId,
+ #[interactive_clap(named_arg)]
+ /// Select network
+ network_config: crate::network_for_transaction::NetworkForTransactionArgs,
+}
+
+#[derive(Clone)]
+pub struct DepositAndStakeContext(crate::commands::ActionContext);
+
+impl DepositAndStakeContext {
+ pub fn from_previous_context(
+ previous_context: super::StakeDelegationContext,
+ scope: &::InteractiveClapContextScope,
+ ) -> color_eyre::eyre::Result {
+ let on_after_getting_network_callback: crate::commands::OnAfterGettingNetworkCallback =
+ std::sync::Arc::new({
+ let signer_id = previous_context.account_id.clone();
+ let validator_account_id: near_primitives::types::AccountId =
+ scope.validator_account_id.clone().into();
+ let amount = scope.amount;
+
+ move |_network_config| {
+ Ok(crate::commands::PrepopulatedTransaction {
+ signer_id: signer_id.clone(),
+ receiver_id: validator_account_id.clone(),
+ actions: vec![near_primitives::transaction::Action::FunctionCall(
+ near_primitives::transaction::FunctionCallAction {
+ method_name: "deposit_and_stake".to_string(),
+ args: serde_json::to_vec(&serde_json::json!({}))?,
+ gas: crate::common::NearGas::from_tgas(50).as_gas(),
+ deposit: amount.as_yoctonear(),
+ },
+ )],
+ })
+ }
+ });
+
+ let on_after_sending_transaction_callback: crate::transaction_signature_options::OnAfterSendingTransactionCallback = std::sync::Arc::new({
+ let signer_id = previous_context.account_id.clone();
+ let validator_id = scope.validator_account_id.clone();
+ let amount = scope.amount;
+
+ move |outcome_view, _network_config| {
+ if let near_primitives::views::FinalExecutionStatus::SuccessValue(_) = outcome_view.status {
+ eprintln!("<{signer_id}> has successfully delegated {amount} to stake with <{validator_id}>.")
+ }
+ Ok(())
+ }
+ });
+
+ Ok(Self(crate::commands::ActionContext {
+ global_context: previous_context.global_context,
+ interacting_with_account_ids: vec![
+ previous_context.account_id.clone(),
+ scope.validator_account_id.clone().into(),
+ ],
+ on_after_getting_network_callback,
+ on_before_signing_callback: std::sync::Arc::new(
+ |_prepolulated_unsinged_transaction, _network_config| Ok(()),
+ ),
+ on_before_sending_transaction_callback: std::sync::Arc::new(
+ |_signed_transaction, _network_config, _message| Ok(()),
+ ),
+ on_after_sending_transaction_callback,
+ }))
+ }
+}
+
+impl From for crate::commands::ActionContext {
+ fn from(item: DepositAndStakeContext) -> Self {
+ item.0
+ }
+}
+
+impl DepositAndStake {
+ pub fn input_validator_account_id(
+ context: &super::StakeDelegationContext,
+ ) -> color_eyre::eyre::Result