atomicDEX-API
atomicDEX-API copied to clipboard
feat(cli): all general commands are implemented
This PR introduces the most of commands provided by both Legacy and 2.0 versions of Komodo DeFi framework RPC API that were not introduced in the earlier versions:
swap: active_swaps, my_swap_status, my_recent_swaps, min_trading_vol, max_taker_vol, network: get_gossip_mesh, get_gossip_peer_topics, get_gossip_topic_peers, get_my_peer_id, get_peers_info, get_relay_mesh coin: disable_coin, set_required_confirmations, set_requires_notarization, coins_needed_for_kick_start utility: get_current_mtp, ban_pubkey, list_banned_pubkeys, unban_pubkeys wallet: show_priv_key, validate_address, kmd_rewards_info convertaddress, convert_utxo_address, tx_history, sign_message, verify_message, send_raw_transaction, withdraw (v2), get_raw_transaction, get_public_key, get_public_key_hash, enable: enable_bch_with_tokens, - enable_slp, enable_tendermint_with_assets, enable_tendermint_token, enable_eth_with_tokens, enable_erc20, task_enable_z_coin_init, task_enable_z_coin_status, task_enable_z_coin_cancel version stat: add_node_to_version_stat, remove_node_from_version_stat, start_version_stat_collection, stop_version_stat_collection, update_version_stat_collection
Dependency Updates:
komodefi-cli
Package | From | To | mm2 |
---|---|---|---|
addr2line | 0.19.0 | 0.17.0 | 0.17.0 |
aho-corasick | 1.0.1 | 0.7.18 | 0.7.18 |
allocator-api2 | 0.2.15 | 0.2.16 | |
anstyle | 1.0.0 | 1.0.1 | |
anstyle-parse | 0.2.0 | 0.2.1 | |
anstyle-wincon | 1.0.1 | 1.0.2 | |
anyhow | 1.0.71 | 1.0.42 | 1.0.42 |
arrayvec | 0.7.2 | 0.7.1 | 0.7.1 |
async-trait | 0.1.68 | 0.1.52 | 0.1.52 |
backtrace | 0.3.67 | 0.3.66 | 0.3.66 |
blake2b_simd | 0.5.11 | 0.5.10 | 0.5.10 |
bumpalo | 3.12.2 | 3.12.0 | 3.12.0 |
cc | 1.0.79 | 1.0.74 | 1.0.74 |
chrono | 0.4.24 | 0.4.23 | 0.4.23 |
clap | 4.3.4 | 4.2.7 | 2.33.3 |
clap_builder | 4.3.4 | 4.2.7 | |
clap_derive | 4.3.2 | 4.2.0 | |
clap_lex | 0.5.0 | 0.4.1 | |
cpufeatures | 0.2.7 | 0.2.1 | 0.2.1 |
crossbeam-epoch | 0.9.14 | 0.9.5 | 0.9.5 |
crossbeam-utils | 0.8.15 | 0.8.8 | 0.8.8 |
crossterm_winapi | 0.9.0 | 0.9.1 | |
cxx | 1.0.94 | 1.0.81 | 1.0.81 |
cxx-build | 1.0.94 | 1.0.62 | 1.0.62 |
cxxbridge-flags | 1.0.94 | 1.0.81 | 1.0.81 |
cxxbridge-macro | 1.0.94 | 1.0.81 | 1.0.81 |
derive_more | 0.99.17 | 0.99.11 | 0.99.11 |
dyn-clone | 1.0.11 | 1.0.12 | |
either | 1.8.1 | 1.6.0 | 1.6.0 |
errno | 0.3.1 | 0.3.2 | 0.2.8 |
gimli | 0.27.2 | 0.26.2 | 0.26.2 |
h2 | 0.3.18 | 0.3.19 | 0.3.19 |
hermit-abi | 0.1.14, 0.3.1 | 0.1.14, 0.3.2 | 0.1.14 |
hyper-rustls | 0.23.2 | 0.23.0 | 0.23.0 |
iana-time-zone | 0.1.56 | 0.1.53 | 0.1.53 |
ipnet | 2.7.2 | 2.3.0 | 2.3.0 |
is-terminal | 0.4.7 | 0.4.9 | |
itoa | 1.0.6 | 1.0.1 | 1.0.1 |
js-sys | 0.3.57 | 0.3.55 | 0.3.55 |
libc | 0.2.144 | 0.2.139 | 0.2.139 |
lightning-invoice | NEW | 0.21.0 | |
link-cplusplus | 1.0.8 | 1.0.7 | 1.0.7 |
linux-raw-sys | 0.3.8 | 0.4.5 | 0.1.4 |
lock_api | 0.4.9 | 0.4.6 | 0.4.6 |
memoffset | 0.8.0 | 0.6.4 | 0.6.4 |
metrics | 0.21.0 | 0.21.1 | 0.21.1 |
num_cpus | 1.15.0 | 1.13.1 | 1.13.1 |
object | 0.30.3 | 0.29.0 | 0.29.0 |
once_cell | 1.17.1 | 1.16.0 | 1.16.0 |
parity-scale-codec | 3.5.0 | 3.1.2 | 3.1.2 |
parity-scale-codec-derive | 3.1.4 | 3.1.2 | |
parking_lot | 0.12.1 | 0.12.0 | 0.12.0 |
parking_lot_core | 0.9.7 | 0.9.1 | 0.9.1 |
paste | 1.0.12 | 1.0.7 | 1.0.7 |
portable-atomic | 1.3.3 | 1.3.2 | 1.3.2 |
proc-macro-crate | 1.3.1 | 1.1.3 | 1.1.3 |
proc-macro2 | 1.0.56 | 1.0.58 | 1.0.58 |
redox_syscall | 0.2.16 | 0.2.10 | |
redox_users | 0.4.3 | 0.4.0 | |
regex | 1.8.1 | 1.5.6 | 1.5.6 |
regex-syntax | 0.7.1 | 0.6.26 | 0.6.26 |
rustc_version | 0.4.0 | 0.2.3 | 0.2.3 |
rustix | 0.37.20 | 0.38.8 | 0.36.9 |
ryu | 1.0.13 | 1.0.5 | 1.05 |
scratch | 1.0.5 | 1.0.2 | 1.0.2 |
security-framework | 2.9.1 | 2.9.2 | |
security-framework-sys | 2.9.0 | 2.9.1 | |
semver | 1.0.17 | 0.9.0 | 0.9.0 |
serde | 1.0.163 | 1.0.164 | 1.0.164 |
serde_derive | 1.0.163 | 1.0.164 | 1.0.164 |
serde_json | 1.0.96 | 1.0.79 | 1.0.79 |
serde_repr | 0.1.12 | 0.1.6 | 0.1.6 |
signal-hook | 0.3.15 | 0.3.17 | |
smallvec | 1.10.0 | 1.6.1 | 1.6.1 |
syn | 2.0.15 | 2.0.16 | 2.0.16 |
term-table | NEW | 1.3.2 | |
thiserror | 1.0.40 | 1.0.30 | 1.0.30 |
thiserror-impl | 1.0.40 | 1.0.30 | 1.0.30 |
tokio | 1.28.1 | 1.25.0 | 1.25.0 |
tokio-macros | 2.1.0 | 1.7.0 | 1.7.0 |
toml | NEW | 0.5.7 | |
tracing | 0.1.37 | 0.1.34 | 0.1.34 |
tracing-attributes | 0.1.24 | 0.1.20 | 0.1.20 |
tracing-core | 0.1.30 | 0.1.26 | 0.1.26 |
unicode-ident | 1.0.8 | 1.0.0 | 1.0.0 |
uuid | 1.3.2 | 1.2.2 | 1.2.2 |
wasm-bindgen-futures | 0.4.30 | 0.4.21 | 0.4.21 |
wasm-bindgen-test | 0.3.30 | 0.3.13 | 0.3.13 |
wasm-bindgen-test-macro | 0.3.30 | 0.3.13 | 0.3.13 |
web-sys | 0.3.57 | 0.3.55 | 0.3.55 |
windows-targets | 0.48.0 | 0.48.1 | 0.42.1 |
why not use the same dependency versions used in mm2 when you can to make it easier for dep reviewers
cc: @shamardy
- I see you changed some lifetime optimized structs/funcs to not using lifetime and you opted in for cloning the data instead... can you share a reason why you followed this part? e.g MakerOrder, TakerOrderForRpc etc.
Thank you for pointing it out )
Concerning structs that have started be able to be deserialzed, e.g. TakerOrderForRpc
- it's a common way for our project to not keep references inside this kind of structs.
cc: @borngraced
mm2src/mm2_rpc/src/structs/ is a more appropriate mod name compare to mm2src/mm2_rpc/src/data/.
Data is more commonly used for network layer data types, it could be structs, enums, aliases ... anything that could serialized and vice versa.
cc: @borngraced
Thank you for the fixes! Next review iteration, I finished reviewing all changes related to mm2 code. Will have a quick look at adex-cli in next review. One note, It would be good to remove the duplicates in
struct.rs
that we moved to a common crate. @rozhkovdmitrii Please at least open an issue for this refactor and other duplicated structs you used in this PR.
@rozhkovdmitrii can you please write to the QA team documentation/examples to test adex-cli with. E.g. how to launch/stop mm2 using cli, list of methods implemented, and how to use them, etc.. If you already wrote some of these in other issues/PRs, you can also link to them.
Sure, thank you for suggestion, will do that
Looking forward to testing this. Please add @kivqa and I to the reviewers once docs/examples are ready.
@smk762, @kivqa, hello! Let me inform you that komodefi-cli reference has been completed and ready to review
smk762@pig:~/GITHUB/KP/atomicDEX-API/bin$ komodefi-cli init
Start collecting mm2_cfg into: MM2.json
> gui is set by default: komodefi-cli
> What is the network `mm2` is going to be a part, netid: 7777
> What is the seed phrase: ---- pledge ----- voyage ------ coil ------- sleep ------ street ----- era
> Allow weak password: Yes
> What is the rpc_password: 2bzu=UA)
> What is dbdir None
> What is rpcip: None
> What is the rpcport: None
> What is rpc_local_only: yes
> What is i_am_a_seed: no
Reading seed nodes until tap enter is met
> What is the next seednode: None
> What is enable_hd: no
mm2_cfg has been writen into: MM2.json
Getting coin set from: https://raw.githubusercontent.com/KomodoPlatform/coins/master/coins
Got coins data, written into: coins
Start getting activation_scheme from: "/home/smk762/.config/komodefi-cli/activation_scheme.json"
Download activation_scheme from: https://stats.kmd.io/api/table/coin_activation/
Initialization done
smk762@pig:~/GITHUB/KP/atomicDEX-API/bin$ cat MM2.json
{
"gui": "komodefi-cli",
"netid": 7777,
"rpc_password": "2bzu=UA)",
"passphrase": "select ------- daring ---------- fun ----- valid ------- quit ------- obtain ---",
"allow_weak_password": true,
"rpc_local_only": true,
"i_am_seed": false,
"enable_hd": false
}
It would be good to include rpcport, rpcip and dbdir entries in MM2.json even if default.
komodefi-cli config set
error: the following required arguments were not provided:
<--password|--uri <URI>>
Usage: komodefi-cli config set <--password|--uri <URI>>
For more information, try '--help'.
This is a little confusing. Suggest if no params, ask user input for both. maybe make example like:
Usage:
komodefi-cli config set --password # opens user input to set password
komodefi-cli config set --uri http://127.0.0.1:7783 # set rpc ip
either way, good to specify if http://
bit and :7783
is required (or use input validation etc). Might also be convenient to have an option to source the config from MM2.json
like komodefi-cli config set --from_MM2_json
Saw error like Configuration file: '/home/smk762/.config/komodefi-cli/komodefi_cfg.json' - does not comply to the expected mode: 660, the actual one is: 664
Can app update the permissions?
For komodefi-cli config get
mm2 RPC URL: http://127.0.0.1:7783
mm2 RPC password: *************
can we please add a flag like --unhide
to optionally expose the rpc password?
komodefi-cli mm2
Manage mm2 instance commands
Usage: komodefi-cli mm2 <COMMAND>
Commands:
start Start mm2 instance
stop Stop mm2 using API
kill Kill mm2 process
status Check if mm2 is running
version Get version of intermediary mm2 service
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
It would be really great to have an option in this menu for downloading & extracting latest mm2 release into folder where komodefi-cli mm2 start
expects it to be. The required url can be derived from github api at https://api.github.com/repos/KomodoPlatform/komodo-defi-framework/releases
Curl example: curl -vvv https://api.github.com/repos/KomodoPlatform/atomicDEX-API/releases | jq -r '.[0].assets | map(select(.name | contains("Linux-Release."))) | .[0].browser_download_url'
@borngraced can you please work on these fixes https://github.com/KomodoPlatform/komodo-defi-framework/pull/1932#issuecomment-1729684767 in next sprints after ARRR wasm is completed?
@borngraced can you please work on these fixes https://github.com/KomodoPlatform/komodo-defi-framework/pull/1932#issuecomment-1729684767 in next sprints after ARRR wasm is completed?
Alright cool 👍
@borngraced please merge with latest dev where there are some changes related to adex-cli.
smk762@pig:~/GITHUB/KP/atomicDEX-API/bin$ komodefi-cli init Start collecting mm2_cfg into: MM2.json > gui is set by default: komodefi-cli > What is the network `mm2` is going to be a part, netid: 7777 > What is the seed phrase: ---- pledge ----- voyage ------ coil ------- sleep ------ street ----- era > Allow weak password: Yes > What is the rpc_password: 2bzu=UA) > What is dbdir None > What is rpcip: None > What is the rpcport: None > What is rpc_local_only: yes > What is i_am_a_seed: no Reading seed nodes until tap enter is met > What is the next seednode: None > What is enable_hd: no mm2_cfg has been writen into: MM2.json Getting coin set from: https://raw.githubusercontent.com/KomodoPlatform/coins/master/coins Got coins data, written into: coins Start getting activation_scheme from: "/home/smk762/.config/komodefi-cli/activation_scheme.json" Download activation_scheme from: https://stats.kmd.io/api/table/coin_activation/ Initialization done smk762@pig:~/GITHUB/KP/atomicDEX-API/bin$ cat MM2.json { "gui": "komodefi-cli", "netid": 7777, "rpc_password": "2bzu=UA)", "passphrase": "select ------- daring ---------- fun ----- valid ------- quit ------- obtain ---", "allow_weak_password": true, "rpc_local_only": true, "i_am_seed": false, "enable_hd": false }
It would be good to include rpcport, rpcip and dbdir entries in MM2.json even if default.
komodefi-cli config set error: the following required arguments were not provided: <--password|--uri <URI>> Usage: komodefi-cli config set <--password|--uri <URI>> For more information, try '--help'.
This is a little confusing. Suggest if no params, ask user input for both. maybe make example like:
Usage: komodefi-cli config set --password # opens user input to set password komodefi-cli config set --uri http://127.0.0.1:7783 # set rpc ip
either way, good to specify if
http://
bit and:7783
is required (or use input validation etc). Might also be convenient to have an option to source the config fromMM2.json
likekomodefi-cli config set --from_MM2_json
Saw error like
Configuration file: '/home/smk762/.config/komodefi-cli/komodefi_cfg.json' - does not comply to the expected mode: 660, the actual one is: 664
Can app update the permissions?For
komodefi-cli config get
mm2 RPC URL: http://127.0.0.1:7783 mm2 RPC password: *************
can we please add a flag like
--unhide
to optionally expose the rpc password?
komodefi-cli mm2
Manage mm2 instance commands Usage: komodefi-cli mm2 <COMMAND> Commands: start Start mm2 instance stop Stop mm2 using API kill Kill mm2 process status Check if mm2 is running version Get version of intermediary mm2 service help Print this message or the help of the given subcommand(s) Options: -h, --help Print help
It would be really great to have an option in this menu for downloading & extracting latest mm2 release into folder where
komodefi-cli mm2 start
expects it to be. The required url can be derived from github api at https://api.github.com/repos/KomodoPlatform/komodo-defi-framework/releasesCurl example:
curl -vvv https://api.github.com/repos/KomodoPlatform/atomicDEX-API/releases | jq -r '.[0].assets | map(select(.name | contains("Linux-Release."))) | .[0].browser_download_url'
I just finished implementing these enhancements/functionalities. @shamardy @smk762
@onur-ozkan can you please review all the commits since the last approval of this PR?
CI fails https://github.com/KomodoPlatform/komodo-defi-framework/actions/runs/7099396312/job/19323313119?pr=1932
check/test/build fails for Windows https://github.com/KomodoPlatform/komodo-defi-framework/actions/runs/7099767054/job/19324474791?pr=1932
@smk762 can you please check if your comments here https://github.com/KomodoPlatform/komodo-defi-framework/pull/1932#issuecomment-1729684767 are resolved?
Has been deprecated here https://github.com/KomodoPlatform/komodo-defi-framework/pull/2234 , we will provide a more maintainable version for the cli in the future.