Skip to content

Commit

Permalink
Merge branch '2.0' into feat/address-types
Browse files Browse the repository at this point in the history
  • Loading branch information
DaughterOfMars authored Oct 6, 2023
2 parents 7716258 + 39e6e24 commit f5532eb
Show file tree
Hide file tree
Showing 16 changed files with 293 additions and 285 deletions.
2 changes: 1 addition & 1 deletion sdk/src/types/block/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub enum Error {
// https://github.com/iotaledger/iota-sdk/issues/647
// InvalidParentCount(<BoundedU8 as TryFrom<usize>>::Error),
InvalidParentCount,
InvalidPayloadKind(u32),
InvalidPayloadKind(u8),
InvalidPayloadLength {
expected: usize,
actual: usize,
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/output/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ pub struct AccountOutput {

impl AccountOutput {
/// The [`Output`](crate::types::block::output::Output) kind of an [`AccountOutput`].
pub const KIND: u8 = 4;
pub const KIND: u8 = 1;
/// Maximum possible length in bytes of the state metadata.
pub const STATE_METADATA_LENGTH_MAX: u16 = 8192;
/// The set of allowed [`UnlockCondition`]s for an [`AccountOutput`].
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 @@ -232,7 +232,7 @@ pub struct BasicOutput {

impl BasicOutput {
/// The [`Output`](crate::types::block::output::Output) kind of an [`BasicOutput`].
pub const KIND: u8 = 3;
pub const KIND: u8 = 0;

/// The set of allowed [`UnlockCondition`]s for an [`BasicOutput`].
const ALLOWED_UNLOCK_CONDITIONS: UnlockConditionFlags = UnlockConditionFlags::ADDRESS
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/output/delegation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub struct DelegationOutput {

impl DelegationOutput {
/// The [`Output`](crate::types::block::output::Output) kind of a [`DelegationOutput`].
pub const KIND: u8 = 7;
pub const KIND: u8 = 4;
/// The set of allowed [`UnlockCondition`]s for a [`DelegationOutput`].
pub const ALLOWED_UNLOCK_CONDITIONS: UnlockConditionFlags = UnlockConditionFlags::ADDRESS;

Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/output/foundry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ pub struct FoundryOutput {

impl FoundryOutput {
/// The [`Output`](crate::types::block::output::Output) kind of a [`FoundryOutput`].
pub const KIND: u8 = 5;
pub const KIND: u8 = 2;
/// The set of allowed [`UnlockCondition`]s for a [`FoundryOutput`].
pub const ALLOWED_UNLOCK_CONDITIONS: UnlockConditionFlags = UnlockConditionFlags::IMMUTABLE_ACCOUNT_ADDRESS;
/// The set of allowed [`Feature`]s for a [`FoundryOutput`].
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/types/block/output/nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ pub struct NftOutput {

impl NftOutput {
/// The [`Output`](crate::types::block::output::Output) kind of an [`NftOutput`].
pub const KIND: u8 = 6;
pub const KIND: u8 = 3;
/// The set of allowed [`UnlockCondition`]s for an [`NftOutput`].
pub const ALLOWED_UNLOCK_CONDITIONS: UnlockConditionFlags = UnlockConditionFlags::ADDRESS
.union(UnlockConditionFlags::STORAGE_DEPOSIT_RETURN)
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/types/block/payload/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl From<TaggedDataPayload> for Payload {

impl Payload {
/// Returns the payload kind of a `Payload`.
pub fn kind(&self) -> u32 {
pub fn kind(&self) -> u8 {
match self {
Self::Transaction(_) => TransactionPayload::KIND,
Self::TaggedData(_) => TaggedDataPayload::KIND,
Expand Down Expand Up @@ -86,7 +86,7 @@ impl Packable for Payload {
unpacker: &mut U,
visitor: &Self::UnpackVisitor,
) -> Result<Self, UnpackError<Self::UnpackError, U::Error>> {
Ok(match u32::unpack::<_, VERIFY>(unpacker, &()).coerce()? {
Ok(match u8::unpack::<_, VERIFY>(unpacker, &()).coerce()? {
TransactionPayload::KIND => {
Self::from(TransactionPayload::unpack::<_, VERIFY>(unpacker, visitor).coerce()?)
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/types/block/payload/tagged_data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct TaggedDataPayload {

impl TaggedDataPayload {
/// The payload kind of a [`TaggedDataPayload`].
pub const KIND: u32 = 5;
pub const KIND: u8 = 0;
/// Valid lengths for the tag.
pub const TAG_LENGTH_RANGE: RangeInclusive<u8> = 0..=64;
/// Valid lengths for the data.
Expand Down Expand Up @@ -80,7 +80,7 @@ pub mod dto {
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
struct TaggedDataPayloadDto {
#[serde(rename = "type")]
kind: u32,
kind: u8,
#[serde(skip_serializing_if = "<[_]>::is_empty", default, with = "prefix_hex_bytes")]
tag: Box<[u8]>,
#[serde(skip_serializing_if = "<[_]>::is_empty", default, with = "prefix_hex_bytes")]
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/types/block/payload/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct TransactionPayload {

impl TransactionPayload {
/// The payload kind of a [`TransactionPayload`].
pub const KIND: u32 = 6;
pub const KIND: u8 = 1;

/// Creates a new [`TransactionPayload`].
pub fn new(essence: RegularTransactionEssence, unlocks: Unlocks) -> Result<Self, Error> {
Expand Down Expand Up @@ -110,7 +110,7 @@ pub mod dto {
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
pub struct TransactionPayloadDto {
#[serde(rename = "type")]
pub kind: u32,
pub kind: u8,
pub essence: TransactionEssenceDto,
pub unlocks: Vec<Unlock>,
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/tests/client/input_signing_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn input_signing_data_conversion() {
InputSigningData::try_from_dto_with_params(input_signing_data_dto.clone(), &protocol_parameters).unwrap();
assert_eq!(input_signing_data, restored_input_signing_data);

let input_signing_data_dto_str = r#"{"output":{"type":3,"amount":"1000000","mana":"0","unlockConditions":[{"type":0,"address":{"type":0,"pubKeyHash":"0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"}}]},"outputMetadata":{"blockId":"0xedf5f572c58ddf4b4f9567d82bf96689cc68b730df796d822b4b9fb643f5efda0000000000000000","transactionId":"0xbce525324af12eda02bf7927e92cea3a8e8322d0f41966271443e6c3b245a440","outputIndex":0,"isSpent":false,"commitmentIdSpent":"0xedf5f572c58ddf4b4f9567d82bf96689cc68b730df796d822b4b9fb643f5efda4f9567d82bf96689","transactionIdSpent":"0x24a1f46bdb6b2bf38f1c59f73cdd4ae5b418804bb231d76d06fbf246498d5883","includedCommitmentId":"0xedf5f572c58ddf4b4f9567d82bf96689cc68b730df796d822b4b9fb643f5efda4f9567d82bf96689","latestCommitmentId":"0xedf5f572c58ddf4b4f9567d82bf96689cc68b730df796d822b4b9fb643f5efda4f9567d82bf96689"},"chain":{"coinType":4219,"account":0,"change":0,"addressIndex":0}}"#;
let input_signing_data_dto_str = r#"{"output":{"type":0,"amount":"1000000","mana":"0","unlockConditions":[{"type":0,"address":{"type":0,"pubKeyHash":"0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"}}]},"outputMetadata":{"blockId":"0xedf5f572c58ddf4b4f9567d82bf96689cc68b730df796d822b4b9fb643f5efda0000000000000000","transactionId":"0xbce525324af12eda02bf7927e92cea3a8e8322d0f41966271443e6c3b245a440","outputIndex":0,"isSpent":false,"commitmentIdSpent":"0xedf5f572c58ddf4b4f9567d82bf96689cc68b730df796d822b4b9fb643f5efda4f9567d82bf96689","transactionIdSpent":"0x24a1f46bdb6b2bf38f1c59f73cdd4ae5b418804bb231d76d06fbf246498d5883","includedCommitmentId":"0xedf5f572c58ddf4b4f9567d82bf96689cc68b730df796d822b4b9fb643f5efda4f9567d82bf96689","latestCommitmentId":"0xedf5f572c58ddf4b4f9567d82bf96689cc68b730df796d822b4b9fb643f5efda4f9567d82bf96689"},"chain":{"coinType":4219,"account":0,"change":0,"addressIndex":0}}"#;
assert_eq!(
serde_json::to_string(&input_signing_data_dto).unwrap(),
input_signing_data_dto_str
Expand Down
Loading

0 comments on commit f5532eb

Please sign in to comment.