mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-23 18:18:31 +02:00
Revert "[CONTRACTS] Contracts branch update for 1.80 (#718)"
This reverts commit cdd63fb565.
This commit is contained in:
@@ -446,149 +446,3 @@ subcommands:
|
||||
- input:
|
||||
help: Filename of a proof file
|
||||
index: 1
|
||||
- contract:
|
||||
subcommands:
|
||||
- new:
|
||||
about: Create a new contract with initial setup
|
||||
args:
|
||||
- encrypt-for:
|
||||
help: The counter party grin address
|
||||
short: e
|
||||
long: encrypt-for
|
||||
takes_value: true
|
||||
# index: 1
|
||||
- receive:
|
||||
help: How much you want to receive
|
||||
short: r
|
||||
long: receive
|
||||
takes_value: true
|
||||
- send:
|
||||
help: How much you want to send
|
||||
short: s
|
||||
long: send
|
||||
takes_value: true
|
||||
- num-participants:
|
||||
help: How many participants are involved? (can be 1 or 2)
|
||||
short: n
|
||||
long: num-participants
|
||||
takes_value: true
|
||||
default_value: "2"
|
||||
- as-json:
|
||||
help: Show result as JSON
|
||||
short: j
|
||||
long: as-json
|
||||
takes_value: false
|
||||
- no-payjoin:
|
||||
help: Don't make it a payjoin (if receiver)
|
||||
long: no-payjoin
|
||||
takes_value: false
|
||||
- add-outputs:
|
||||
help: Defines whether we should pick inputs/outputs in the first step.
|
||||
short: a
|
||||
long: add-outputs
|
||||
takes_value: false
|
||||
- use-inputs:
|
||||
help: Which inputs you want to use (provide comma separated commitments)
|
||||
short: i
|
||||
long: use-inputs
|
||||
takes_value: true
|
||||
- make-outputs:
|
||||
help: Which outputs should we create? (provide comma separated amounts)
|
||||
short: o
|
||||
long: make-outputs
|
||||
takes_value: true
|
||||
# - setup:
|
||||
# about: Perform a key setup on a contract
|
||||
# args:
|
||||
# - encrypt-for:
|
||||
# help: The counter party grin address
|
||||
# short: e
|
||||
# long: encrypt-for
|
||||
# takes_value: true
|
||||
# # index: 1
|
||||
# - receive:
|
||||
# help: How much you want to receive
|
||||
# short: r
|
||||
# long: receive
|
||||
# takes_value: true
|
||||
# - send:
|
||||
# help: How much you want to send
|
||||
# short: s
|
||||
# long: send
|
||||
# takes_value: true
|
||||
# - as-json:
|
||||
# help: Show result as JSON
|
||||
# short: j
|
||||
# long: as-json
|
||||
# takes_value: false
|
||||
# - no-payjoin:
|
||||
# help: Don't make it a payjoin (if receiver)
|
||||
# long: no-payjoin
|
||||
# takes_value: false
|
||||
# - add-outputs:
|
||||
# help: Defines whether we should pick inputs/outputs in the setup step.
|
||||
# short: a
|
||||
# long: add-outputs
|
||||
# takes_value: false
|
||||
# - use-inputs:
|
||||
# help: Which inputs you want to use (provide comma separated commitments)
|
||||
# short: i
|
||||
# long: use-inputs
|
||||
# takes_value: true
|
||||
# - make-outputs:
|
||||
# help: Which outputs should we create? (provide comma separated amounts)
|
||||
# short: o
|
||||
# long: make-outputs
|
||||
# takes_value: true
|
||||
- sign:
|
||||
about: Sign a contract
|
||||
args:
|
||||
- encrypt-for:
|
||||
help: The counter party grin address
|
||||
short: e
|
||||
long: encrypt-for
|
||||
takes_value: true
|
||||
# index: 1
|
||||
- receive:
|
||||
help: How much you want to receive
|
||||
short: r
|
||||
long: receive
|
||||
takes_value: true
|
||||
- send:
|
||||
help: How much you want to send
|
||||
short: s
|
||||
long: send
|
||||
takes_value: true
|
||||
- as-json:
|
||||
help: Show result as JSON
|
||||
short: j
|
||||
long: as-json
|
||||
takes_value: false
|
||||
- no-payjoin:
|
||||
help: Don't make it a payjoin (if receiver)
|
||||
long: no-payjoin
|
||||
takes_value: false
|
||||
- use-inputs:
|
||||
help: Which inputs you want to use (provide comma separated commitments)
|
||||
short: i
|
||||
long: use-inputs
|
||||
takes_value: true
|
||||
- make-outputs:
|
||||
help: Which outputs should we create? (provide comma separated amounts)
|
||||
short: o
|
||||
long: make-outputs
|
||||
takes_value: true
|
||||
- no-broadcast:
|
||||
help: Don't broadcast the transaction if it was finalized
|
||||
long: no-broadcast
|
||||
takes_value: false
|
||||
- view:
|
||||
about: View a contract
|
||||
- revoke:
|
||||
about: Attempt to revoke a contract
|
||||
args:
|
||||
- tx-id:
|
||||
help: Id of a transaction we want to cancel
|
||||
short: i
|
||||
long: tx-id
|
||||
takes_value: true
|
||||
|
||||
+4
-1
@@ -39,10 +39,13 @@ fn main() {
|
||||
}
|
||||
|
||||
// build and versioning information
|
||||
let mut opts = built::Options::default();
|
||||
opts.set_dependencies(true);
|
||||
let out_dir_path = format!("{}{}", env::var("OUT_DIR").unwrap(), "/built.rs");
|
||||
// don't fail the build if something's missing, may just be cargo release
|
||||
let _ = built::write_built_file_with_opts(
|
||||
Some(Path::new(env!("CARGO_MANIFEST_DIR"))),
|
||||
&opts,
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")),
|
||||
Path::new(&out_dir_path),
|
||||
);
|
||||
}
|
||||
|
||||
+1
-169
@@ -12,14 +12,13 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/// Argument parsing and error handling for wallet commands
|
||||
use self::core::consensus;
|
||||
use crate::api::TLSConfig;
|
||||
use crate::cli::command_loop;
|
||||
use crate::config::GRIN_WALLET_DIR;
|
||||
use crate::util::file::get_first_line;
|
||||
use crate::util::secp::key::SecretKey;
|
||||
use crate::util::{Mutex, ZeroingString};
|
||||
/// Argument parsing and error handling for wallet commands
|
||||
use clap::ArgMatches;
|
||||
use grin_core as core;
|
||||
use grin_core::core::amount_to_hr_string;
|
||||
@@ -966,148 +965,6 @@ pub fn parse_verify_proof_args(args: &ArgMatches) -> Result<command::ProofVerify
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: parse args
|
||||
pub fn parse_contract_new_args(
|
||||
args: &ArgMatches,
|
||||
account: &String,
|
||||
) -> Result<command::ContractNewArgs, ParseError> {
|
||||
let counterparty_addr = args.value_of("encrypt-for").unwrap();
|
||||
|
||||
// TODO: Make sure the values are in some expected bounds.
|
||||
// TODO: How to deal with decimals and precision? we probably want users to express the value in Grin.
|
||||
// Parse receive and send params and convert them to nano grin
|
||||
let receive = match args.value_of("receive") {
|
||||
Some(g) => Some((g.parse::<f64>().unwrap() * consensus::GRIN_BASE as f64) as u64),
|
||||
None => None,
|
||||
};
|
||||
let send = match args.value_of("send") {
|
||||
Some(g) => Some((g.parse::<f64>().unwrap() * consensus::GRIN_BASE as f64) as u64),
|
||||
None => None,
|
||||
};
|
||||
if receive.is_some() && send.is_some() {
|
||||
return Err(ParseError::ArgumentError(String::from(
|
||||
"You can only specify receive or send, not both.",
|
||||
)));
|
||||
};
|
||||
// TODO: verify this is correct e.g. which values are passed here by default etc.
|
||||
let src_acct_name = Some(String::from(account));
|
||||
let add_outputs = args.is_present("add-outputs");
|
||||
let as_json = args.is_present("as-json");
|
||||
let no_payjoin = args.is_present("no-payjoin");
|
||||
let use_inputs = match args.value_of("use-inputs") {
|
||||
Some(v) => {
|
||||
if no_payjoin {
|
||||
panic!("Can't use --no-payjoin with --use-inputs.");
|
||||
}
|
||||
Some(String::from(v))
|
||||
}
|
||||
None => {
|
||||
if no_payjoin {
|
||||
None
|
||||
} else {
|
||||
// Some("any") means pick 1 random input to contribute (payjoin)
|
||||
Some(String::from("any"))
|
||||
}
|
||||
}
|
||||
};
|
||||
let make_outputs = match args.value_of("make-outputs") {
|
||||
Some(v) => Some(String::from(v)),
|
||||
None => None,
|
||||
};
|
||||
|
||||
let num_participants = args
|
||||
.value_of("num-participants")
|
||||
.unwrap()
|
||||
.parse::<u8>()
|
||||
.unwrap();
|
||||
|
||||
Ok(command::ContractNewArgs {
|
||||
counterparty_addr: String::from(counterparty_addr),
|
||||
receive: receive,
|
||||
send: send,
|
||||
src_acct_name: src_acct_name,
|
||||
num_participants: num_participants,
|
||||
as_json: as_json,
|
||||
add_outputs: add_outputs,
|
||||
use_inputs: use_inputs,
|
||||
make_outputs: make_outputs,
|
||||
// TODO: Future features below
|
||||
fee_rate: None,
|
||||
outfile: None,
|
||||
})
|
||||
}
|
||||
|
||||
// TODO: parse args
|
||||
pub fn parse_contract_setup_args(
|
||||
args: &ArgMatches,
|
||||
) -> Result<command::ContractSetupArgs, ParseError> {
|
||||
// TODO: Make sure the values are in some expected bounds.
|
||||
// TODO: How to deal with decimals and precision? we probably want users to express the value in Grin.
|
||||
let counterparty_addr = match args.value_of("encrypt-for") {
|
||||
Some(v) => Some(String::from(v)),
|
||||
None => None,
|
||||
};
|
||||
// Parse receive and send params and convert them to nano grin
|
||||
let receive = match args.value_of("receive") {
|
||||
Some(g) => Some((g.parse::<f64>().unwrap() * consensus::GRIN_BASE as f64) as u64),
|
||||
None => None,
|
||||
};
|
||||
let send = match args.value_of("send") {
|
||||
Some(g) => Some((g.parse::<f64>().unwrap() * consensus::GRIN_BASE as f64) as u64),
|
||||
None => None,
|
||||
};
|
||||
if receive.is_some() && send.is_some() {
|
||||
return Err(ParseError::ArgumentError(String::from(
|
||||
"You can only specify receive or send, not both.",
|
||||
)));
|
||||
};
|
||||
let as_json = args.is_present("as-json");
|
||||
let no_payjoin = args.is_present("no-payjoin");
|
||||
let use_inputs = match args.value_of("use-inputs") {
|
||||
Some(v) => {
|
||||
if no_payjoin {
|
||||
panic!("Can't use --no-payjoin with --use-inputs.");
|
||||
}
|
||||
Some(String::from(v))
|
||||
}
|
||||
None => {
|
||||
if no_payjoin {
|
||||
None
|
||||
} else {
|
||||
// Some("any") means pick 1 random input to contribute (payjoin)
|
||||
Some(String::from("any"))
|
||||
}
|
||||
}
|
||||
};
|
||||
let make_outputs = match args.value_of("make-outputs") {
|
||||
Some(v) => Some(String::from(v)),
|
||||
None => None,
|
||||
};
|
||||
// TODO: should we catch if the person calls "--receive=5" when it should be "--send=5"?
|
||||
// Perhaps we could detect this from the slate state e.g. S1 -> receive, I1 -> send?
|
||||
|
||||
Ok(command::ContractSetupArgs {
|
||||
counterparty_addr: counterparty_addr,
|
||||
receive: receive,
|
||||
send: send,
|
||||
as_json: as_json,
|
||||
add_outputs: false,
|
||||
use_inputs: use_inputs,
|
||||
make_outputs: make_outputs,
|
||||
// TODO: Future features below
|
||||
fee_rate: None,
|
||||
outfile: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn parse_contract_revoke_args(
|
||||
args: &ArgMatches,
|
||||
) -> Result<command::ContractRevokeArgs, ParseError> {
|
||||
let tx_id = args.value_of("tx-id").unwrap().parse::<u32>().unwrap();
|
||||
|
||||
Ok(command::ContractRevokeArgs { tx_id: tx_id })
|
||||
}
|
||||
|
||||
pub fn wallet_command<C, F>(
|
||||
wallet_args: &ArgMatches,
|
||||
mut wallet_config: WalletConfig,
|
||||
@@ -1438,31 +1295,6 @@ where
|
||||
// for CLI mode only, should be handled externally
|
||||
Ok(())
|
||||
}
|
||||
("contract", Some(args)) => match args.subcommand() {
|
||||
("new", Some(new_args)) => {
|
||||
let account = &global_wallet_args.account;
|
||||
let a = arg_parse!(parse_contract_new_args(&new_args, account));
|
||||
command::contract_new(owner_api, km, a)
|
||||
}
|
||||
// ("setup", Some(setup_args)) => {
|
||||
// let a = arg_parse!(parse_contract_setup_args(&setup_args));
|
||||
// command::contract_setup(owner_api, km, a)
|
||||
// }
|
||||
("sign", Some(sign_args)) => {
|
||||
// Sign command takes setup_args so we use the same parser
|
||||
let setup_args = arg_parse!(parse_contract_setup_args(&sign_args));
|
||||
let broadcast_tx = !sign_args.is_present("no-broadcast");
|
||||
command::contract_sign(owner_api, km, setup_args, broadcast_tx)
|
||||
}
|
||||
("view", Some(view_args)) => {
|
||||
Err(Error::ArgumentError(String::from("Not implemented")).into())
|
||||
}
|
||||
("revoke", Some(revoke_args)) => {
|
||||
let a = arg_parse!(parse_contract_revoke_args(&revoke_args));
|
||||
command::contract_revoke(owner_api, km, a)
|
||||
}
|
||||
_ => Err(Error::ArgumentError(String::from("Unknown contract subcommand.")).into()),
|
||||
},
|
||||
_ => {
|
||||
let msg = format!("Unknown wallet command, use 'grin-wallet help' for details");
|
||||
return Err(Error::ArgumentError(msg));
|
||||
|
||||
Reference in New Issue
Block a user