mirror of
https://github.com/vacp2p/status-rln-prover.git
synced 2026-01-08 21:18:05 -05:00
Update for new KarmaTiers smart contract (#23)
* Update for new KarmaTiers smart contract * Add Anvil unit test for KarmaTiers SC * Add unit test for KarmaSC * Add rln sc unit test
This commit is contained in:
@@ -7,5 +7,10 @@ edition = "2024"
|
||||
alloy.workspace = true
|
||||
url.workspace = true
|
||||
async-trait.workspace = true
|
||||
derive_more.workspace = true
|
||||
log = "0.4.27"
|
||||
thiserror.workspace = true
|
||||
log = "0.4.27"
|
||||
|
||||
[dev-dependencies]
|
||||
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }
|
||||
claims = "0.8"
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@ mod rln_sc;
|
||||
|
||||
pub use common::AlloyWsProvider;
|
||||
pub use karma_sc::{KarmaAmountExt, KarmaSC};
|
||||
pub use karma_tiers::{KarmaTiersSC, Tier, TierIndex};
|
||||
pub use karma_tiers::{GetScTiersError, KarmaTiers, Tier};
|
||||
pub use rln_sc::{KarmaRLNSC, RLNRegister};
|
||||
|
||||
pub use mock::{MockKarmaRLNSc, MockKarmaSc, TIER_LIMITS};
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use crate::karma_tiers::{Tier, TierIndex};
|
||||
use crate::karma_tiers::Tier;
|
||||
use crate::{KarmaAmountExt, RLNRegister};
|
||||
use alloy::primitives::{Address, U256};
|
||||
use async_trait::async_trait;
|
||||
use log::debug;
|
||||
use std::collections::BTreeMap;
|
||||
use std::sync::LazyLock;
|
||||
|
||||
pub struct MockKarmaSc {}
|
||||
@@ -23,66 +22,50 @@ pub struct MockKarmaRLNSc {}
|
||||
impl RLNRegister for MockKarmaRLNSc {
|
||||
type Error = alloy::contract::Error;
|
||||
|
||||
async fn register(&self, identity_commitment: U256) -> Result<(), Self::Error> {
|
||||
async fn register_user(
|
||||
&self,
|
||||
address: &Address,
|
||||
identity_commitment: U256,
|
||||
) -> Result<(), Self::Error> {
|
||||
debug!(
|
||||
"Register user with identity_commitment: {:?}",
|
||||
identity_commitment
|
||||
"Register user ({}) with identity_commitment: {:?}",
|
||||
address, identity_commitment
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub static TIER_LIMITS: LazyLock<BTreeMap<TierIndex, Tier>> = LazyLock::new(|| {
|
||||
BTreeMap::from([
|
||||
(
|
||||
TierIndex::from(0),
|
||||
Tier {
|
||||
min_karma: U256::from(10),
|
||||
max_karma: U256::from(49),
|
||||
name: "Basic".to_string(),
|
||||
tx_per_epoch: 6,
|
||||
active: true,
|
||||
},
|
||||
),
|
||||
(
|
||||
TierIndex::from(1),
|
||||
Tier {
|
||||
min_karma: U256::from(50),
|
||||
max_karma: U256::from(99),
|
||||
name: "Active".to_string(),
|
||||
tx_per_epoch: 120,
|
||||
active: true,
|
||||
},
|
||||
),
|
||||
(
|
||||
TierIndex::from(2),
|
||||
Tier {
|
||||
min_karma: U256::from(100),
|
||||
max_karma: U256::from(499),
|
||||
name: "Regular".to_string(),
|
||||
tx_per_epoch: 720,
|
||||
active: true,
|
||||
},
|
||||
),
|
||||
(
|
||||
TierIndex::from(3),
|
||||
Tier {
|
||||
min_karma: U256::from(500),
|
||||
max_karma: U256::from(999),
|
||||
name: "Power User".to_string(),
|
||||
tx_per_epoch: 86400,
|
||||
active: true,
|
||||
},
|
||||
),
|
||||
(
|
||||
TierIndex::from(4),
|
||||
Tier {
|
||||
min_karma: U256::from(1000),
|
||||
max_karma: U256::from(4999),
|
||||
name: "S-Tier".to_string(),
|
||||
tx_per_epoch: 432000,
|
||||
active: true,
|
||||
},
|
||||
),
|
||||
])
|
||||
pub static TIER_LIMITS: LazyLock<Vec<Tier>> = LazyLock::new(|| {
|
||||
vec![
|
||||
Tier {
|
||||
min_karma: U256::from(10),
|
||||
max_karma: U256::from(49),
|
||||
name: "Basic".to_string(),
|
||||
tx_per_epoch: 6,
|
||||
},
|
||||
Tier {
|
||||
min_karma: U256::from(50),
|
||||
max_karma: U256::from(99),
|
||||
name: "Active".to_string(),
|
||||
tx_per_epoch: 120,
|
||||
},
|
||||
Tier {
|
||||
min_karma: U256::from(100),
|
||||
max_karma: U256::from(499),
|
||||
name: "Regular".to_string(),
|
||||
tx_per_epoch: 720,
|
||||
},
|
||||
Tier {
|
||||
min_karma: U256::from(500),
|
||||
max_karma: U256::from(999),
|
||||
name: "Power User".to_string(),
|
||||
tx_per_epoch: 86400,
|
||||
},
|
||||
Tier {
|
||||
min_karma: U256::from(1000),
|
||||
max_karma: U256::from(4999),
|
||||
name: "S-Tier".to_string(),
|
||||
tx_per_epoch: 432000,
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user