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

[gh-2471] add tx build command. #2472

Merged
merged 10 commits into from
Aug 22, 2024
Merged

[gh-2471] add tx build command. #2472

merged 10 commits into from
Aug 22, 2024

Conversation

feliciss
Copy link
Collaborator

@feliciss feliciss commented Aug 19, 2024

Summary

Add build subcommand for rooch tx and rooch transaction.

Example output (if writing to a file):

rooch transaction build --function rooch_framework::empty::empty --json --file-location ~/text.txt
Write encoded tx data succeeded in the designated location

cat ~/text.txt                                                                                    
??U?J?LԌj?&?F?^m????3???VW??emptyempty% 

Example output (if outputting a hex):

rooch transaction build --function rooch_framework::empty::empty --json --output
"0ea3bb55c14aec8e074cd48c6a850526aa46965e176df53fadb433adeeeb56570000000000000000040000000000000000e1f5050000000001000000000000000000000000000000000000000000000000000000000000000305656d70747905656d7074790000"

Copy link

vercel bot commented Aug 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rooch-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 21, 2024 6:55pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rooch ⬜️ Ignored (Inspect) Visit Preview Aug 21, 2024 6:55pm

pub type_args: Vec<TypeTag>,

#[clap(long)]
pub args: Vec<Vec<u8>>,
Copy link
Contributor

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

Copy link
Collaborator Author

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>,
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment on lines 18 to 24
pub module_address: AccountAddress,

#[clap(long, required = true)]
pub module_name: String,

#[clap(long, required = true)]
pub function_name: String,
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

Comment on lines 91 to 105
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(),
));
}
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

@jolestar jolestar merged commit e725ba7 into rooch-network:main Aug 22, 2024
7 checks passed
@feliciss feliciss deleted the #2471 branch August 22, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide rooch tx build generate a RoochTransactionData via argument, and output tx hex or write to a file.
2 participants