Skip to content

Commit

Permalink
Finish Delegation TIP compliance (#1306)
Browse files Browse the repository at this point in the history
* Docs clean

* Remove immutable feature flags

* Add NullDelegationValidatorId error

* impl StateTransitionVerifier for DelegationOutput

* Add some checks

* Add NonDelayedClaimingTransition

* Add todo

* Fmt

* Update sdk/src/types/block/output/delegation.rs

Co-authored-by: Thoralf-M <[email protected]>

* IOTA tokens -> coins

* validator_id -> validator_address

---------

Co-authored-by: Thoralf-M <[email protected]>
  • Loading branch information
thibault-martinez and Thoralf-M authored Sep 26, 2023
1 parent 2ec7957 commit 6961e39
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 61 deletions.
4 changes: 2 additions & 2 deletions sdk/src/types/api/core/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,10 @@ pub struct ManaRewardsResponse {
pub struct CommitteeResponse {
/// The epoch index of the committee.
pub epoch_index: EpochIndex,
/// The total amount of delegated and staked IOTA tokens in the selected committee.
/// The total amount of delegated and staked IOTA coins in the selected committee.
#[serde(with = "string")]
pub total_stake: u64,
/// The total amount of staked IOTA tokens in the selected committee.
/// The total amount of staked IOTA coins in the selected committee.
#[serde(with = "string")]
pub total_validator_stake: u64,
/// The validators of the committee.
Expand Down
2 changes: 2 additions & 0 deletions sdk/src/types/block/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ pub enum Error {
UnsupportedOutputKind(u8),
DuplicateOutputChain(ChainId),
InvalidField(&'static str),
NullDelegationValidatorId,
}

#[cfg(feature = "std")]
Expand Down Expand Up @@ -371,6 +372,7 @@ impl fmt::Display for Error {
Self::UnsupportedOutputKind(k) => write!(f, "unsupported output kind: {k}"),
Self::DuplicateOutputChain(chain_id) => write!(f, "duplicate output chain {chain_id}"),
Self::InvalidField(field) => write!(f, "invalid field: {field}"),
Self::NullDelegationValidatorId => write!(f, "null delegation validator ID"),
}
}
}
Expand Down
11 changes: 1 addition & 10 deletions sdk/src/types/block/output/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ pub(crate) type StateMetadataLength = BoundedU16<0, { AccountOutput::STATE_METAD
/// Describes an account in the ledger that can be controlled by the state and governance controllers.
#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub struct AccountOutput {
// Amount of IOTA tokens held by the output.
// Amount of IOTA coins held by the output.
amount: u64,
mana: u64,
// Native tokens held by the output.
Expand Down Expand Up @@ -780,29 +780,20 @@ pub(crate) mod dto {
pub struct AccountOutputDto {
#[serde(rename = "type")]
pub kind: u8,
// Amount of IOTA tokens held by the output.
#[serde(with = "string")]
pub amount: u64,
#[serde(with = "string")]
pub mana: u64,
// Native tokens held by the output.
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub native_tokens: Vec<NativeToken>,
// Unique identifier of the account.
pub account_id: AccountId,
// A counter that must increase by 1 every time the account is state transitioned.
pub state_index: u32,
// Metadata that can only be changed by the state controller.
#[serde(skip_serializing_if = "<[_]>::is_empty", default, with = "prefix_hex_bytes")]
pub state_metadata: Box<[u8]>,
// A counter that denotes the number of foundries created by this account.
pub foundry_counter: u32,
//
pub unlock_conditions: Vec<UnlockConditionDto>,
//
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub features: Vec<Feature>,
//
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub immutable_features: Vec<Feature>,
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/output/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl From<&BasicOutput> for BasicOutputBuilder {
#[packable(unpack_error = Error)]
#[packable(unpack_visitor = ProtocolParameters)]
pub struct BasicOutput {
/// Amount of IOTA tokens to deposit with this output.
/// Amount of IOTA coins to deposit with this output.
#[packable(verify_with = verify_output_amount_packable)]
amount: u64,
/// Amount of stored Mana held by this output.
Expand Down
Loading

0 comments on commit 6961e39

Please sign in to comment.