Skip to content

Commit

Permalink
Abstract sparse vector type
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard committed Aug 30, 2023
1 parent 91038ed commit 1473890
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 187 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

3 changes: 3 additions & 0 deletions pallets/dapp-staking-v3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

astar-primitives = { workspace = true }

[dev-dependencies]
pallet-balances = { workspace = true }

Expand All @@ -39,4 +41,5 @@ std = [
"frame-support/std",
"frame-system/std",
"pallet-balances/std",
"astar-primitives/std",
]
12 changes: 9 additions & 3 deletions pallets/dapp-staking-v3/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ use frame_support::{
use frame_system::pallet_prelude::*;
use sp_runtime::traits::{BadOrigin, Saturating, Zero};

use astar_primitives::Balance;

use crate::types::*;
pub use pallet::*;

Expand Down Expand Up @@ -74,7 +76,11 @@ pub mod pallet {
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;

/// Currency used for staking.
type Currency: LockableCurrency<Self::AccountId, Moment = Self::BlockNumber>;
type Currency: LockableCurrency<
Self::AccountId,
Moment = Self::BlockNumber,
Balance = Balance,
>;

/// Describes smart contract in the context required by dApp staking.
type SmartContract: Parameter + Member + MaxEncodedLen;
Expand All @@ -97,7 +103,7 @@ pub mod pallet {

/// Minimum amount an account has to lock in dApp staking in order to participate.
#[pallet::constant]
type MinimumLockedAmount: Get<BalanceOf<Self>>;
type MinimumLockedAmount: Get<Balance>;

/// Amount of blocks that need to pass before unlocking chunks can be claimed by the owner.
#[pallet::constant]
Expand Down Expand Up @@ -196,7 +202,7 @@ pub mod pallet {

/// General information about the current era.
#[pallet::storage]
pub type CurrentEraInfo<T: Config> = StorageValue<_, EraInfo<BalanceOf<T>>, ValueQuery>;
pub type CurrentEraInfo<T: Config> = StorageValue<_, EraInfo, ValueQuery>;

#[pallet::call]
impl<T: Config> Pallet<T> {
Expand Down
2 changes: 1 addition & 1 deletion pallets/dapp-staking-v3/src/test/testing_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use std::collections::HashMap;
pub(crate) struct MemorySnapshot {
active_protocol_state: ProtocolState<BlockNumberFor<Test>>,
next_dapp_id: DAppId,
current_era_info: EraInfo<BalanceOf<Test>>,
current_era_info: EraInfo,
integrated_dapps: HashMap<
<Test as pallet_dapp_staking::Config>::SmartContract,
DAppInfo<<Test as frame_system::Config>::AccountId>,
Expand Down
Loading

0 comments on commit 1473890

Please sign in to comment.