Skip to content

Commit c33b860

Browse files
authored
Add remove_vault in pallet-bitacross (#2863)
* Add remove_vault * Do not pay fees for now
1 parent 610ea48 commit c33b860

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

pallets/bitacross/src/lib.rs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub mod pallet {
7272
RelayerRemoved { who: Identity },
7373
BtcWalletGenerated { pub_key: PubKey, account_id: T::AccountId },
7474
EthWalletGenerated { pub_key: PubKey },
75+
VaultRemoved { who: T::AccountId },
7576
}
7677

7778
#[pallet::error]
@@ -81,6 +82,7 @@ pub mod pallet {
8182
UnsupportedRelayerType,
8283
BtcWalletAlreadyExist,
8384
EthWalletAlreadyExist,
85+
VaultNotExist,
8486
}
8587

8688
#[pallet::genesis_config]
@@ -123,23 +125,39 @@ pub mod pallet {
123125

124126
#[pallet::call_index(1)]
125127
#[pallet::weight({195_000_000})]
126-
pub fn add_relayer(origin: OriginFor<T>, account: Identity) -> DispatchResult {
128+
pub fn add_relayer(origin: OriginFor<T>, account: Identity) -> DispatchResultWithPostInfo {
127129
Self::ensure_admin_or_root(origin)?;
128130
ensure!(account.is_substrate() || account.is_evm(), Error::<T>::UnsupportedRelayerType);
129131
// we don't care if `account` already exists
130132
Relayer::<T>::insert(account.clone(), ());
131133
Self::deposit_event(Event::RelayerAdded { who: account });
132-
Ok(())
134+
Ok(Pays::No.into())
133135
}
134136

135137
#[pallet::call_index(2)]
136138
#[pallet::weight({195_000_000})]
137-
pub fn remove_relayer(origin: OriginFor<T>, account: Identity) -> DispatchResult {
139+
pub fn remove_relayer(
140+
origin: OriginFor<T>,
141+
account: Identity,
142+
) -> DispatchResultWithPostInfo {
138143
Self::ensure_admin_or_root(origin)?;
139144
ensure!(Relayer::<T>::contains_key(&account), Error::<T>::RelayerNotExist);
140145
Relayer::<T>::remove(account.clone());
141146
Self::deposit_event(Event::RelayerRemoved { who: account });
142-
Ok(())
147+
Ok(Pays::No.into())
148+
}
149+
150+
#[pallet::call_index(3)]
151+
#[pallet::weight({195_000_000})]
152+
pub fn remove_vault(
153+
origin: OriginFor<T>,
154+
account: T::AccountId,
155+
) -> DispatchResultWithPostInfo {
156+
Self::ensure_admin_or_root(origin)?;
157+
ensure!(Vault::<T>::contains_key(&account), Error::<T>::VaultNotExist);
158+
Vault::<T>::remove(account.clone());
159+
Self::deposit_event(Event::VaultRemoved { who: account });
160+
Ok(Pays::No.into())
143161
}
144162

145163
/// ---------------------------------------------------

pallets/teebag/src/lib.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#![allow(clippy::too_many_arguments)]
1919

2020
use frame_support::{
21-
dispatch::{DispatchErrorWithPostInfo, DispatchResult, DispatchResultWithPostInfo},
21+
dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo},
2222
ensure,
2323
pallet_prelude::*,
2424
traits::Get,
@@ -511,15 +511,15 @@ pub mod pallet {
511511
},
512512
};
513513
Self::add_enclave(&sender, &enclave)?;
514-
Ok(().into())
514+
Ok(Pays::No.into())
515515
}
516516

517517
#[pallet::call_index(9)]
518518
#[pallet::weight((195_000_000, DispatchClass::Normal))]
519519
pub fn unregister_enclave(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
520520
let sender = ensure_signed(origin)?;
521521
Self::remove_enclave(&sender)?;
522-
Ok(().into())
522+
Ok(Pays::No.into())
523523
}
524524

525525
#[pallet::call_index(10)]
@@ -560,10 +560,13 @@ pub mod pallet {
560560

561561
#[pallet::call_index(20)]
562562
#[pallet::weight((195_000_000, DispatchClass::Normal))]
563-
pub fn post_opaque_task(origin: OriginFor<T>, request: RsaRequest) -> DispatchResult {
563+
pub fn post_opaque_task(
564+
origin: OriginFor<T>,
565+
request: RsaRequest,
566+
) -> DispatchResultWithPostInfo {
564567
let _ = ensure_signed(origin)?;
565568
Self::deposit_event(Event::OpaqueTaskPosted { request });
566-
Ok(())
569+
Ok(Pays::No.into())
567570
}
568571

569572
#[pallet::call_index(21)]

0 commit comments

Comments
 (0)