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

Offline signatures from SDK #4234

Merged
merged 5 commits into from
Jan 16, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Removes the SignTx struct and cli command as it's a duplicate of `S…
…ignOffline`
grarco committed Jan 14, 2025
commit 6ea2ebc9f61111d25034c877920e050eb61a86a2
61 changes: 0 additions & 61 deletions crates/apps_lib/src/cli.rs
Original file line number Diff line number Diff line change
@@ -296,7 +296,6 @@ pub mod cmds {
.subcommand(QueryEffNativeSupply::def().display_order(5))
.subcommand(QueryStakingRewardsRate::def().display_order(5))
// Actions
.subcommand(SignTx::def().display_order(6))
.subcommand(ShieldedSync::def().display_order(6))
.subcommand(GenIbcShieldingTransfer::def().display_order(6))
// Utils
@@ -1919,25 +1918,6 @@ pub mod cmds {
}
}

#[derive(Clone, Debug)]
pub struct SignTx(pub args::SignTx<args::CliTypes>);

impl SubCmd for SignTx {
const CMD: &'static str = "sign-tx";

fn parse(matches: &ArgMatches) -> Option<Self> {
matches
.subcommand_matches(Self::CMD)
.map(|matches| SignTx(args::SignTx::parse(matches)))
}

fn def() -> App {
App::new(Self::CMD)
.about(wrap!("Sign a transaction offline."))
.add_args::<args::SignTx<args::CliTypes>>()
}
}

#[derive(Clone, Debug)]
pub struct QueryValidatorState(
pub args::QueryValidatorState<args::CliTypes>,
@@ -6761,47 +6741,6 @@ pub mod args {
}
}

impl CliToSdk<SignTx<SdkTypes>> for SignTx<CliTypes> {
type Error = std::io::Error;

fn to_sdk(
self,
ctx: &mut Context,
) -> Result<SignTx<SdkTypes>, Self::Error> {
let tx = self.tx.to_sdk(ctx)?;
let tx_data = std::fs::read(self.tx_data)?;

Ok(SignTx::<SdkTypes> {
tx,
tx_data,
owner: ctx.borrow_chain_or_exit().get(&self.owner),
})
}
}

impl Args for SignTx<CliTypes> {
fn parse(matches: &ArgMatches) -> Self {
let tx = Tx::parse(matches);
let tx_path = TX_PATH.parse(matches);
let owner = OWNER.parse(matches);
Self {
tx,
tx_data: tx_path,
owner,
}
}

fn def(app: App) -> App {
app.add_args::<Tx<CliTypes>>()
.arg(TX_PATH.def().help(wrap!(
"The path to the tx file with the serialized tx."
)))
.arg(
OWNER.def().help(wrap!("The address of the account owner")),
)
}
}

impl Args for ShieldedSync<CliTypes> {
fn parse(matches: &ArgMatches) -> Self {
let ledger_address = CONFIG_RPC_LEDGER_ADDRESS.parse(matches);
11 changes: 0 additions & 11 deletions crates/sdk/src/args.rs
Original file line number Diff line number Diff line change
@@ -2141,17 +2141,6 @@ impl TxReactivateValidator {
}
}

#[derive(Clone, Debug)]
/// Sign a transaction offline
pub struct SignTx<C: NamadaTypes = SdkTypes> {
/// Common tx arguments
pub tx: Tx<C>,
/// Transaction data
pub tx_data: C::Data,
/// The account address
pub owner: C::Address,
}

#[derive(Clone, Debug)]
/// Sync notes from MASP owned by the provided spending /
/// viewing keys. Syncing can be told to stop at a given