-
Notifications
You must be signed in to change notification settings - Fork 86
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
[gh-2471] add tx build command. #2472
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
pub type_args: Vec<TypeTag>, | ||
|
||
#[clap(long)] | ||
pub args: Vec<Vec<u8>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use FunctionArg
to support args parse like rooch move run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
pub function_name: String, | ||
|
||
#[clap(long)] | ||
pub type_args: Vec<TypeTag>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ParsedStructType
like rooch move run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
pub module_address: AccountAddress, | ||
|
||
#[clap(long, required = true)] | ||
pub module_name: String, | ||
|
||
#[clap(long, required = true)] | ||
pub function_name: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The three option can merge to one ParsedFunctionId
like rooch move run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
if self.output { | ||
let tx_data_hex = hex::encode(tx_data.encode()); | ||
if self.json { | ||
Ok(Some(tx_data_hex)) | ||
} else { | ||
println!( | ||
"Build transaction succeeded with the transaction hex [{}]", | ||
tx_data_hex | ||
); | ||
|
||
Ok(None) | ||
} | ||
} else if let Some(file_destination) = self.file_destination { | ||
let mut file = File::create(file_destination)?; | ||
file.write_all(&tx_data.encode())?; | ||
println!("Write encoded tx data succeeded in the destination"); | ||
|
||
Ok(None) | ||
} else { | ||
return Err(RoochError::CommandArgumentError( | ||
"Argument --file-destination is not provided".to_owned(), | ||
)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the output option if we provide file_destination
.
if file_destination is None, print the hex, otherwise write the tx to the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the output option if we provide
file_destination
.if file_destination is None, print the hex, otherwise write the tx to the file.
I'll only resolve issues of the if else clause cause the write function is only functioning on vectors not hex strings.
Summary
Add
build
subcommand forrooch tx
androoch transaction
.Example output (if writing to a file):
Example output (if outputting a hex):
rooch transaction build --function rooch_framework::empty::empty --json --output "0ea3bb55c14aec8e074cd48c6a850526aa46965e176df53fadb433adeeeb56570000000000000000040000000000000000e1f5050000000001000000000000000000000000000000000000000000000000000000000000000305656d70747905656d7074790000"
rooch tx build
generate a RoochTransactionData via argument, and output tx hex or write to a file. #2471