Skip to content

Commit 7f27de7

Browse files
authored
Merge pull request #4886 from namada-net/mergify/bp/maint-201.0/pr-4816
Refactor SDK args and sigs (backport #4816)
2 parents 40be69d + 445bad6 commit 7f27de7

File tree

15 files changed

+1752
-1346
lines changed

15 files changed

+1752
-1346
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
- Reworked SDK wrapping and signatures, including some breaking changes.
2+
More specifically:
3+
- The wrapper arguments have been extracted into a separate type and their
4+
presence signals the need to wrap the tx
5+
- The dump and dry-run arguments have been turned into enumerations
6+
- The wrapper signer data has been removed from SigningTxData and moved into
7+
SigningWrapperData
8+
- Simplified the interface of aux_signing_data
9+
- Removed redundant dispatcher functions
10+
- Prevent casting from a wrapped to a raw transaction type
11+
- Prevent submitting an unwrapped transaction
12+
- Avoided passing the MASP internal address as a transaction's owner
13+
- Updated the interface of build_batch
14+
- Removed the owner for reveal_pk
15+
([\#4816](https://github.com/anoma/namada/pull/4816))

.github/workflows/scripts/check-changelog.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ check_changelog_added_in_subfolders() {
88
fi
99
echo "Using sha: $head_commit"
1010

11-
subfolders=("ci" "bug-fixes" "improvements" "miscellaneous" "features" "testing" "docs")
11+
subfolders=("ci" "bug-fixes" "improvements" "miscellaneous" "features" "testing" "docs" "SDK")
1212

1313
subfolder_pattern=$(printf "|%s" "${subfolders[@]}")
1414
subfolder_pattern=${subfolder_pattern:1} # Remove the leading '|'
@@ -26,4 +26,4 @@ check_changelog_added_in_subfolders() {
2626
fi
2727
}
2828

29-
check_changelog_added_in_subfolders
29+
check_changelog_added_in_subfolders

crates/apps_lib/src/cli.rs

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7708,21 +7708,24 @@ pub mod args {
77087708
ctx: &mut Context,
77097709
) -> Result<Tx<SdkTypes>, Self::Error> {
77107710
let ctx = ctx.borrow_mut_chain_or_exit();
7711+
let wrapper = self.wrap_tx.map(|wrapper| Wrapper {
7712+
broadcast_only: wrapper.broadcast_only,
7713+
fee_amount: wrapper.fee_amount,
7714+
fee_token: ctx.get(&wrapper.fee_token).into(),
7715+
gas_limit: wrapper.gas_limit,
7716+
wrapper_fee_payer: wrapper
7717+
.wrapper_fee_payer
7718+
.map(|x| ctx.get(&x)),
7719+
});
77117720

77127721
Ok(Tx::<SdkTypes> {
77137722
dry_run: self.dry_run,
7714-
dry_run_wrapper: self.dry_run_wrapper,
77157723
dump_tx: self.dump_tx,
7716-
dump_wrapper_tx: self.dump_wrapper_tx,
77177724
output_folder: self.output_folder,
77187725
force: self.force,
7719-
broadcast_only: self.broadcast_only,
77207726
ledger_address: ctx.get(&self.ledger_address),
77217727
initialized_account_alias: self.initialized_account_alias,
77227728
wallet_alias_force: self.wallet_alias_force,
7723-
fee_amount: self.fee_amount,
7724-
fee_token: ctx.get(&self.fee_token).into(),
7725-
gas_limit: self.gas_limit,
77267729
signing_keys: self
77277730
.signing_keys
77287731
.iter()
@@ -7734,7 +7737,7 @@ pub mod args {
77347737
chain_id: self
77357738
.chain_id
77367739
.or_else(|| Some(ctx.config.ledger.chain_id.clone())),
7737-
wrapper_fee_payer: self.wrapper_fee_payer.map(|x| ctx.get(&x)),
7740+
wrap_tx: wrapper,
77387741
memo: self.memo,
77397742
use_device: self.use_device,
77407743
device_transport: self.device_transport,
@@ -7861,10 +7864,20 @@ pub mod args {
78617864
}
78627865

78637866
fn parse(matches: &ArgMatches) -> Self {
7864-
let dry_run = DRY_RUN_TX.parse(matches);
7865-
let dry_run_wrapper = DRY_RUN_WRAPPER_TX.parse(matches);
7866-
let dump_tx = DUMP_TX.parse(matches);
7867-
let dump_wrapper_tx = DUMP_WRAPPER_TX.parse(matches);
7867+
let dry_run = if DRY_RUN_TX.parse(matches) {
7868+
Some(DryRun::Inner)
7869+
} else if DRY_RUN_WRAPPER_TX.parse(matches) {
7870+
Some(DryRun::Wrapper)
7871+
} else {
7872+
None
7873+
};
7874+
let dump_tx = if DUMP_TX.parse(matches) {
7875+
Some(DumpTx::Inner)
7876+
} else if DUMP_WRAPPER_TX.parse(matches) {
7877+
Some(DumpTx::Wrapper)
7878+
} else {
7879+
None
7880+
};
78687881
let force = FORCE.parse(matches);
78697882
let broadcast_only = BROADCAST_ONLY.parse(matches);
78707883
let ledger_address = CONFIG_RPC_LEDGER_ADDRESS.parse(matches);
@@ -7893,25 +7906,30 @@ pub mod args {
78937906
}
78947907
};
78957908
let device_transport = DEVICE_TRANSPORT.parse(matches);
7909+
// Wrap the transaction unless we want to dump or dry-run the raw tx
7910+
let wrap_tx = match (&dump_tx, &dry_run) {
7911+
(_, Some(DryRun::Inner)) | (Some(DumpTx::Inner), _) => None,
7912+
_ => Some(Wrapper {
7913+
broadcast_only,
7914+
fee_amount,
7915+
wrapper_fee_payer,
7916+
fee_token,
7917+
gas_limit,
7918+
}),
7919+
};
78967920
Self {
78977921
dry_run,
7898-
dry_run_wrapper,
78997922
dump_tx,
7900-
dump_wrapper_tx,
79017923
force,
7902-
broadcast_only,
79037924
ledger_address,
79047925
initialized_account_alias,
79057926
wallet_alias_force,
7906-
fee_amount,
7907-
fee_token,
7908-
gas_limit,
79097927
expiration,
79107928
signing_keys,
79117929
tx_reveal_code_path,
79127930
password,
79137931
chain_id,
7914-
wrapper_fee_payer,
7932+
wrap_tx,
79157933
output_folder,
79167934
memo,
79177935
use_device,

crates/apps_lib/src/cli/client.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ impl CliApi {
3737
client.wait_until_node_is_synced(&io).await?;
3838
let args = args.to_sdk(&mut ctx)?;
3939
let namada = ctx.to_sdk(client, io);
40-
let dry_run =
41-
args.tx.dry_run || args.tx.dry_run_wrapper;
40+
let dry_run = args.tx.dry_run.is_some();
4241
tx::submit_custom(&namada, args).await?;
4342
if !dry_run {
4443
namada
@@ -192,8 +191,7 @@ impl CliApi {
192191
client.wait_until_node_is_synced(&io).await?;
193192
let args = args.to_sdk(&mut ctx)?;
194193
let namada = ctx.to_sdk(client, io);
195-
let dry_run =
196-
args.tx.dry_run || args.tx.dry_run_wrapper;
194+
let dry_run = args.tx.dry_run.is_some();
197195
tx::submit_init_account(&namada, args).await?;
198196
if !dry_run {
199197
namada

0 commit comments

Comments
 (0)