Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBalance as default dapp-staking reward destination #975

Merged
merged 5 commits into from
Jul 13, 2023
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
10 changes: 5 additions & 5 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 bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astar-collator"
version = "5.12.0"
version = "5.13.0"
description = "Astar collator implementation in Rust."
build = "build.rs"
default-run = "astar-collator"
Expand Down
2 changes: 1 addition & 1 deletion pallets/dapps-staking/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pallet-dapps-staking"
version = "3.9.0"
version = "3.10.0"
description = "FRAME pallet to staking for dapps"
authors.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion pallets/dapps-staking/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use super::*;
use crate::Pallet as DappsStaking;

use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_support::traits::{Get, OnFinalize, OnInitialize};
use frame_support::traits::{Currency, Get, OnFinalize, OnInitialize};
use frame_system::{Pallet as System, RawOrigin};
use sp_runtime::traits::{One, TrailingZeroInput};

Expand Down
3 changes: 1 addition & 2 deletions pallets/dapps-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#![cfg_attr(not(feature = "std"), no_std)]

use astar_primitives::Balance;
use frame_support::traits::Currency;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_runtime::{traits::Zero, RuntimeDebug};
Expand Down Expand Up @@ -541,7 +540,7 @@ pub enum RewardDestination {

impl Default for RewardDestination {
fn default() -> Self {
RewardDestination::StakeBalance
RewardDestination::FreeBalance
}
}

Expand Down
19 changes: 18 additions & 1 deletion pallets/dapps-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
// along with Astar. If not, see <http://www.gnu.org/licenses/>.

use super::{pallet::pallet::Error, pallet::pallet::Event, *};
use frame_support::{assert_noop, assert_ok, traits::OnInitialize, weights::Weight};
use frame_support::{
assert_noop, assert_ok,
traits::{Currency, OnInitialize},
weights::Weight,
};
use mock::{Balance, Balances, MockSmartContract, *};
use sp_core::H160;
use sp_runtime::{
Expand Down Expand Up @@ -1911,6 +1915,19 @@ fn changing_reward_destination_for_empty_ledger_is_not_ok() {
});
}

#[test]
fn default_reward_destination_is_free_balance() {
ExternalityBuilder::build().execute_with(|| {
initialize_first_block();

let staker = 1;
assert_eq!(
DappsStaking::ledger(&staker).reward_destination,
RewardDestination::FreeBalance
);
});
}

#[test]
fn claim_dapp_with_zero_stake_periods_is_ok() {
ExternalityBuilder::build().execute_with(|| {
Expand Down
2 changes: 1 addition & 1 deletion runtime/astar/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astar-runtime"
version = "5.12.0"
version = "5.13.0"
build = "build.rs"
authors.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion runtime/astar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("astar"),
impl_name: create_runtime_str!("astar"),
authoring_version: 1,
spec_version: 62,
spec_version: 63,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down
2 changes: 1 addition & 1 deletion runtime/shibuya/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shibuya-runtime"
version = "5.12.0"
version = "5.13.0"
build = "build.rs"
authors.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion runtime/shibuya/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("shibuya"),
impl_name: create_runtime_str!("shibuya"),
authoring_version: 1,
spec_version: 102,
spec_version: 103,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down
2 changes: 1 addition & 1 deletion runtime/shiden/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shiden-runtime"
version = "5.12.0"
version = "5.13.0"
build = "build.rs"
authors.workspace = true
edition.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion runtime/shiden/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("shiden"),
impl_name: create_runtime_str!("shiden"),
authoring_version: 1,
spec_version: 102,
spec_version: 103,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down
4 changes: 4 additions & 0 deletions tests/xcm-simulator/src/tests/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ fn remote_dapps_staking_staker_claim() {
smart_contract.clone(),
stake_amount,
));
assert_ok!(parachain::DappsStaking::set_reward_destination(
parachain::RuntimeOrigin::signed(ALICE),
pallet_dapps_staking::RewardDestination::StakeBalance,
));

// advance enough blocks so we at least get to era 4
advance_parachain_block_to(20);
Expand Down