Skip to content

Commit

Permalink
feat: add and integrate IotaSystemAdminCap rust module
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriyr committed Nov 5, 2024
1 parent f6abe20 commit cff774d
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module iota_system::genesis {

use iota::balance;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;
use iota::system_admin_cap::IotaSystemAdminCap;

use iota_system::iota_system;
use iota_system::validator;
Expand Down Expand Up @@ -67,7 +67,7 @@ module iota_system::genesis {
genesis_validators: vector<GenesisValidatorMetadata>,
_token_distribution_schedule: TokenDistributionSchedule,
_timelock_genesis_label: Option<String>,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
assert!(tx_context::epoch(ctx) == 0, 0);
Expand Down Expand Up @@ -118,7 +118,7 @@ module iota_system::genesis {
genesis_chain_parameters.protocol_version,
genesis_chain_parameters.chain_start_timestamp_ms,
genesis_chain_parameters.epoch_duration_ms,
system_timelock_cap,
iota_system_admin_cap,
ctx,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ module iota_system::iota_system {
use iota::dynamic_field;
use iota::iota::IOTA;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;
use iota::system_admin_cap::IotaSystemAdminCap;

use iota_system::validator::ValidatorV1;
use iota_system::iota_system_state_inner::{Self, IotaSystemStateV1};

const SYSTEM_TIMELOCK_CAP_DF_KEY: vector<u8> = b"sys_timelock_cap";

public struct IotaSystemState has key {
id: UID,
version: u64,
Expand All @@ -27,7 +25,7 @@ module iota_system::iota_system {
protocol_version: u64,
epoch_start_timestamp_ms: u64,
epoch_duration_ms: u64,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
let system_state = iota_system_state_inner::create(
Expand All @@ -37,6 +35,7 @@ module iota_system::iota_system {
protocol_version,
epoch_start_timestamp_ms,
epoch_duration_ms,
iota_system_admin_cap,
ctx,
);
let version = iota_system_state_inner::genesis_system_state_version();
Expand All @@ -45,7 +44,6 @@ module iota_system::iota_system {
version,
};
dynamic_field::add(&mut self.id, version, system_state);
dynamic_field::add(&mut self.id, SYSTEM_TIMELOCK_CAP_DF_KEY, system_timelock_cap);
transfer::share_object(self);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module iota_system::iota_system_state_inner {
use iota::event;
use iota::iota::IOTA;
use iota::iota::IotaTreasuryCap;
use iota::system_admin_cap::IotaSystemAdminCap;
use iota::table::{Self, Table};

use iota_system::validator::ValidatorV1;
Expand Down Expand Up @@ -50,6 +51,7 @@ module iota_system::iota_system_state_inner {
validators: ValidatorSetV1,
storage_fund: Balance<IOTA>,
parameters: SystemParametersV1,
iota_system_admin_cap: IotaSystemAdminCap,
reference_gas_price: u64,
safe_mode: bool,
epoch_start_timestamp_ms: u64,
Expand All @@ -63,6 +65,7 @@ module iota_system::iota_system_state_inner {
protocol_version: u64,
epoch_start_timestamp_ms: u64,
epoch_duration_ms: u64,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
): IotaSystemStateV1 {
let validators = new_validator_set(validators, ctx);
Expand All @@ -77,6 +80,7 @@ module iota_system::iota_system_state_inner {
epoch_duration_ms,
extra_fields: bag::new(ctx),
},
iota_system_admin_cap,
reference_gas_price: 1,
safe_mode: false,
epoch_start_timestamp_ms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module iota_system::genesis {

use iota::balance;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;
use iota::system_admin_cap::IotaSystemAdminCap;

use iota_system::iota_system;
use iota_system::validator;
Expand Down Expand Up @@ -67,7 +67,7 @@ module iota_system::genesis {
genesis_validators: vector<GenesisValidatorMetadata>,
_token_distribution_schedule: TokenDistributionSchedule,
_timelock_genesis_label: Option<String>,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
assert!(tx_context::epoch(ctx) == 0, 0);
Expand Down Expand Up @@ -118,7 +118,7 @@ module iota_system::genesis {
genesis_chain_parameters.protocol_version,
genesis_chain_parameters.chain_start_timestamp_ms,
genesis_chain_parameters.epoch_duration_ms,
system_timelock_cap,
iota_system_admin_cap,
ctx,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ module iota_system::iota_system {
use iota::dynamic_field;
use iota::iota::IOTA;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;
use iota::system_admin_cap::IotaSystemAdminCap;

use iota_system::validator::ValidatorV1;
use iota_system::iota_system_state_inner::{Self, IotaSystemStateV1, IotaSystemStateV2};

const SYSTEM_TIMELOCK_CAP_DF_KEY: vector<u8> = b"sys_timelock_cap";

public struct IotaSystemState has key {
id: UID,
version: u64,
Expand All @@ -27,7 +25,7 @@ module iota_system::iota_system {
protocol_version: u64,
epoch_start_timestamp_ms: u64,
epoch_duration_ms: u64,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
let system_state = iota_system_state_inner::create(
Expand All @@ -37,6 +35,7 @@ module iota_system::iota_system {
protocol_version,
epoch_start_timestamp_ms,
epoch_duration_ms,
iota_system_admin_cap,
ctx,
);
let version = iota_system_state_inner::genesis_system_state_version();
Expand All @@ -45,7 +44,6 @@ module iota_system::iota_system {
version,
};
dynamic_field::add(&mut self.id, version, system_state);
dynamic_field::add(&mut self.id, SYSTEM_TIMELOCK_CAP_DF_KEY, system_timelock_cap);
transfer::share_object(self);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module iota_system::iota_system_state_inner {
use iota::event;
use iota::iota::IOTA;
use iota::iota::IotaTreasuryCap;
use iota::system_admin_cap::IotaSystemAdminCap;
use iota::table::{Self, Table};

use iota_system::validator::{ValidatorV1, ValidatorV2};
Expand Down Expand Up @@ -58,6 +59,7 @@ module iota_system::iota_system_state_inner {
validators: ValidatorSetV1,
storage_fund: Balance<IOTA>,
parameters: SystemParametersV1,
iota_system_admin_cap: IotaSystemAdminCap,
reference_gas_price: u64,
safe_mode: bool,
epoch_start_timestamp_ms: u64,
Expand All @@ -73,6 +75,7 @@ module iota_system::iota_system_state_inner {
validators: ValidatorSetV2,
storage_fund: Balance<IOTA>,
parameters: SystemParametersV1,
iota_system_admin_cap: IotaSystemAdminCap,
reference_gas_price: u64,
safe_mode: bool,
epoch_start_timestamp_ms: u64,
Expand All @@ -86,6 +89,7 @@ module iota_system::iota_system_state_inner {
protocol_version: u64,
epoch_start_timestamp_ms: u64,
epoch_duration_ms: u64,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
): IotaSystemStateV1 {
let validators = new_validator_set(validators, ctx);
Expand All @@ -100,6 +104,7 @@ module iota_system::iota_system_state_inner {
epoch_duration_ms,
extra_fields: bag::new(ctx),
},
iota_system_admin_cap,
reference_gas_price: 1,
safe_mode: false,
epoch_start_timestamp_ms,
Expand Down Expand Up @@ -178,6 +183,7 @@ module iota_system::iota_system_state_inner {
validators,
storage_fund,
parameters,
iota_system_admin_cap,
reference_gas_price,
safe_mode,
epoch_start_timestamp_ms,
Expand All @@ -194,6 +200,7 @@ module iota_system::iota_system_state_inner {
validators: new_validator_set,
storage_fund,
parameters,
iota_system_admin_cap,
reference_gas_price,
safe_mode,
epoch_start_timestamp_ms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module iota_system::genesis {

use iota::balance;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;
use iota::system_admin_cap::IotaSystemAdminCap;

use iota_system::iota_system;
use iota_system::validator;
Expand Down Expand Up @@ -67,7 +67,7 @@ module iota_system::genesis {
genesis_validators: vector<GenesisValidatorMetadata>,
_token_distribution_schedule: TokenDistributionSchedule,
_timelock_genesis_label: Option<String>,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
assert!(tx_context::epoch(ctx) == 0, 0);
Expand Down Expand Up @@ -118,7 +118,7 @@ module iota_system::genesis {
genesis_chain_parameters.protocol_version,
genesis_chain_parameters.chain_start_timestamp_ms,
genesis_chain_parameters.epoch_duration_ms,
system_timelock_cap,
iota_system_admin_cap,
ctx,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ module iota_system::iota_system {
use iota::dynamic_field;
use iota::iota::IOTA;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;
use iota::system_admin_cap::IotaSystemAdminCap;

use iota_system::validator::ValidatorV1;
use iota_system::iota_system_state_inner::{Self, IotaSystemStateV1};

const SYSTEM_TIMELOCK_CAP_DF_KEY: vector<u8> = b"sys_timelock_cap";

public struct IotaSystemState has key {
id: UID,
version: u64,
Expand All @@ -27,7 +25,7 @@ module iota_system::iota_system {
protocol_version: u64,
epoch_start_timestamp_ms: u64,
epoch_duration_ms: u64,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
let system_state = iota_system_state_inner::create(
Expand All @@ -37,6 +35,7 @@ module iota_system::iota_system {
protocol_version,
epoch_start_timestamp_ms,
epoch_duration_ms,
iota_system_admin_cap,
ctx,
);
let version = iota_system_state_inner::genesis_system_state_version();
Expand All @@ -45,7 +44,6 @@ module iota_system::iota_system {
version,
};
dynamic_field::add(&mut self.id, version, system_state);
dynamic_field::add(&mut self.id, SYSTEM_TIMELOCK_CAP_DF_KEY, system_timelock_cap);
transfer::share_object(self);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module iota_system::iota_system_state_inner {
use iota::event;
use iota::iota::IOTA;
use iota::iota::IotaTreasuryCap;
use iota::system_admin_cap::IotaSystemAdminCap;
use iota::table::{Self, Table};

use iota_system::validator::ValidatorV1;
Expand Down Expand Up @@ -47,6 +48,7 @@ module iota_system::iota_system_state_inner {
iota_treasury_cap: IotaTreasuryCap,
validators: ValidatorSetV1,
storage_fund: Balance<IOTA>,
iota_system_admin_cap: IotaSystemAdminCap,
parameters: SystemParametersV1,
reference_gas_price: u64,
safe_mode: bool,
Expand All @@ -61,6 +63,7 @@ module iota_system::iota_system_state_inner {
protocol_version: u64,
epoch_start_timestamp_ms: u64,
epoch_duration_ms: u64,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
): IotaSystemStateV1 {
let system_state = IotaSystemStateV1 {
Expand All @@ -78,6 +81,7 @@ module iota_system::iota_system_state_inner {
epoch_duration_ms,
extra_fields: bag::new(ctx),
},
iota_system_admin_cap,
reference_gas_price: 1,
safe_mode: false,
epoch_start_timestamp_ms,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module iota_system::genesis {

use iota::balance;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;
use iota::system_admin_cap::IotaSystemAdminCap;

use iota_system::iota_system;
use iota_system::validator;
Expand Down Expand Up @@ -67,7 +67,7 @@ module iota_system::genesis {
genesis_validators: vector<GenesisValidatorMetadata>,
_token_distribution_schedule: TokenDistributionSchedule,
_timelock_genesis_label: Option<String>,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
assert!(tx_context::epoch(ctx) == 0, 0);
Expand Down Expand Up @@ -118,7 +118,7 @@ module iota_system::genesis {
genesis_chain_parameters.protocol_version,
genesis_chain_parameters.chain_start_timestamp_ms,
genesis_chain_parameters.epoch_duration_ms,
system_timelock_cap,
iota_system_admin_cap,
ctx,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ module iota_system::iota_system {
use iota::dynamic_field;
use iota::iota::IOTA;
use iota::iota::IotaTreasuryCap;
use iota::timelock::SystemTimelockCap;
use iota::system_admin_cap::IotaSystemAdminCap;

use iota_system::validator::ValidatorV1;
use iota_system::iota_system_state_inner::{Self, IotaSystemStateV1, IotaSystemStateV2};

const SYSTEM_TIMELOCK_CAP_DF_KEY: vector<u8> = b"sys_timelock_cap";

public struct IotaSystemState has key {
id: UID,
version: u64,
Expand All @@ -27,7 +25,7 @@ module iota_system::iota_system {
protocol_version: u64,
epoch_start_timestamp_ms: u64,
epoch_duration_ms: u64,
system_timelock_cap: SystemTimelockCap,
iota_system_admin_cap: IotaSystemAdminCap,
ctx: &mut TxContext,
) {
let system_state = iota_system_state_inner::create(
Expand All @@ -37,6 +35,7 @@ module iota_system::iota_system {
protocol_version,
epoch_start_timestamp_ms,
epoch_duration_ms,
iota_system_admin_cap,
ctx,
);
let version = iota_system_state_inner::genesis_system_state_version();
Expand All @@ -45,7 +44,6 @@ module iota_system::iota_system {
version,
};
dynamic_field::add(&mut self.id, version, system_state);
dynamic_field::add(&mut self.id, SYSTEM_TIMELOCK_CAP_DF_KEY, system_timelock_cap);
transfer::share_object(self);
}

Expand Down
Loading

0 comments on commit cff774d

Please sign in to comment.