-
Notifications
You must be signed in to change notification settings - Fork 93
Feat/seq bump #1909
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
Merged
Merged
Feat/seq bump #1909
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5c4ae70
Add tx edit subcommand
elizabethengelman 8931ecc
Add tx edit seq-num bump command
elizabethengelman 4dff945
Add tx edit seq-num bump it test
elizabethengelman 06e422f
Factor out an it helper
elizabethengelman 3339591
Merge branch 'main' into feat/seq-bump
elizabethengelman 34ac90b
Apply cargo fmt changes
elizabethengelman 81f531c
Clippy
elizabethengelman daf06fd
Check in generated docs
elizabethengelman 84c7251
Add bump amount arg
elizabethengelman 9a9e686
Fmt
elizabethengelman 0c833a7
Bump -> increment
elizabethengelman bd985f2
Generated docs
elizabethengelman df032d3
Merge branch 'main' into feat/seq-bump
elizabethengelman a7648d8
Merge branch 'main' into feat/seq-bump
elizabethengelman 4522e20
Merge branch 'main' into feat/seq-bump
elizabethengelman 5ea223e
Implement tx edit seq-num next
elizabethengelman c6caa65
Move seq-num next to update subcommand
elizabethengelman b7069b0
Merge branch 'main' into feat/seq-bump
elizabethengelman e99245c
Update generated docs
elizabethengelman 3a6473c
Cleanup
elizabethengelman cebc9b8
Merge branch 'main' into feat/seq-bump
elizabethengelman 2dd1a08
Address pr feedback: use tx source acct for seq num
elizabethengelman 3b728ae
Address feedback: update xdr error
elizabethengelman 0897d28
Merge branch 'main' into feat/seq-bump
elizabethengelman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use super::global; | ||
|
||
pub mod sequence_number; | ||
|
||
#[derive(Debug, clap::Subcommand)] | ||
pub enum Cmd { | ||
/// Edit the sequence number on a transaction | ||
#[command(subcommand, visible_alias = "seq-num")] | ||
SequenceNumber(sequence_number::Cmd), | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
SequenceNumber(#[from] sequence_number::Error), | ||
} | ||
|
||
impl Cmd { | ||
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> { | ||
match self { | ||
Cmd::SequenceNumber(cmd) => cmd.run(global_args).await?, | ||
}; | ||
Ok(()) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
cmd/soroban-cli/src/commands/tx/update/sequence_number/mod.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use super::global; | ||
|
||
mod next; | ||
|
||
#[derive(Debug, clap::Subcommand)] | ||
pub enum Cmd { | ||
/// Fetch the source account's seq-num and increment for the given tx | ||
#[command()] | ||
Next(next::Cmd), | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Next(#[from] next::Error), | ||
} | ||
|
||
impl Cmd { | ||
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> { | ||
match self { | ||
Cmd::Next(cmd) => cmd.run(global_args).await?, | ||
}; | ||
Ok(()) | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
cmd/soroban-cli/src/commands/tx/update/sequence_number/next.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use stellar_xdr::curr::MuxedAccount; | ||
|
||
use crate::{ | ||
commands::{ | ||
global, | ||
tx::xdr::{tx_envelope_from_input, Error as XdrParsingError}, | ||
}, | ||
config::{self, locator, network}, | ||
xdr::{self, SequenceNumber, TransactionEnvelope, WriteXdr}, | ||
}; | ||
|
||
#[derive(clap::Parser, Debug, Clone)] | ||
pub struct Cmd { | ||
#[command(flatten)] | ||
pub network: network::Args, | ||
#[command(flatten)] | ||
pub locator: locator::Args, | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
XdrStdin(#[from] XdrParsingError), | ||
#[error(transparent)] | ||
Xdr(#[from] xdr::Error), | ||
#[error("V0 and fee bump transactions are not supported")] | ||
Unsupported, | ||
#[error(transparent)] | ||
RpcClient(#[from] crate::rpc::Error), | ||
#[error(transparent)] | ||
Config(#[from] config::Error), | ||
#[error(transparent)] | ||
Network(#[from] config::network::Error), | ||
} | ||
|
||
impl Cmd { | ||
pub async fn run(&self, global_args: &global::Args) -> Result<(), Error> { | ||
let mut tx = tx_envelope_from_input(&None)?; | ||
self.update_tx_env(&mut tx, global_args).await?; | ||
println!("{}", tx.to_xdr_base64(xdr::Limits::none())?); | ||
Ok(()) | ||
} | ||
|
||
pub async fn update_tx_env( | ||
&self, | ||
tx_env: &mut TransactionEnvelope, | ||
_global: &global::Args, | ||
) -> Result<(), Error> { | ||
match tx_env { | ||
TransactionEnvelope::Tx(transaction_v1_envelope) => { | ||
let tx_source_acct = &transaction_v1_envelope.tx.source_account; | ||
let current_seq_num = self.current_seq_num(tx_source_acct).await?; | ||
let next_seq_num = current_seq_num + 1; | ||
transaction_v1_envelope.tx.seq_num = SequenceNumber(next_seq_num); | ||
} | ||
TransactionEnvelope::TxV0(_) | TransactionEnvelope::TxFeeBump(_) => { | ||
return Err(Error::Unsupported); | ||
} | ||
}; | ||
Ok(()) | ||
} | ||
|
||
async fn current_seq_num(&self, tx_source_acct: &MuxedAccount) -> Result<i64, Error> { | ||
let network = &self.network.get(&self.locator)?; | ||
let client = network.rpc_client()?; | ||
client | ||
.verify_network_passphrase(Some(&network.network_passphrase)) | ||
.await?; | ||
|
||
let address = tx_source_acct.to_string(); | ||
|
||
let account = client.get_account(&address).await?; | ||
Ok(*account.seq_num.as_ref()) | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.