Unverified Commit 72bb3dfc authored by thiolliere's avatar thiolliere Committed by GitHub
Browse files

Companion: remove IsCallable make use of introduced in-origin filtering (#1226)

* remove IsCallable make use of in-origin filter

* update lock

* bump version for runtimes as spec as changed

* trigger CI

* Revert "trigger CI"

This reverts commit 5ac58fd4.
parent 8495eb37
Pipeline #96909 canceled with stages
in 5 minutes and 41 seconds
This diff is collapsed.
...@@ -666,6 +666,7 @@ mod tests { ...@@ -666,6 +666,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
} }
impl system::Trait for Test { impl system::Trait for Test {
type BaseCallFilter = ();
type Origin = Origin; type Origin = Origin;
type Call = Call; type Call = Call;
type Index = u64; type Index = u64;
...@@ -794,7 +795,7 @@ mod tests { ...@@ -794,7 +795,7 @@ mod tests {
fn claiming_works() { fn claiming_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..]))); assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&42), 100); assert_eq!(Balances::free_balance(&42), 100);
assert_eq!(Vesting::vesting_balance(&42), Some(50)); assert_eq!(Vesting::vesting_balance(&42), Some(50));
assert_eq!(Claims::total(), total_claims() - 100); assert_eq!(Claims::total(), total_claims() - 100);
...@@ -807,8 +808,8 @@ mod tests { ...@@ -807,8 +808,8 @@ mod tests {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!(Claims::move_claim(Origin::signed(1), eth(&alice()), eth(&bob()), None), BadOrigin); assert_noop!(Claims::move_claim(Origin::signed(1), eth(&alice()), eth(&bob()), None), BadOrigin);
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&alice()), eth(&bob()), None)); assert_ok!(Claims::move_claim(Origin::signed(6), eth(&alice()), eth(&bob()), None));
assert_noop!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])), Error::<Test>::SignerHasNoClaim); assert_noop!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])), Error::<Test>::SignerHasNoClaim);
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&bob(), &42u64.encode(), &[][..]))); assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&bob(), &42u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&42), 100); assert_eq!(Balances::free_balance(&42), 100);
assert_eq!(Vesting::vesting_balance(&42), Some(50)); assert_eq!(Vesting::vesting_balance(&42), Some(50));
assert_eq!(Claims::total(), total_claims() - 100); assert_eq!(Claims::total(), total_claims() - 100);
...@@ -820,7 +821,7 @@ mod tests { ...@@ -820,7 +821,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_ok!(Claims::move_claim(Origin::signed(6), eth(&dave()), eth(&bob()), None)); assert_ok!(Claims::move_claim(Origin::signed(6), eth(&dave()), eth(&bob()), None));
let s = sig::<Test>(&bob(), &42u64.encode(), StatementKind::Regular.to_text()); let s = sig::<Test>(&bob(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec())); assert_ok!(Claims::claim_attest(Origin::none(), 42, s, StatementKind::Regular.to_text().to_vec()));
assert_eq!(Balances::free_balance(&42), 200); assert_eq!(Balances::free_balance(&42), 200);
}); });
} }
...@@ -837,16 +838,16 @@ mod tests { ...@@ -837,16 +838,16 @@ mod tests {
#[test] #[test]
fn claiming_does_not_bypass_signing() { fn claiming_does_not_bypass_signing() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..]))); assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_noop!( assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&dave(), &42u64.encode(), &[][..])), Claims::claim(Origin::none(), 42, sig::<Test>(&dave(), &42u64.encode(), &[][..])),
Error::<Test>::InvalidStatement, Error::<Test>::InvalidStatement,
); );
assert_noop!( assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&eve(), &42u64.encode(), &[][..])), Claims::claim(Origin::none(), 42, sig::<Test>(&eve(), &42u64.encode(), &[][..])),
Error::<Test>::InvalidStatement, Error::<Test>::InvalidStatement,
); );
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&frank(), &42u64.encode(), &[][..]))); assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&frank(), &42u64.encode(), &[][..])));
}); });
} }
...@@ -855,21 +856,21 @@ mod tests { ...@@ -855,21 +856,21 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Saft.to_text()); let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Saft.to_text());
let r = Claims::claim_attest(Origin::NONE, 42, s.clone(), StatementKind::Saft.to_text().to_vec()); let r = Claims::claim_attest(Origin::none(), 42, s.clone(), StatementKind::Saft.to_text().to_vec());
assert_noop!(r, Error::<Test>::InvalidStatement); assert_noop!(r, Error::<Test>::InvalidStatement);
let r = Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec()); let r = Claims::claim_attest(Origin::none(), 42, s, StatementKind::Regular.to_text().to_vec());
assert_noop!(r, Error::<Test>::SignerHasNoClaim); assert_noop!(r, Error::<Test>::SignerHasNoClaim);
// ^^^ we use ecdsa_recover, so an invalid signature just results in a random signer id // ^^^ we use ecdsa_recover, so an invalid signature just results in a random signer id
// being recovered, which realistically will never have a claim. // being recovered, which realistically will never have a claim.
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text()); let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec())); assert_ok!(Claims::claim_attest(Origin::none(), 42, s, StatementKind::Regular.to_text().to_vec()));
assert_eq!(Balances::free_balance(&42), 200); assert_eq!(Balances::free_balance(&42), 200);
assert_eq!(Claims::total(), total_claims() - 200); assert_eq!(Claims::total(), total_claims() - 200);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text()); let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
let r = Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec()); let r = Claims::claim_attest(Origin::none(), 42, s, StatementKind::Regular.to_text().to_vec());
assert_noop!(r, Error::<Test>::SignerHasNoClaim); assert_noop!(r, Error::<Test>::SignerHasNoClaim);
}); });
} }
...@@ -891,7 +892,7 @@ mod tests { ...@@ -891,7 +892,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
// Alice's claim is 100 // Alice's claim is 100
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..]))); assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&42), 100); assert_eq!(Balances::free_balance(&42), 100);
// Eve's claim is 300 through Account 42 // Eve's claim is 300 through Account 42
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec())); assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec()));
...@@ -932,7 +933,7 @@ mod tests { ...@@ -932,7 +933,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), &[]); let s = sig::<Test>(&dave(), &42u64.encode(), &[]);
let r = Claims::claim(Origin::NONE, 42, s.clone()); let r = Claims::claim(Origin::none(), 42, s.clone());
assert_noop!(r, Error::<Test>::InvalidStatement); assert_noop!(r, Error::<Test>::InvalidStatement);
}); });
} }
...@@ -946,12 +947,12 @@ mod tests { ...@@ -946,12 +947,12 @@ mod tests {
); );
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])), Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim, Error::<Test>::SignerHasNoClaim,
); );
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None, None)); assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, None, None));
assert_eq!(Claims::total(), total_claims() + 200); assert_eq!(Claims::total(), total_claims() + 200);
assert_ok!(Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..]))); assert_ok!(Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&69), 200); assert_eq!(Balances::free_balance(&69), 200);
assert_eq!(Vesting::vesting_balance(&69), None); assert_eq!(Vesting::vesting_balance(&69), None);
assert_eq!(Claims::total(), total_claims()); assert_eq!(Claims::total(), total_claims());
...@@ -967,11 +968,11 @@ mod tests { ...@@ -967,11 +968,11 @@ mod tests {
); );
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])), Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim, Error::<Test>::SignerHasNoClaim,
); );
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, Some((50, 10, 1)), None)); assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, Some((50, 10, 1)), None));
assert_ok!(Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..]))); assert_ok!(Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&69), 200); assert_eq!(Balances::free_balance(&69), 200);
assert_eq!(Vesting::vesting_balance(&69), Some(50)); assert_eq!(Vesting::vesting_balance(&69), Some(50));
...@@ -994,20 +995,20 @@ mod tests { ...@@ -994,20 +995,20 @@ mod tests {
let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Regular.to_text()); let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Regular.to_text());
assert_noop!( assert_noop!(
Claims::claim_attest( Claims::claim_attest(
Origin::NONE, 69, signature.clone(), StatementKind::Regular.to_text().to_vec() Origin::none(), 69, signature.clone(), StatementKind::Regular.to_text().to_vec()
), ),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None, Some(StatementKind::Regular))); assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, None, Some(StatementKind::Regular)));
assert_noop!( assert_noop!(
Claims::claim_attest( Claims::claim_attest(
Origin::NONE, 69, signature.clone(), vec![], Origin::none(), 69, signature.clone(), vec![],
), ),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
assert_ok!( assert_ok!(
Claims::claim_attest( Claims::claim_attest(
Origin::NONE, 69, signature.clone(), StatementKind::Regular.to_text().to_vec() Origin::none(), 69, signature.clone(), StatementKind::Regular.to_text().to_vec()
) )
); );
assert_eq!(Balances::free_balance(&69), 200); assert_eq!(Balances::free_balance(&69), 200);
...@@ -1029,9 +1030,9 @@ mod tests { ...@@ -1029,9 +1030,9 @@ mod tests {
fn double_claiming_doesnt_work() { fn double_claiming_doesnt_work() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..]))); assert_ok!(Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_noop!( assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])), Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
}); });
...@@ -1044,13 +1045,13 @@ mod tests { ...@@ -1044,13 +1045,13 @@ mod tests {
assert_ok!(<Test as Trait>::VestingSchedule::add_vesting_schedule(&69, total_claims(), 100, 10)); assert_ok!(<Test as Trait>::VestingSchedule::add_vesting_schedule(&69, total_claims(), 100, 10));
CurrencyOf::<Test>::make_free_balance_be(&69, total_claims()); CurrencyOf::<Test>::make_free_balance_be(&69, total_claims());
assert_eq!(Balances::free_balance(69), total_claims()); assert_eq!(Balances::free_balance(69), total_claims());
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, Some((50, 10, 1)), None)); assert_ok!(Claims::mint_claim(Origin::root(), eth(&bob()), 200, Some((50, 10, 1)), None));
// New total // New total
assert_eq!(Claims::total(), total_claims() + 200); assert_eq!(Claims::total(), total_claims() + 200);
// They should not be able to claim // They should not be able to claim
assert_noop!( assert_noop!(
Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])), Claims::claim(Origin::none(), 69, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Error::<Test>::VestedBalanceExists, Error::<Test>::VestedBalanceExists,
); );
}); });
...@@ -1061,7 +1062,7 @@ mod tests { ...@@ -1061,7 +1062,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &69u64.encode(), &[][..])), Claims::claim(Origin::none(), 42, sig::<Test>(&alice(), &69u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
}); });
...@@ -1072,7 +1073,7 @@ mod tests { ...@@ -1072,7 +1073,7 @@ mod tests {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
assert_noop!( assert_noop!(
Claims::claim(Origin::NONE, 42, sig::<Test>(&bob(), &69u64.encode(), &[][..])), Claims::claim(Origin::none(), 42, sig::<Test>(&bob(), &69u64.encode(), &[][..])),
Error::<Test>::SignerHasNoClaim Error::<Test>::SignerHasNoClaim
); );
}); });
......
...@@ -593,6 +593,7 @@ mod tests { ...@@ -593,6 +593,7 @@ mod tests {
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
} }
impl system::Trait for Test { impl system::Trait for Test {
type BaseCallFilter = ();
type Origin = Origin; type Origin = Origin;
type Call = (); type Call = ();
type Index = u64; type Index = u64;
...@@ -985,7 +986,7 @@ mod tests { ...@@ -985,7 +986,7 @@ mod tests {
fn onboard_works() { fn onboard_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Set up a crowdfund // Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9)); assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
assert_eq!(Balances::free_balance(1), 999); assert_eq!(Balances::free_balance(1), 999);
...@@ -1021,7 +1022,7 @@ mod tests { ...@@ -1021,7 +1022,7 @@ mod tests {
fn onboard_handles_basic_errors() { fn onboard_handles_basic_errors() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Set up a crowdfund // Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9)); assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
assert_eq!(Balances::free_balance(1), 999); assert_eq!(Balances::free_balance(1), 999);
...@@ -1059,7 +1060,7 @@ mod tests { ...@@ -1059,7 +1060,7 @@ mod tests {
fn begin_retirement_works() { fn begin_retirement_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Set up a crowdfund // Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9)); assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
assert_eq!(Balances::free_balance(1), 999); assert_eq!(Balances::free_balance(1), 999);
...@@ -1102,7 +1103,7 @@ mod tests { ...@@ -1102,7 +1103,7 @@ mod tests {
fn begin_retirement_handles_basic_errors() { fn begin_retirement_handles_basic_errors() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Set up a crowdfund // Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9)); assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
assert_eq!(Balances::free_balance(1), 999); assert_eq!(Balances::free_balance(1), 999);
...@@ -1147,7 +1148,7 @@ mod tests { ...@@ -1147,7 +1148,7 @@ mod tests {
fn withdraw_works() { fn withdraw_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Set up a crowdfund // Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9)); assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
// Transfer fee is taken here // Transfer fee is taken here
assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 100)); assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 100));
...@@ -1173,7 +1174,7 @@ mod tests { ...@@ -1173,7 +1174,7 @@ mod tests {
fn withdraw_handles_basic_errors() { fn withdraw_handles_basic_errors() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Set up a crowdfund // Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9)); assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
// Transfer fee is taken here // Transfer fee is taken here
assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 49)); assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 49));
...@@ -1197,7 +1198,7 @@ mod tests { ...@@ -1197,7 +1198,7 @@ mod tests {
fn dissolve_works() { fn dissolve_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Set up a crowdfund // Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9)); assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
// Transfer fee is taken here // Transfer fee is taken here
assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 100)); assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 100));
...@@ -1234,7 +1235,7 @@ mod tests { ...@@ -1234,7 +1235,7 @@ mod tests {
fn dissolve_handles_basic_errors() { fn dissolve_handles_basic_errors() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Set up a crowdfund // Set up a crowdfund
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9)); assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 9));
// Transfer fee is taken here // Transfer fee is taken here
assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 100)); assert_ok!(Crowdfund::contribute(Origin::signed(1), 0, 100));
...@@ -1276,7 +1277,7 @@ mod tests { ...@@ -1276,7 +1277,7 @@ mod tests {
// Some blocks later... // Some blocks later...
run_to_block(2); run_to_block(2);
// Create an auction // Create an auction
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
// Add deploy data // Add deploy data
assert_ok!(Crowdfund::fix_deploy_data( assert_ok!(Crowdfund::fix_deploy_data(
Origin::signed(1), Origin::signed(1),
...@@ -1306,7 +1307,7 @@ mod tests { ...@@ -1306,7 +1307,7 @@ mod tests {
fn fund_across_multiple_auctions_works() { fn fund_across_multiple_auctions_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
// Create an auction // Create an auction
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
// Create two competing crowdfunds, with end dates across multiple auctions // Create two competing crowdfunds, with end dates across multiple auctions
// Each crowdfund is competing for the same slots, so only one can win // Each crowdfund is competing for the same slots, so only one can win
assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 30)); assert_ok!(Crowdfund::create(Origin::signed(1), 1000, 1, 4, 30));
...@@ -1344,7 +1345,7 @@ mod tests { ...@@ -1344,7 +1345,7 @@ mod tests {
assert_eq!(Slots::managed_ids(), vec![0.into()]); assert_eq!(Slots::managed_ids(), vec![0.into()]);
// Create a second auction // Create a second auction
assert_ok!(Slots::new_auction(Origin::ROOT, 5, 1)); assert_ok!(Slots::new_auction(Origin::root(), 5, 1));
// Contribute to existing funds add to NewRaise // Contribute to existing funds add to NewRaise
assert_ok!(Crowdfund::contribute(Origin::signed(1), 1, 10)); assert_ok!(Crowdfund::contribute(Origin::signed(1), 1, 10));
......
...@@ -27,15 +27,10 @@ pub mod slots; ...@@ -27,15 +27,10 @@ pub mod slots;
pub mod crowdfund; pub mod crowdfund;
pub mod impls; pub mod impls;
use sp_std::marker::PhantomData; use primitives::BlockNumber;
use codec::{Encode, Decode}; use sp_runtime::{Perbill, traits::Saturating};
use primitives::{BlockNumber, AccountId, ValidityError};
use sp_runtime::{
Perbill, traits::{Saturating, SignedExtension, DispatchInfoOf},
transaction_validity::{TransactionValidityError, TransactionValidity, InvalidTransaction}
};
use frame_support::{ use frame_support::{
parameter_types, traits::{Currency, Filter}, parameter_types, traits::{Currency},
weights::{Weight, constants::WEIGHT_PER_SECOND}, weights::{Weight, constants::WEIGHT_PER_SECOND},
}; };
use static_assertions::const_assert; use static_assertions::const_assert;
...@@ -52,7 +47,6 @@ pub use parachains::Call as ParachainsCall; ...@@ -52,7 +47,6 @@ pub use parachains::Call as ParachainsCall;
/// Implementations of some helper traits passed into runtime modules as associated types. /// Implementations of some helper traits passed into runtime modules as associated types.
pub use impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor}; pub use impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor};
use sp_runtime::traits::Dispatchable;
pub type NegativeImbalance<T> = <balances::Module<T> as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance; pub type NegativeImbalance<T> = <balances::Module<T> as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
...@@ -67,66 +61,3 @@ parameter_types! { ...@@ -67,66 +61,3 @@ parameter_types! {
} }
const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct()); const_assert!(AvailableBlockRatio::get().deconstruct() >= AVERAGE_ON_INITIALIZE_WEIGHT.deconstruct());
/// Apply a given filter to transactions.
pub struct TransactionCallFilter<T: Filter<Call>, Call>(PhantomData<(T, Call)>);
impl<F: Filter<Call>, Call> Default for TransactionCallFilter<F, Call> {
fn default() -> Self { Self::new() }
}
impl<F: Filter<Call>, Call> Encode for TransactionCallFilter<F, Call> {
fn using_encoded<R, FO: FnOnce(&[u8]) -> R>(&self, f: FO) -> R { f(&b""[..]) }
}
impl<F: Filter<Call>, Call> Decode for TransactionCallFilter<F, Call> {
fn decode<I: codec::Input>(_: &mut I) -> Result<Self, codec::Error> { Ok(Self::new()) }
}
impl<F: Filter<Call>, Call> Clone for TransactionCallFilter<F, Call> {
fn clone(&self) -> Self { Self::new() }
}
impl<F: Filter<Call>, Call> Eq for TransactionCallFilter<F, Call> {}
impl<F: Filter<Call>, Call> PartialEq for TransactionCallFilter<F, Call> {
fn eq(&self, _: &Self) -> bool { true }
}
impl<F: Filter<Call>, Call> sp_std::fmt::Debug for TransactionCallFilter<F, Call> {
fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) }
}
fn validate<F: Filter<Call>, Call>(call: &Call) -> TransactionValidity {
if F::filter(call) {
Ok(Default::default())
} else {
Err(InvalidTransaction::Custom(ValidityError::NoPermission.into()).into())
}
}
impl<F: Filter<Call> + Send + Sync, Call: Dispatchable + Send + Sync>
SignedExtension for TransactionCallFilter<F, Call>
{
const IDENTIFIER: &'static str = "TransactionCallFilter";
type AccountId = AccountId;
type Call = Call;
type AdditionalSigned = ();
type Pre = ();
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) }
fn validate(&self,
_: &Self::AccountId,
call: &Call,
_: &DispatchInfoOf<Self::Call>,
_: usize,
) -> TransactionValidity { validate::<F, _>(call) }
fn validate_unsigned(
call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> TransactionValidity { validate::<F, _>(call) }
}
impl<F: Filter<Call>, Call> TransactionCallFilter<F, Call> {
/// Create a new instance.
pub fn new() -> Self {
Self(sp_std::marker::PhantomData)
}
}
...@@ -1609,6 +1609,7 @@ mod tests { ...@@ -1609,6 +1609,7 @@ mod tests {
} }