Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make offer / take offer cli yaml serializable #437

Merged

Conversation

TheCharlatan
Copy link
Member

@TheCharlatan TheCharlatan commented May 15, 2022

Based on #436 , addresses parts of #285 .
The cli currently returns formatted strings when the user runs make or take offer. With this PR these formatted strings are replaced with a yaml object. The output therefore currently also foregoes color formatting. Please comment on the tradeoffs made here, especially whether I should attempt to preserve the color formatting.

PR #436 make output:

swap0-cli make --btc-addr tb1q935eq5fl2a3ajpqp0e3d7z36g7vctcgv05f5lf --xmr-addr 54EYTy2HYFcAXwAbFQ3HmAis8JLNmxRdTC9DwQL7sGJd4CAUYimPxuQHYkMNg1EELNP85YqFwqraLd4ovz6UeeekFLoCKiu --btc-amount "0.0000135 BTC" --xmr-amount "0.005 XMR" --network Testnet --arb-blockchain ECDSA --acc-blockchain Monero --maker-role Bob --cancel-timelock 8 --punish-timelock 10 --fee-strategy "1 satoshi/vByte" --public-ip-addr 127.0.0.1 --bind-ip-addr 0.0.0.0 --port 9735 --overlay tcp
Success: Public offer registered, please share with taker:  Offer:Cke4ftrP5A71LQM2fvVdFMNR4gmBqNCsR11111uMFxZS82VT4msZoKV11111TBBgPR113GTvtvqfD1111114A4TUjY3fAV1d3HiXbKibmTya9uGbmAMrLdiGBFStCtAJUWEP11111111111111111111111111111111111111111AfZ113XRBuxwnz2U

PR #436 take output:

swap1-cli take --btc-addr tb1qhwxs7tw5xfqdw4r3wnjuufnjfqzty6u265cz7m --xmr-addr 52ATjSm1ZRYMdY1XzoYnMzBuYpuz3RE5m2GC5s7hVhQmQodatmyy9FBGZfoDK29mvkfeJR6rCwZVZaUHeeYuZfJLPAQsGz2 --offer $Offer
Success: Public offer registered: 0xfea1…5fe5

This PR make command:

swap0-cli make --btc-addr tb1q935eq5fl2a3ajpqp0e3d7z36g7vctcgv05f5lf --xmr-addr 54EYTy2HYFcAXwAbFQ3HmAis8JLNmxRdTC9DwQL7sGJd4CAUYimPxuQHYkMNg1EELNP85YqFwqraLd4ovz6UeeekFLoCKiu --btc-amount "0.0000135 BTC" --xmr-amount "0.005 XMR" --network Testnet --arb-blockchain ECDSA --acc-blockchain Monero --maker-role Bob --cancel-timelock 8 --punish-timelock 10 --fee-strategy "1 satoshi/vByte" --public-ip-addr 127.0.0.1 --bind-ip-addr 0.0.0.0 --port 9735 --overlay tcp
---
offer: "Offer:Cke4ftrP5A71LQM2fvVdFMNR4gmBqNCsR11111uMFxZS82VT4msZoKV11111TBBgPR113GTvtvqfD1111114A4TUjY3fAV1d3HiXbKibmTya9uGbmAMrLdiGBFStCtAJUWEP11111111111111111111111111111111111111111AfZ113XRBuxwnz2U"
message: "Public offer registered, please share with taker."

This PR take command:

swap1-cli take --btc-addr tb1qhwxs7tw5xfqdw4r3wnjuufnjfqzty6u265cz7m --xmr-addr 52ATjSm1ZRYMdY1XzoYnMzBuYpuz3RE5m2GC5s7hVhQmQodatmyy9FBGZfoDK29mvkfeJR6rCwZVZaUHeeYuZfJLPAQsGz2 --offer $Offer
---
offerid: "0xfea11b55341a46931b3381a2ef27469374f7a49f8730fb3803bfdf881e955fe5"
message: Public offer registered

@codecov-commenter
Copy link

codecov-commenter commented May 15, 2022

Codecov Report

Merging #437 (0e194d8) into main (c1c21c1) will decrease coverage by 0.2%.
The diff coverage is 8.1%.

@@           Coverage Diff           @@
##            main    #437     +/-   ##
=======================================
- Coverage   12.9%   12.7%   -0.2%     
=======================================
  Files         27      27             
  Lines       7916    7937     +21     
=======================================
- Hits        1021    1007     -14     
- Misses      6895    6930     +35     
Impacted Files Coverage Δ
src/farcasterd/runtime.rs 0.0% <0.0%> (ø)
src/cli/command.rs 29.8% <50.0%> (ø)
src/rpc/request.rs 15.1% <57.1%> (+0.7%) ⬆️
src/rpc/client.rs 55.7% <0.0%> (-11.4%) ⬇️
src/lib.rs 10.4% <0.0%> (-1.6%) ⬇️
src/service.rs 11.4% <0.0%> (-1.4%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1c21c1...0e194d8. Read the comment docs.

@TheCharlatan TheCharlatan force-pushed the makeOfferTakeOfferCliYAML branch from c4762da to 42e8ae0 Compare May 15, 2022 10:37
@TheCharlatan TheCharlatan force-pushed the makeOfferTakeOfferCliYAML branch from 42e8ae0 to eafbbb2 Compare May 30, 2022 14:40
@TheCharlatan TheCharlatan marked this pull request as ready for review May 30, 2022 14:40
@TheCharlatan TheCharlatan requested a review from zkao May 30, 2022 15:27
@h4sh3d
Copy link
Member

h4sh3d commented May 30, 2022

In an ideal world we would have something like --format yaml in cli that allow printing yaml, with a default to "string" or human readable format.

At least for some cli actions like this one were both can be justified. What do you think?

@TheCharlatan
Copy link
Member Author

Sure, what really counts for me is that we use proper data structures and are consistent between the cli calls. We could also add --format json easily, or --format string. I think we should add this (in a separate series of PRs), since all we need to do is add some serde traits and slightly adjust the cli binary. Ideally such a code change would not touch the other, permanent, microservices at all (and I don't think it would).

src/farcasterd/runtime.rs Outdated Show resolved Hide resolved
@TheCharlatan TheCharlatan requested a review from h4sh3d May 30, 2022 16:17
@TheCharlatan TheCharlatan merged commit 580db73 into farcaster-project:main Jun 6, 2022
@TheCharlatan TheCharlatan mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants