Skip to content

Commit

Permalink
Force set vested (#228)
Browse files Browse the repository at this point in the history
* add fn force_set_vested

* change vesting to bifrost-vesting

* remove fn force_set_vest_works

* allow local test for manual seal
  • Loading branch information
ark930 authored Aug 17, 2021
1 parent 85f253e commit b4cce63
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 19 deletions.
4 changes: 2 additions & 2 deletions 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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ run-dev:

.PHONY: run-dev-manual-seal
run-dev-manual-seal:
RUST_LOG=debug cargo run -p node-cli --locked --features "with-dev-runtime" -- --tmp --dev --sealing instant
RUST_LOG=debug cargo run -p node-cli --locked --features "with-dev-runtime" -- --tmp --dev --sealing instant --rpc-cors all --unsafe-ws-external

# Build docker image
.PHONY: build-docker-image
Expand Down
30 changes: 30 additions & 0 deletions pallets/vesting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,36 @@ pub mod pallet {
Ok(())
}

#[pallet::weight(0)]
pub fn force_set_vested(
origin: OriginFor<T>,
source: <T::Lookup as StaticLookup>::Source,
target: <T::Lookup as StaticLookup>::Source,
schedule: VestingInfo<BalanceOf<T>, T::BlockNumber>,
) -> DispatchResult {
ensure_root(origin)?;
ensure!(schedule.locked >= T::MinVestedTransfer::get(), Error::<T>::AmountLow);

let target = T::Lookup::lookup(target)?;
let source = T::Lookup::lookup(source)?;

T::Currency::remove_lock(VESTING_ID, &target);

let (from, to, value) = if schedule.locked > T::Currency::free_balance(&target) {
(&source, &target, schedule.locked - T::Currency::free_balance(&target))
} else {
(&target, &source, T::Currency::free_balance(&target) - schedule.locked)
};

T::Currency::transfer(&from, &to, value, ExistenceRequirement::AllowDeath)?;

Vesting::<T>::insert(target.clone(), schedule);
let res = Self::update_lock(target.clone());
debug_assert!(res.is_ok());

Ok(())
}

#[pallet::weight(0)]
pub fn init_vesting_start_at(
origin: OriginFor<T>,
Expand Down
16 changes: 8 additions & 8 deletions runtime/asgard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pallet-transaction-payment = { version = "3.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "3.0.0", default-features = false }
pallet-treasury = { version = "3.0.0", default-features = false }
pallet-utility = { version = "3.0.0", default-features = false }
pallet-vesting = { version = "3.0.0", default-features = false }

# Cumulus dependencies
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
Expand All @@ -80,15 +79,16 @@ pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.8" }

# bifrost pallets
bifrost-runtime-common = { package = "bifrost-runtime-common", path = "../common", default-features = false }
bifrost-vtoken-mint = { path = "../../pallets/vtoken-mint", default-features = false }
bifrost-minter-reward = { path = "../../pallets/minter-reward", default-features = false }
bifrost-bancor= { path = "../../pallets/bancor",default-features = false }
bifrost-bancor-runtime-api = { path = "../../pallets/bancor/rpc/runtime-api", default-features = false }
bifrost-flexible-fee = { path = "../../pallets/flexible-fee", default-features = false }
bifrost-flexible-fee-rpc-runtime-api = { path = "../../pallets/flexible-fee/rpc/runtime-api", default-features = false }
bifrost-salp= {path = "../../pallets/salp",default-features = false}
bifrost-bancor= {path = "../../pallets/bancor",default-features = false}
bifrost-vsbond-auction = { path = "../../pallets/vsbond-auction", default-features = false }
bifrost-bancor-runtime-api = { path = "../../pallets/bancor/rpc/runtime-api", default-features = false }
bifrost-minter-reward = { path = "../../pallets/minter-reward", default-features = false }
bifrost-runtime-common = { package = "bifrost-runtime-common", path = "../common", default-features = false }
bifrost-salp = { path = "../../pallets/salp", default-features = false }
bifrost-vsbond-auction = { path = "../../pallets/vsbond-auction", default-features = false }
bifrost-vtoken-mint = { path = "../../pallets/vtoken-mint", default-features = false }
pallet-vesting = { package = "bifrost-vesting", path = "../../pallets/vesting", default-features = false }

# orml
orml-currencies = { version = "0.4.1-dev", default-features = false }
Expand Down
16 changes: 8 additions & 8 deletions runtime/dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ pallet-transaction-payment = { version = "3.0.0", default-features = false }
pallet-transaction-payment-rpc-runtime-api = { version = "3.0.0", default-features = false }
pallet-treasury = { version = "3.0.0", default-features = false }
pallet-utility = { version = "3.0.0", default-features = false }
pallet-vesting = { version = "3.0.0", default-features = false }

# Cumulus dependencies
cumulus-pallet-aura-ext = { git = "https://github.com/paritytech/cumulus", default-features = false, branch = "polkadot-v0.9.8" }
Expand All @@ -81,15 +80,16 @@ pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.8" }

# bifrost pallets
bifrost-runtime-common = { package = "bifrost-runtime-common", path = "../common", default-features = false }
bifrost-vtoken-mint = { path = "../../pallets/vtoken-mint", default-features = false }
bifrost-minter-reward = { path = "../../pallets/minter-reward", default-features = false }
bifrost-bancor= { path = "../../pallets/bancor",default-features = false }
bifrost-bancor-runtime-api = { path = "../../pallets/bancor/rpc/runtime-api", default-features = false }
bifrost-flexible-fee = { path = "../../pallets/flexible-fee", default-features = false }
bifrost-flexible-fee-rpc-runtime-api = { path = "../../pallets/flexible-fee/rpc/runtime-api", default-features = false }
bifrost-salp= {path = "../../pallets/salp",default-features = false}
bifrost-bancor= {path = "../../pallets/bancor",default-features = false}
bifrost-vsbond-auction = { path = "../../pallets/vsbond-auction", default-features = false }
bifrost-bancor-runtime-api = { path = "../../pallets/bancor/rpc/runtime-api", default-features = false }
bifrost-minter-reward = { path = "../../pallets/minter-reward", default-features = false }
bifrost-runtime-common = { package = "bifrost-runtime-common", path = "../common", default-features = false }
bifrost-salp = { path = "../../pallets/salp", default-features = false }
bifrost-vsbond-auction = { path = "../../pallets/vsbond-auction", default-features = false }
bifrost-vtoken-mint = { path = "../../pallets/vtoken-mint", default-features = false }
pallet-vesting = { package = "bifrost-vesting", path = "../../pallets/vesting", default-features = false }

# orml
orml-currencies = { version = "0.4.1-dev", default-features = false }
Expand Down

0 comments on commit b4cce63

Please sign in to comment.