Skip to content

Commit

Permalink
fix: add inline comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
nakul1010 committed Aug 15, 2023
1 parent f1891cc commit 4a0f29b
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/issue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl<T: Config> Pallet<T> {
}

// Function to retrieve the vault ID associated with a given issue ID
pub fn get_vault_from_id_from_issue_id(issue_id: &H256) -> Result<DefaultVaultId<T>, DispatchError> {
pub fn get_vault_from_issue_id(issue_id: &H256) -> Result<DefaultVaultId<T>, DispatchError> {
// Retrieve the issue request using the provided issue_id
let issue_request = Self::get_issue_request_from_id(issue_id)?;

Expand Down
4 changes: 2 additions & 2 deletions crates/issue/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ fn execute_issue_fails_for_replace_request() {
}

#[test]
fn complete_issue_request_for_replace() {
fn fail_to_cancel_completed_replace_issue_request() {
run_test(|| {
let issue_id = setup_execute(3, 1, 1, 3, AccountOrVault::Vault(OLD_VAULT));
assert_ok!(Issue::_complete_vault_issue(issue_id));
Expand All @@ -438,7 +438,7 @@ fn complete_issue_request_for_replace() {
}

#[test]
fn cancel_issue_for_replace() {
fn cancel_replace_issue_request() {
run_test(|| {
let griefing_collateral = 10;
let issue_id = setup_execute(3, 1, griefing_collateral, 3, AccountOrVault::Vault(OLD_VAULT));
Expand Down
6 changes: 2 additions & 4 deletions crates/redeem/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,8 @@ pub(crate) mod issue {
<issue::Pallet<T>>::_complete_vault_issue(issue_id)
}

pub fn get_vault_from_id_from_issue_id<T: crate::Config>(
issue_id: &H256,
) -> Result<DefaultVaultId<T>, DispatchError> {
<issue::Pallet<T>>::get_vault_from_id_from_issue_id(issue_id)
pub fn get_vault_from_issue_id<T: crate::Config>(issue_id: &H256) -> Result<DefaultVaultId<T>, DispatchError> {
<issue::Pallet<T>>::get_vault_from_issue_id(issue_id)
}

pub fn cancel_issue_request_and_slash_collateral<T: crate::Config>(
Expand Down
2 changes: 1 addition & 1 deletion crates/redeem/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ impl<T: Config> Pallet<T> {
);

let old_vault_id = &redeem.vault;
let new_vault_id = ext::issue::get_vault_from_id_from_issue_id::<T>(&issue_id)?;
let new_vault_id = ext::issue::get_vault_from_issue_id::<T>(&issue_id)?;

// decrease old-vault's to-be-redeemed tokens, and
// decrease new-vault's to-be-issued tokens
Expand Down
2 changes: 1 addition & 1 deletion crates/redeem/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ mod redeem_replace_tests {
ext::btc_relay::verify_and_validate_op_return_transaction::<Test, Balance>
.mock_safe(|_, _, _, _| MockResult::Return(Ok(())));
ext::btc_relay::has_request_expired::<Test>.mock_safe(|_, _, _| MockResult::Return(Ok(true)));
ext::issue::get_vault_from_id_from_issue_id::<Test>.mock_safe(|_| MockResult::Return(Ok(NEW_VAULT)));
ext::issue::get_vault_from_issue_id::<Test>.mock_safe(|_| MockResult::Return(Ok(NEW_VAULT)));
ext::vault_registry::cancel_replace_tokens::<Test>.mock_safe(|_, _, _| MockResult::Return(Ok(())));
ext::issue::cancel_issue_request_and_slash_collateral::<Test>.mock_safe(|_| MockResult::Return(Ok(1)));

Expand Down
2 changes: 2 additions & 0 deletions primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,15 @@ pub enum AccountOrVault<AccountId, CurrencyId: Copy> {
Vault(VaultId<AccountId, CurrencyId>),
}
impl<AccountId, CurrencyId: Copy> AccountOrVault<AccountId, CurrencyId> {
// Method to retrieve the account associated with an `AccountOrVault` instance
pub fn get_account(&self) -> &AccountId {
match self {
AccountOrVault::Account(account_id) => account_id,
AccountOrVault::Vault(vault_id) => &vault_id.account_id,
}
}

// Method to check if the enum variant is `Vault`
pub fn is_vault_account(&self) -> bool {
matches!(self, AccountOrVault::Vault(_))
}
Expand Down

0 comments on commit 4a0f29b

Please sign in to comment.