Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .maintain/build-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ WORK_PATH=${BIN_PATH}/..

RUNTIME=$1

cd runtime && ln -fsn $RUNTIME bifrost
docker run --rm -i \
-e PACKAGE=$RUNTIME-runtime \
-e VERBOSE=1 \
Expand All @@ -18,6 +19,5 @@ docker run --rm -i \
paritytech/srtool:${RUSTC_VERSION} build ${EXTRA_ARGS}

mkdir -p ${WORK_PATH}/deploy/wasm
ln -fsn ${WORK_PATH}/runtime/$RUNTIME ${WORK_PATH}/runtime/bifrost
cp ${WORK_PATH}/runtime/$RUNTIME/target/srtool/release/wbuild/$RUNTIME-runtime/${RUNTIME/-/_}_runtime.compact.compressed.wasm \
${WORK_PATH}/deploy/wasm
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "node-cli"
version = "0.9.16"
version = "0.9.18"
authors = ["Liebi Technologies <bifrost@liebi.com>"]
description = "Bifrost Parachain Node"
build = "build.rs"
Expand Down
53 changes: 52 additions & 1 deletion pallets/vesting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ pub mod pallet {
#[pallet::getter(fn vesting_start_at)]
pub(super) type VestingStartAt<T: Config> = StorageValue<_, T::BlockNumber>;

/// Cliff vesting
#[pallet::storage]
#[pallet::getter(fn cliffs)]
pub(super) type Cliff<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountId, T::BlockNumber>;

/// Information regarding the vesting of a given account.
#[pallet::storage]
#[pallet::getter(fn vesting)]
Expand Down Expand Up @@ -214,6 +220,8 @@ pub mod pallet {
VestingStartAtNotSet,
/// Wrong amount
WrongLockedAmount,
/// Wrong vesting during cliff period
WrongCliffVesting,
}

#[pallet::hooks]
Expand All @@ -239,6 +247,7 @@ pub mod pallet {
)]
pub fn vest(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::check_cliff(who.clone())?;
Self::update_lock(who)
}

Expand All @@ -265,7 +274,9 @@ pub mod pallet {
target: <T::Lookup as StaticLookup>::Source,
) -> DispatchResult {
ensure_signed(origin)?;
Self::update_lock(T::Lookup::lookup(target)?)
let who = T::Lookup::lookup(target)?;
Self::check_cliff(who.clone())?;
Self::update_lock(who)
}

/// Create a vested transfer.
Expand Down Expand Up @@ -446,6 +457,20 @@ pub mod pallet {

Ok(())
}

#[pallet::weight(0)]
pub fn force_set_cliff(
origin: OriginFor<T>,
target: <T::Lookup as StaticLookup>::Source,
cliff_block: T::BlockNumber,
) -> DispatchResult {
ensure_root(origin)?;

let target = T::Lookup::lookup(target)?;
Cliff::<T>::insert(target.clone(), cliff_block);

Ok(())
}
}
}

Expand All @@ -471,6 +496,16 @@ impl<T: Config> Pallet<T> {
}
Ok(())
}

fn check_cliff(who: T::AccountId) -> DispatchResult {
if let Some(cliff_block) = Cliff::<T>::get(who.clone()) {
let now = <frame_system::Pallet<T>>::block_number();
ensure!(cliff_block < now, Error::<T>::WrongCliffVesting);
Cliff::<T>::remove(who);
};

Ok(())
}
}

impl<T: Config> VestingSchedule<T::AccountId> for Pallet<T>
Expand Down Expand Up @@ -1110,4 +1145,20 @@ mod tests {
assert_eq!(Vesting::vesting(&1), Some(user3_vesting_schedule)); // Account 1 has a vesting schedule
});
}

#[test]
fn set_cliff_should_work() {
ExtBuilder::default().existential_deposit(10).build().execute_with(|| {
assert_ok!(Vesting::vest(Some(1).into()));
assert_ok!(Vesting::force_set_cliff(Origin::root(), 1, 10));
assert_noop!(Vesting::vest(Some(1).into()), Error::<Test>::WrongCliffVesting);
assert_noop!(Vesting::vest_other(Some(2).into(), 1), Error::<Test>::WrongCliffVesting);
System::set_block_number(10);
assert_noop!(Vesting::vest(Some(1).into()), Error::<Test>::WrongCliffVesting);
assert_noop!(Vesting::vest_other(Some(2).into(), 1), Error::<Test>::WrongCliffVesting);
System::set_block_number(11);
assert_ok!(Vesting::vest(Some(1).into()));
assert_ok!(Vesting::vest_other(Some(2).into(), 1));
});
}
}
2 changes: 1 addition & 1 deletion runtime/bifrost-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("bifrost"),
impl_name: create_runtime_str!("bifrost"),
authoring_version: 1,
spec_version: 916,
spec_version: 918,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 1,
Expand Down