Skip to content

Commit c8d9e64

Browse files
committed
refactor: key registration parameters
Updates offline key registration parameters to use an optional non-participation flag. This simplifies the logic and provides more flexibility when marking an account as non-participating. It also adds a test to verify an account cannot be brought back online after being marked as non-participating.
1 parent 28d379e commit c8d9e64

File tree

4 files changed

+132
-205
lines changed

4 files changed

+132
-205
lines changed

crates/algokit_utils/src/lib.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,8 @@ pub use testing::{
1111
AlgorandFixture, AlgorandTestContext, algorand_fixture, algorand_fixture_with_config,
1212
};
1313
pub use transactions::{
14-
AssetCreateParams,
15-
AssetDestroyParams,
16-
AssetReconfigureParams,
17-
CommonParams,
18-
Composer,
19-
ComposerError,
20-
ComposerTxn,
21-
EmptySigner,
22-
NonParticipationKeyRegistrationParams,
23-
OfflineKeyRegistrationParams,
24-
OnlineKeyRegistrationParams,
25-
PaymentParams,
26-
TxnSigner,
14+
AssetCreateParams, AssetDestroyParams, AssetReconfigureParams, CommonParams, Composer,
15+
ComposerError, ComposerTxn, EmptySigner, NonParticipationKeyRegistrationParams,
16+
OfflineKeyRegistrationParams, OnlineKeyRegistrationParams, PaymentParams, TxnSigner,
2717
TxnSignerGetter,
2818
};

crates/algokit_utils/src/transactions/composer.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use algod_client::{
44
models::{PendingTransactionResponse, TransactionParams},
55
};
66
use algokit_transact::{
7-
Address, AlgorandMsgpack, AssetConfigTransactionFields, FeeParams, KeyRegistrationTransactionFields,
8-
PaymentTransactionFields, SignedTransaction, Transaction, TransactionHeader, Transactions,
7+
Address, AlgorandMsgpack, AssetConfigTransactionFields, FeeParams,
8+
KeyRegistrationTransactionFields, PaymentTransactionFields, SignedTransaction, Transaction,
9+
TransactionHeader, Transactions,
910
};
1011
use derive_more::Debug;
1112
use std::sync::Arc;
@@ -97,10 +98,7 @@ pub struct OnlineKeyRegistrationParams {
9798
#[derive(Debug, Clone)]
9899
pub struct OfflineKeyRegistrationParams {
99100
pub common_params: CommonParams,
100-
/// Whether to prevent the account from ever participating in consensus again.
101-
/// - `false`: Temporary offline (can be brought back online later)
102-
/// - `true`: Permanent offline (account can never participate again)
103-
pub prevent_account_from_ever_participating_again: bool,
101+
pub non_participation: Option<bool>,
104102
}
105103

106104
#[derive(Debug, Clone)]
@@ -480,13 +478,7 @@ impl Composer {
480478
vote_last: None,
481479
vote_key_dilution: None,
482480
state_proof_key: None,
483-
non_participation: if offline_key_reg_params
484-
.prevent_account_from_ever_participating_again
485-
{
486-
Some(true)
487-
} else {
488-
None
489-
},
481+
non_participation: offline_key_reg_params.non_participation,
490482
})
491483
}
492484
ComposerTxn::NonParticipationKeyRegistration(_) => {
@@ -908,7 +900,7 @@ mod tests {
908900
first_valid_round: None,
909901
last_valid_round: None,
910902
},
911-
prevent_account_from_ever_participating_again: false,
903+
non_participation: Some(false),
912904
};
913905
assert!(
914906
composer

0 commit comments

Comments
 (0)