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

Refactor: Use core's Blockchain instead of syncer's Coin type #602

Merged
merged 1 commit into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions shell/_swap-cli
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ _arguments "${_arguments_options[@]}" \
'--ctl-socket=[ZMQ socket name/address for daemon control interface]:CTL_SOCKET:_files' \
'-h[Print help information]' \
'--help[Print help information]' \
':coin -- The coin funding required needs to be checked against:' \
':blockchain -- The blockchain funding required needs to be checked against:' \
&& ret=0
;;
(sweep-bitcoin-address)
Expand Down Expand Up @@ -334,7 +334,7 @@ _swap-cli_commands() {
'revoke-offer:Revoke offer accepts an offer and revokes it within the runtime' \
'abort-swap:Abort a swap if it has not locked yet' \
'progress:Request swap progress report' \
'needs-funding:Returns addresses and amounts that require funding for coin' \
'needs-funding:Returns addresses and amounts that require funding for blockchain' \
'sweep-bitcoin-address:Attempts to sweep any funds on a given bitcoin funding address' \
'sweep-monero-address:Attempts to sweep any funds on a given monero funding address' \
'help:Print this message or the help of the given subcommand(s)' \
Expand Down
2 changes: 1 addition & 1 deletion shell/_swap-cli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Register-ArgumentCompleter -Native -CommandName 'swap-cli' -ScriptBlock {
[CompletionResult]::new('revoke-offer', 'revoke-offer', [CompletionResultType]::ParameterValue, 'Revoke offer accepts an offer and revokes it within the runtime')
[CompletionResult]::new('abort-swap', 'abort-swap', [CompletionResultType]::ParameterValue, 'Abort a swap if it has not locked yet')
[CompletionResult]::new('progress', 'progress', [CompletionResultType]::ParameterValue, 'Request swap progress report')
[CompletionResult]::new('needs-funding', 'needs-funding', [CompletionResultType]::ParameterValue, 'Returns addresses and amounts that require funding for coin')
[CompletionResult]::new('needs-funding', 'needs-funding', [CompletionResultType]::ParameterValue, 'Returns addresses and amounts that require funding for blockchain')
[CompletionResult]::new('sweep-bitcoin-address', 'sweep-bitcoin-address', [CompletionResultType]::ParameterValue, 'Attempts to sweep any funds on a given bitcoin funding address')
[CompletionResult]::new('sweep-monero-address', 'sweep-monero-address', [CompletionResultType]::ParameterValue, 'Attempts to sweep any funds on a given monero funding address')
[CompletionResult]::new('help', 'help', [CompletionResultType]::ParameterValue, 'Print this message or the help of the given subcommand(s)')
Expand Down
2 changes: 1 addition & 1 deletion shell/swap-cli.bash
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ _swap-cli() {
return 0
;;
swap__cli__needs__funding)
opts="-h -d -T -m -x --help --data-dir --tor-proxy --msg-socket --ctl-socket <COIN>"
opts="-h -d -T -m -x --help --data-dir --tor-proxy --msg-socket --ctl-socket <BLOCKCHAIN>"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down
11 changes: 4 additions & 7 deletions src/cli/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ use internet2::addr::{InetSocketAddr, NodeAddr};
use microservices::shell::Exec;

use farcaster_core::{
blockchain::Network,
blockchain::{Blockchain, Network},
negotiation::PublicOffer,
role::{SwapRole, TradeRole},
swap::SwapId,
};
use strict_encoding::ReadExt;

use super::Command;
use crate::{
rpc::{request, Client, Request},
syncerd::Coin,
};
use crate::rpc::{request, Client, Request};
use crate::{Error, LogStyle, ServiceId};

impl Exec for Command {
Expand Down Expand Up @@ -253,8 +250,8 @@ impl Exec for Command {
}
}

Command::NeedsFunding { coin } => {
runtime.request(ServiceId::Farcasterd, Request::NeedsFunding(coin))?;
Command::NeedsFunding { blockchain } => {
runtime.request(ServiceId::Farcasterd, Request::NeedsFunding(blockchain))?;
runtime.report_response_or_fail()?;
}

Expand Down
10 changes: 4 additions & 6 deletions src/cli/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use farcaster_core::{
swap::{btcxmr::PublicOffer, SwapId},
};

use crate::syncerd::Coin;

/// Command-line tool for working with Farcaster node
#[derive(Parser, Clone, PartialEq, Eq, Debug)]
#[clap(name = "swap-cli", bin_name = "swap-cli", author, version)]
Expand Down Expand Up @@ -227,11 +225,11 @@ pub enum Command {
follow: bool,
},

/// Returns addresses and amounts that require funding for coin.
#[display("needs-funding<{coin}>")]
/// Returns addresses and amounts that require funding for blockchain.
#[display("needs-funding<{blockchain}>")]
NeedsFunding {
/// The coin funding required needs to be checked against.
coin: Coin,
/// The blockchain funding required needs to be checked against.
blockchain: Blockchain,
},

/// Attempts to sweep any funds on a given bitcoin funding address
Expand Down
6 changes: 3 additions & 3 deletions src/databased/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use crate::databased::runtime::request::{
Address, OfferStatus, OfferStatusPair, OfferStatusSelector,
};
use crate::farcaster_core::consensus::Encodable;
use crate::syncerd::opts::Coin;
use crate::walletd::runtime::{CheckpointWallet, Wallet};
use farcaster_core::blockchain::Blockchain;
use farcaster_core::swap::btcxmr::PublicOffer;
use farcaster_core::swap::SwapId;
use lmdb::{Cursor, Transaction as LMDBTransaction};
Expand Down Expand Up @@ -302,7 +302,7 @@ impl Runtime {
}
}

Request::GetAddresses(Coin::Bitcoin) => {
Request::GetAddresses(Blockchain::Bitcoin) => {
let addresses = self.database.get_all_bitcoin_addresses()?;
endpoints.send_to(
ServiceBus::Ctl,
Expand Down Expand Up @@ -347,7 +347,7 @@ impl Runtime {
}
}

Request::GetAddresses(Coin::Monero) => {
Request::GetAddresses(Blockchain::Monero) => {
let addresses = self.database.get_all_monero_addresses()?;
endpoints.send_to(
ServiceBus::Ctl,
Expand Down
Loading