Skip to content

Commit

Permalink
impl permission mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptoAtwill committed Sep 26, 2024
1 parent 3d4f91e commit d881a2e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
14 changes: 14 additions & 0 deletions ipc/api/src/subnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/// However, we should either deprecate the native actors, or make
/// them use the types from this sdk directly.
use crate::subnet_id::SubnetID;
use anyhow::anyhow;
use fvm_ipld_encoding::repr::*;
use fvm_shared::{address::Address, clock::ChainEpoch, econ::TokenAmount};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -96,3 +97,16 @@ pub struct ConstructParams {
pub enum ConsensusType {
Fendermint,
}

impl TryFrom<u8> for PermissionMode {
type Error = anyhow::Error;

fn try_from(value: u8) -> Result<Self, Self::Error> {
Ok(match value {
0 => PermissionMode::Collateral,
1 => PermissionMode::Federated,
2 => PermissionMode::Static,
_ => return Err(anyhow!("unknown power permission mode")),
})
}
}
5 changes: 3 additions & 2 deletions ipc/provider/src/manager/evm/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,8 @@ impl SubnetManager for EthSubnetManager {

let genesis_balances = contract.genesis_balances().await?;
let bottom_up_checkpoint_period = contract.bottom_up_check_period().call().await?.as_u64();
let permission_mode =
PermissionMode::try_from(contract.permission_mode().call().await? as u8)?;

Ok(SubnetGenesisInfo {
// Active validators limit set for the child subnet.
Expand All @@ -809,8 +811,7 @@ impl SubnetManager for EthSubnetManager {
// Custom message fee that the child subnet wants to set for cross-net messages
validators: from_contract_validators(contract.genesis_validators().call().await?)?,
genesis_balances: into_genesis_balance_map(genesis_balances.0, genesis_balances.1)?,
// TODO: fixme https://github.com/consensus-shipyard/ipc-monorepo/issues/496
permission_mode: PermissionMode::Collateral,
permission_mode,
supply_source: Asset {
kind: AssetKind::Native,
token_address: None,
Expand Down

0 comments on commit d881a2e

Please sign in to comment.