diff --git a/crates/iota-sdk-crypto/src/multisig.rs b/crates/iota-sdk-crypto/src/multisig.rs index f4a426ca1..9d90fe2ad 100644 --- a/crates/iota-sdk-crypto/src/multisig.rs +++ b/crates/iota-sdk-crypto/src/multisig.rs @@ -247,6 +247,7 @@ impl Verifier for UserSignatureVerifier { UserSignature::Passkey(passkey_authenticator) => { crate::passkey::PasskeyVerifier::default().verify(message, passkey_authenticator) } + _ => Err(SignatureError::from_source("unknown signature scheme")), } } } @@ -391,9 +392,9 @@ fn multisig_pubkey_and_signature_from_user_signature( MultisigMemberSignature::ZkLogin(zklogin_authenticator), )) } - UserSignature::Multisig(_) | UserSignature::Passkey(_) => { Err(SignatureError::from_source("invalid signature scheme")) } + _ => Err(SignatureError::from_source("unknown signature scheme")), } } diff --git a/crates/iota-sdk-crypto/src/simple.rs b/crates/iota-sdk-crypto/src/simple.rs index e862c42eb..91d5fd667 100644 --- a/crates/iota-sdk-crypto/src/simple.rs +++ b/crates/iota-sdk-crypto/src/simple.rs @@ -49,6 +49,7 @@ impl Verifier for SimpleVerifier { SimpleSignature::Secp256r1 { .. } => Err(SignatureError::from_source( "support for secp256r1 is not enabled", )), + _ => Err(SignatureError::from_source("unknown signature scheme")), } } } diff --git a/crates/iota-sdk-crypto/src/zklogin/verify.rs b/crates/iota-sdk-crypto/src/zklogin/verify.rs index f3ef19f13..5839bb56e 100644 --- a/crates/iota-sdk-crypto/src/zklogin/verify.rs +++ b/crates/iota-sdk-crypto/src/zklogin/verify.rs @@ -287,7 +287,7 @@ fn zklogin_proof_to_arkworks( /// Given a SimpleSignature convert the corresponding public key, prefixed with /// the signature scheme flag, to two Bn254Frs -pub fn public_key_to_frs(signature: &SimpleSignature) -> (Fr, Fr) { +fn public_key_to_frs(signature: &SimpleSignature) -> Result<(Fr, Fr), SignatureError> { // buf length of the longest public key secp256r1/secp256k1 of 33 bytes plus 1 // byte for the scheme let mut buf = [0u8; 34]; @@ -307,6 +307,7 @@ pub fn public_key_to_frs(signature: &SimpleSignature) -> (Fr, Fr) { buf[1..Secp256r1PublicKey::LENGTH + 1].copy_from_slice(public_key.inner()); &buf[..Secp256r1PublicKey::LENGTH + 1] } + _ => return Err(SignatureError::from_source("unknown signature scheme")), }; // TODO this comment is wrong... @@ -317,7 +318,8 @@ pub fn public_key_to_frs(signature: &SimpleSignature) -> (Fr, Fr) { let eph_public_key_0 = Fr::from_be_bytes_mod_order(first_half); let eph_public_key_1 = Fr::from_be_bytes_mod_order(second_half); - (eph_public_key_0, eph_public_key_1) + + Ok((eph_public_key_0, eph_public_key_1)) } pub(crate) type U256 = bnum::BUintD8<32>; @@ -441,7 +443,7 @@ pub fn calculate_all_inputs_hash( return Err(SignatureError::from_source("header too long")); } - let (first, second) = public_key_to_frs(signature); + let (first, second) = public_key_to_frs(signature)?; let address_seed = bn254_to_fr(inputs.address_seed()); let max_epoch_f = Fr::from_be_bytes_mod_order(U256::from(max_epoch).to_be().digits()); @@ -596,7 +598,7 @@ mod tests { signature: Ed25519Signature::new([0; 64]), public_key: pubkey, }; - let (actual_0, actual_1) = public_key_to_frs(&signature); + let (actual_0, actual_1) = public_key_to_frs(&signature).unwrap(); let expect_0 = Fr::from(ark_ff::BigInt([ 1244302228903607218, 13386648721483054705, diff --git a/crates/iota-sdk-ffi/src/faucet.rs b/crates/iota-sdk-ffi/src/faucet.rs index 822660feb..5f1c28d23 100644 --- a/crates/iota-sdk-ffi/src/faucet.rs +++ b/crates/iota-sdk-ffi/src/faucet.rs @@ -94,6 +94,7 @@ impl From for BatchSendSt iota_sdk::graphql_client::faucet::BatchSendStatusType::InProgress => Self::InProgress, iota_sdk::graphql_client::faucet::BatchSendStatusType::Succeeded => Self::Succeeded, iota_sdk::graphql_client::faucet::BatchSendStatusType::Discarded => Self::Discarded, + _ => unimplemented!(), } } } diff --git a/crates/iota-sdk-ffi/src/graphql.rs b/crates/iota-sdk-ffi/src/graphql.rs index 5893e193f..a777ee98b 100644 --- a/crates/iota-sdk-ffi/src/graphql.rs +++ b/crates/iota-sdk-ffi/src/graphql.rs @@ -39,8 +39,9 @@ use crate::{ }, }; -#[uniffi::remote(Enum)] /// Determines what to wait for after executing a transaction. +#[uniffi::remote(Enum)] +#[non_exhaustive] pub enum WaitForTx { /// Indicates that the transaction effects will be usable in subsequent /// transactions, and that the transaction itself is indexed on the node. diff --git a/crates/iota-sdk-ffi/src/types/execution_status.rs b/crates/iota-sdk-ffi/src/types/execution_status.rs index 85260bcd5..e1adbf1ea 100644 --- a/crates/iota-sdk-ffi/src/types/execution_status.rs +++ b/crates/iota-sdk-ffi/src/types/execution_status.rs @@ -47,6 +47,7 @@ impl From for ExecutionStatus { error: error.into(), command, }, + _ => unimplemented!(), } } } @@ -408,6 +409,7 @@ impl From for ExecutionError { Self::ExecutionCancelledDueToRandomnessUnavailable } iota_sdk::types::ExecutionError::InvalidLinkage => Self::InvalidLinkage, + _ => unimplemented!(), } } } @@ -613,6 +615,7 @@ impl From for iota_sdk::types::MoveLocation { /// shared-object-operation-not-allowed = %x0b /// ``` #[uniffi::remote(Enum)] +#[non_exhaustive] pub enum CommandArgumentError { /// The type of the value does not match the expected type TypeMismatch, @@ -717,6 +720,7 @@ impl From for PackageUpgradeError { package_id: Arc::new(package_id.into()), ticket_id: Arc::new(ticket_id.into()), }, + _ => unimplemented!(), } } } @@ -763,6 +767,7 @@ impl From for iota_sdk::types::PackageUpgradeError { /// ``` #[uniffi::remote(Enum)] #[repr(u8)] +#[non_exhaustive] pub enum TypeArgumentError { /// A type was not found in the module specified TypeNotFound, diff --git a/crates/iota-sdk-ffi/src/types/graphql.rs b/crates/iota-sdk-ffi/src/types/graphql.rs index 60a927288..317b8d2e0 100644 --- a/crates/iota-sdk-ffi/src/types/graphql.rs +++ b/crates/iota-sdk-ffi/src/types/graphql.rs @@ -735,6 +735,7 @@ pub struct ValidatorCredentials { } #[uniffi::remote(Enum)] +#[non_exhaustive] pub enum TransactionBlockKindInput { SystemTx, ProgrammableTx, @@ -960,6 +961,7 @@ impl MoveFunction { } #[uniffi::remote(Enum)] +#[non_exhaustive] pub enum MoveVisibility { Public, Private, @@ -967,6 +969,7 @@ pub enum MoveVisibility { } #[uniffi::remote(Enum)] +#[non_exhaustive] pub enum MoveAbility { Copy, Drop, @@ -1238,6 +1241,7 @@ pub struct ServiceConfig { } #[uniffi::remote(Enum)] +#[non_exhaustive] pub enum Feature { Analytics, Coins, diff --git a/crates/iota-sdk-ffi/src/types/signature.rs b/crates/iota-sdk-ffi/src/types/signature.rs index 23d3f7bcb..1217b6913 100644 --- a/crates/iota-sdk-ffi/src/types/signature.rs +++ b/crates/iota-sdk-ffi/src/types/signature.rs @@ -32,6 +32,7 @@ use crate::{ /// passkey-flag = %x06 /// ``` #[uniffi::remote(Enum)] +#[non_exhaustive] #[repr(u8)] pub enum SignatureScheme { Ed25519 = 0x00, diff --git a/crates/iota-sdk-ffi/src/types/transaction/mod.rs b/crates/iota-sdk-ffi/src/types/transaction/mod.rs index 29aaf21e3..00f584be3 100644 --- a/crates/iota-sdk-ffi/src/types/transaction/mod.rs +++ b/crates/iota-sdk-ffi/src/types/transaction/mod.rs @@ -53,6 +53,7 @@ impl Transaction { pub fn as_v1(&self) -> Arc { match &self.0 { iota_sdk::types::Transaction::V1(tx) => Arc::new(TransactionV1(tx.clone())), + _ => unimplemented!(), } } @@ -1801,6 +1802,7 @@ impl From for TransactionArgument { iota_sdk::types::TransactionArgument::Result { cmd, ix } => { TransactionArgument::Result { cmd, ix } } + _ => unimplemented!(), } } } @@ -1960,6 +1962,7 @@ impl From for iota_sdk::types::DryRunResult { /// =/ %x01 u64 ; epoch /// ``` #[uniffi::remote(Enum)] +#[non_exhaustive] pub enum TransactionExpiration { /// The transaction has no expiration None, diff --git a/crates/iota-sdk-ffi/src/types/transaction/v1.rs b/crates/iota-sdk-ffi/src/types/transaction/v1.rs index e60a92ba9..8daa8f60c 100644 --- a/crates/iota-sdk-ffi/src/types/transaction/v1.rs +++ b/crates/iota-sdk-ffi/src/types/transaction/v1.rs @@ -252,6 +252,7 @@ impl From for UnchangedSharedKind { Self::Cancelled { version } } iota_sdk::types::UnchangedSharedKind::PerEpochConfig => Self::PerEpochConfig, + _ => unimplemented!(), } } } @@ -311,6 +312,7 @@ impl From for ObjectIn { digest: Arc::new(digest.into()), owner: Arc::new(owner.into()), }, + _ => unimplemented!(), } } } @@ -374,6 +376,7 @@ impl From for ObjectOut { version, digest: Arc::new(digest.into()), }, + _ => unimplemented!(), } } } @@ -410,6 +413,7 @@ impl From for iota_sdk::types::ObjectOut { /// id-operation-deleted = %x02 /// ``` #[uniffi::remote(Enum)] +#[non_exhaustive] #[repr(u8)] pub enum IdOperation { None, diff --git a/crates/iota-sdk-graphql-client/src/faucet.rs b/crates/iota-sdk-graphql-client/src/faucet.rs index dc7f6c54c..2382c2dca 100644 --- a/crates/iota-sdk-graphql-client/src/faucet.rs +++ b/crates/iota-sdk-graphql-client/src/faucet.rs @@ -38,6 +38,7 @@ struct BatchStatusFaucetResponse { #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] #[serde(rename_all = "UPPERCASE")] +#[non_exhaustive] pub enum BatchSendStatusType { InProgress, Succeeded, diff --git a/crates/iota-sdk-graphql-client/src/lib.rs b/crates/iota-sdk-graphql-client/src/lib.rs index 4f93e8b74..5dbda0801 100644 --- a/crates/iota-sdk-graphql-client/src/lib.rs +++ b/crates/iota-sdk-graphql-client/src/lib.rs @@ -76,6 +76,7 @@ fn response_to_err(response: GraphQlResponse) -> Result { } /// Determines what to wait for after executing a transaction. +#[non_exhaustive] pub enum WaitForTx { /// Indicates that the transaction effects will be usable in subsequent /// transactions, and that the transaction itself is indexed on the node. diff --git a/crates/iota-sdk-graphql-client/src/query_types/dry_run.rs b/crates/iota-sdk-graphql-client/src/query_types/dry_run.rs index 716b3487b..6ee8ebfcd 100644 --- a/crates/iota-sdk-graphql-client/src/query_types/dry_run.rs +++ b/crates/iota-sdk-graphql-client/src/query_types/dry_run.rs @@ -48,6 +48,7 @@ pub struct DryRunReturn { #[derive(cynic::InlineFragments, Debug)] #[cynic(schema = "rpc", graphql_type = "TransactionArgument")] +#[non_exhaustive] pub enum TransactionArgument { GasCoin(GasCoin), Input(Input), diff --git a/crates/iota-sdk-graphql-client/src/query_types/dynamic_fields.rs b/crates/iota-sdk-graphql-client/src/query_types/dynamic_fields.rs index 358219efd..d1896e62c 100644 --- a/crates/iota-sdk-graphql-client/src/query_types/dynamic_fields.rs +++ b/crates/iota-sdk-graphql-client/src/query_types/dynamic_fields.rs @@ -78,6 +78,7 @@ pub struct DynamicField { #[derive(cynic::InlineFragments, Debug)] #[cynic(schema = "rpc", graphql_type = "DynamicFieldValue")] +#[non_exhaustive] pub enum DynamicFieldValue { MoveObject(MoveObjectContents), MoveValue(MoveValue), diff --git a/crates/iota-sdk-graphql-client/src/query_types/normalized_move/mod.rs b/crates/iota-sdk-graphql-client/src/query_types/normalized_move/mod.rs index b6c401b6e..02b8610e4 100644 --- a/crates/iota-sdk-graphql-client/src/query_types/normalized_move/mod.rs +++ b/crates/iota-sdk-graphql-client/src/query_types/normalized_move/mod.rs @@ -17,6 +17,7 @@ use crate::query_types::schema; #[derive(cynic::Enum, Copy, Debug, Clone, strum::Display)] #[cynic(schema = "rpc", graphql_type = "MoveAbility")] #[strum(serialize_all = "snake_case")] +#[non_exhaustive] pub enum MoveAbility { Copy, Drop, @@ -27,6 +28,7 @@ pub enum MoveAbility { #[derive(cynic::Enum, Copy, Debug, Clone, strum::Display)] #[cynic(schema = "rpc", graphql_type = "MoveVisibility")] #[strum(serialize_all = "snake_case")] +#[non_exhaustive] pub enum MoveVisibility { Public, Private, diff --git a/crates/iota-sdk-graphql-client/src/query_types/service_config.rs b/crates/iota-sdk-graphql-client/src/query_types/service_config.rs index 7a0b0ea22..3ae5a6acb 100644 --- a/crates/iota-sdk-graphql-client/src/query_types/service_config.rs +++ b/crates/iota-sdk-graphql-client/src/query_types/service_config.rs @@ -80,6 +80,7 @@ pub struct ServiceConfig { graphql_type = "Feature", rename_all = "SCREAMING_SNAKE_CASE" )] +#[non_exhaustive] pub enum Feature { Analytics, Coins, diff --git a/crates/iota-sdk-graphql-client/src/query_types/transaction.rs b/crates/iota-sdk-graphql-client/src/query_types/transaction.rs index 7875dd7b1..2b2f904e5 100644 --- a/crates/iota-sdk-graphql-client/src/query_types/transaction.rs +++ b/crates/iota-sdk-graphql-client/src/query_types/transaction.rs @@ -170,6 +170,7 @@ pub struct TransactionBlockCheckpoint { graphql_type = "TransactionBlockKindInput", rename_all = "SCREAMING_SNAKE_CASE" )] +#[non_exhaustive] pub enum TransactionBlockKindInput { SystemTx, ProgrammableTx, diff --git a/crates/iota-sdk-transaction-builder/src/builder/client_methods.rs b/crates/iota-sdk-transaction-builder/src/builder/client_methods.rs index 8d8e2a0f0..db0e0ee9d 100644 --- a/crates/iota-sdk-transaction-builder/src/builder/client_methods.rs +++ b/crates/iota-sdk-transaction-builder/src/builder/client_methods.rs @@ -228,7 +228,9 @@ impl ClientMethods for iota_graphql_client::Client { tx: &Transaction, skip_checks: bool, ) -> Result { - let Transaction::V1(tx) = &tx; + let Transaction::V1(tx) = &tx else { + unimplemented!() + }; let gas_objects = tx .gas_payment .objects diff --git a/crates/iota-sdk-transaction-builder/src/builder/gas_station.rs b/crates/iota-sdk-transaction-builder/src/builder/gas_station.rs index 60bcb0ab1..8951b629b 100644 --- a/crates/iota-sdk-transaction-builder/src/builder/gas_station.rs +++ b/crates/iota-sdk-transaction-builder/src/builder/gas_station.rs @@ -407,6 +407,7 @@ impl GasStationData { inner_txn.gas_payment.objects = objects; reservation_id } + _ => unimplemented!(), }; let tx_bytes = base64ct::Base64::encode_string(&bcs::to_bytes(&txn).map_err(Error::Bcs)?); diff --git a/crates/iota-sdk-transaction-builder/src/builder/mod.rs b/crates/iota-sdk-transaction-builder/src/builder/mod.rs index 46589f7f8..11041704b 100644 --- a/crates/iota-sdk-transaction-builder/src/builder/mod.rs +++ b/crates/iota-sdk-transaction-builder/src/builder/mod.rs @@ -1027,6 +1027,7 @@ impl TransactionBuilder { initial_shared_version: *v, mutable: false, }, + _ => unimplemented!(), }; let idx = inputs.len(); inputs.push(input); @@ -1113,7 +1114,9 @@ impl TransactionBuilder { .await .map_err(Error::client)? .ok_or(Error::MissingGasBudget)?; - let Transaction::V1(txn) = &mut txn; + let Transaction::V1(txn) = &mut txn else { + unimplemented!() + }; txn.gas_payment.budget = budget } @@ -1129,7 +1132,9 @@ impl TransactionBuilder { pub async fn dry_run(mut self, skip_checks: bool) -> Result { let txn = self.resolve_ptb(false).await?; { - let Transaction::V1(txn) = &txn; + let Transaction::V1(txn) = &txn else { + unimplemented!() + }; if !txn.gas_payment.objects.is_empty() && txn.gas_payment.budget == 0 { return Err(Error::DryRun( "gas coins were provided without a gas budget".to_owned(), diff --git a/crates/iota-sdk-transaction-builder/src/lib.rs b/crates/iota-sdk-transaction-builder/src/lib.rs index 2277197b8..9e7598892 100644 --- a/crates/iota-sdk-transaction-builder/src/lib.rs +++ b/crates/iota-sdk-transaction-builder/src/lib.rs @@ -577,6 +577,7 @@ mod tests { } } } + _ => unimplemented!(), } } check_effects_status_success(effects).await; diff --git a/crates/iota-sdk-transaction-builder/src/unresolved.rs b/crates/iota-sdk-transaction-builder/src/unresolved.rs index 48c547887..3987eb809 100644 --- a/crates/iota-sdk-transaction-builder/src/unresolved.rs +++ b/crates/iota-sdk-transaction-builder/src/unresolved.rs @@ -29,12 +29,14 @@ impl Input { | iota_types::Input::Receiving(ObjectReference { object_id, .. }) => { Some(object_id) } + _ => unimplemented!(), }, } } } #[derive(Debug, Clone, PartialEq, Eq)] +#[non_exhaustive] pub enum InputKind { ImmutableOrOwned(ObjectId), Shared { object_id: ObjectId, mutable: bool }, @@ -61,6 +63,7 @@ impl InputKind { } #[derive(Debug, Clone, derive_more::From)] +#[non_exhaustive] pub enum Command { MoveCall(MoveCall), TransferObjects(TransferObjects), @@ -231,6 +234,7 @@ impl Publish { } #[derive(Debug, Clone, Copy)] +#[non_exhaustive] pub enum Argument { Gas, Input(InputId), diff --git a/crates/iota-sdk-types/src/checkpoint.rs b/crates/iota-sdk-types/src/checkpoint.rs index e6ee734f7..55e6e0143 100644 --- a/crates/iota-sdk-types/src/checkpoint.rs +++ b/crates/iota-sdk-types/src/checkpoint.rs @@ -31,6 +31,7 @@ pub type ProtocolVersion = u64; schemars(tag = "type", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum CheckpointCommitment { /// An Elliptic Curve Multiset Hash attesting to the set of Objects that /// compose the live state of the IOTA blockchain. diff --git a/crates/iota-sdk-types/src/crypto/multisig.rs b/crates/iota-sdk-types/src/crypto/multisig.rs index 493e29342..012f52dd5 100644 --- a/crates/iota-sdk-types/src/crypto/multisig.rs +++ b/crates/iota-sdk-types/src/crypto/multisig.rs @@ -47,6 +47,7 @@ const MAX_COMMITTEE_SIZE: usize = 10; /// ``` #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum MultisigMemberPublicKey { Ed25519(Ed25519PublicKey), Secp256k1(Secp256k1PublicKey), @@ -320,6 +321,7 @@ impl Eq for MultisigAggregatedSignature {} /// ``` #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum MultisigMemberSignature { Ed25519(Ed25519Signature), Secp256k1(Secp256k1Signature), diff --git a/crates/iota-sdk-types/src/crypto/passkey.rs b/crates/iota-sdk-types/src/crypto/passkey.rs index a4d469d68..47bfc96b0 100644 --- a/crates/iota-sdk-types/src/crypto/passkey.rs +++ b/crates/iota-sdk-types/src/crypto/passkey.rs @@ -310,7 +310,7 @@ mod serialization { /// [5.8.1.1 Serialization]: https://w3c.github.io/webauthn/#clientdatajson-serialization #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] - pub struct CollectedClientData { + pub(super) struct CollectedClientData { /// This member contains the value [`ClientDataType::Create`] when /// creating new credentials, and [`ClientDataType::Get`] when /// getting an assertion from an existing credential. The purpose @@ -349,7 +349,7 @@ mod serialization { /// Used to limit the values of [`CollectedClientData::ty`] and serializes /// to static strings. #[derive(Debug, Deserialize, Serialize, Clone, Copy, PartialEq, Eq)] - pub enum ClientDataType { + pub(super) enum ClientDataType { /// Serializes to the string `"webauthn.get"` /// /// Passkey's in IOTA only support the value `"webauthn.get"`, other diff --git a/crates/iota-sdk-types/src/crypto/signature.rs b/crates/iota-sdk-types/src/crypto/signature.rs index bfe290fcd..4e51bb4a2 100644 --- a/crates/iota-sdk-types/src/crypto/signature.rs +++ b/crates/iota-sdk-types/src/crypto/signature.rs @@ -37,6 +37,7 @@ use super::{ schemars(tag = "scheme", rename_all = "lowercase") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum SimpleSignature { Ed25519 { signature: Ed25519Signature, @@ -216,6 +217,7 @@ impl SimpleSignature { #[strum(serialize_all = "lowercase")] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] #[repr(u8)] +#[non_exhaustive] pub enum SignatureScheme { Ed25519 = 0x00, Secp256k1 = 0x01, @@ -295,6 +297,7 @@ impl std::fmt::Display for InvalidSignatureScheme { /// the completely serialized signature. #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum UserSignature { Simple(SimpleSignature), Multisig(MultisigAggregatedSignature), diff --git a/crates/iota-sdk-types/src/effects/mod.rs b/crates/iota-sdk-types/src/effects/mod.rs index 703b625c6..d747e0df0 100644 --- a/crates/iota-sdk-types/src/effects/mod.rs +++ b/crates/iota-sdk-types/src/effects/mod.rs @@ -28,6 +28,7 @@ use crate::{SignedTransaction, TypeTag, execution_status::ExecutionStatus}; schemars(tag = "version") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum TransactionEffects { #[cfg_attr(feature = "schemars", schemars(rename = "1"))] V1(Box), @@ -121,6 +122,7 @@ pub struct DryRunReturn { /// A transaction argument used in programmable transactions. #[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[non_exhaustive] pub enum TransactionArgument { /// Reference to the gas coin. GasCoin, diff --git a/crates/iota-sdk-types/src/effects/v1.rs b/crates/iota-sdk-types/src/effects/v1.rs index d9cb8fac1..980892c0b 100644 --- a/crates/iota-sdk-types/src/effects/v1.rs +++ b/crates/iota-sdk-types/src/effects/v1.rs @@ -158,6 +158,7 @@ pub struct UnchangedSharedObject { schemars(tag = "kind", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum UnchangedSharedKind { /// Read-only shared objects from the input. We don't really need /// ObjectDigest for protocol correctness, but it will make it easier to @@ -221,6 +222,7 @@ impl UnchangedSharedKind { schemars(tag = "state", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum ObjectIn { Missing, /// The old version, digest and owner. @@ -295,6 +297,7 @@ impl ObjectIn { schemars(tag = "state", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum ObjectOut { /// Same definition as in ObjectIn. Missing, @@ -384,6 +387,7 @@ impl ObjectOut { )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum IdOperation { None, Created, diff --git a/crates/iota-sdk-types/src/execution_status.rs b/crates/iota-sdk-types/src/execution_status.rs index 8f7715bba..b5510ff1d 100644 --- a/crates/iota-sdk-types/src/execution_status.rs +++ b/crates/iota-sdk-types/src/execution_status.rs @@ -17,6 +17,7 @@ use super::{Address, Digest, Identifier, ObjectId}; /// ``` #[derive(Eq, PartialEq, Clone, Debug)] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum ExecutionStatus { /// The Transaction successfully executed. Success, @@ -148,6 +149,7 @@ impl ExecutionStatus { schemars(tag = "error", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum ExecutionError { /// Insufficient Gas InsufficientGas, @@ -388,6 +390,7 @@ pub struct MoveLocation { schemars(tag = "kind", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum CommandArgumentError { /// The type of the value does not match the expected type TypeMismatch, @@ -470,6 +473,7 @@ impl CommandArgumentError { schemars(tag = "kind", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum PackageUpgradeError { /// Unable to fetch package UnableToFetchPackage { package_id: ObjectId }, @@ -522,6 +526,7 @@ impl PackageUpgradeError { schemars(rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum TypeArgumentError { /// A type was not found in the module specified TypeNotFound, diff --git a/crates/iota-sdk-types/src/framework.rs b/crates/iota-sdk-types/src/framework.rs index 5cb9cf478..7f0d38195 100644 --- a/crates/iota-sdk-types/src/framework.rs +++ b/crates/iota-sdk-types/src/framework.rs @@ -55,6 +55,7 @@ impl Coin { } #[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum CoinFromObjectError { NotACoin, InvalidContentLength, diff --git a/crates/iota-sdk-types/src/iota_names/error.rs b/crates/iota-sdk-types/src/iota_names/error.rs index 1a1771aa3..03eaffe15 100644 --- a/crates/iota-sdk-types/src/iota_names/error.rs +++ b/crates/iota-sdk-types/src/iota_names/error.rs @@ -5,6 +5,7 @@ use crate::ObjectId; #[derive(thiserror::Error, Debug, Clone, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[non_exhaustive] pub enum IotaNamesError { #[error("Name length {0} exceeds maximum length {1}")] NameLengthExceeded(usize, usize), diff --git a/crates/iota-sdk-types/src/move_package.rs b/crates/iota-sdk-types/src/move_package.rs index 6ccc1e74c..b9f1709b3 100644 --- a/crates/iota-sdk-types/src/move_package.rs +++ b/crates/iota-sdk-types/src/move_package.rs @@ -7,6 +7,7 @@ use crate::{Digest, ObjectId}; #[repr(u8)] #[derive(strum::Display, Debug, Clone, Copy, PartialEq, Eq)] #[strum(serialize_all = "SCREAMING_SNAKE_CASE")] +#[non_exhaustive] pub enum UpgradePolicy { /// The least restrictive policy. Permits changes to all function /// implementations, the removal of ability constraints on generic type diff --git a/crates/iota-sdk-types/src/object.rs b/crates/iota-sdk-types/src/object.rs index e17627d6e..d84b96e02 100644 --- a/crates/iota-sdk-types/src/object.rs +++ b/crates/iota-sdk-types/src/object.rs @@ -97,6 +97,7 @@ impl ObjectReference { )] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum Owner { /// Object is exclusively owned by a single address, and is mutable. Address(Address), diff --git a/crates/iota-sdk-types/src/transaction/mod.rs b/crates/iota-sdk-types/src/transaction/mod.rs index ed6dde56a..be54aad62 100644 --- a/crates/iota-sdk-types/src/transaction/mod.rs +++ b/crates/iota-sdk-types/src/transaction/mod.rs @@ -29,6 +29,7 @@ pub(crate) use serialization::SignedTransactionWithIntentMessage; #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[non_exhaustive] pub enum Transaction { #[cfg_attr(feature = "serde", serde(rename = "1"))] V1(TransactionV1), @@ -87,6 +88,7 @@ pub struct SignedTransaction { /// ``` #[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Hash)] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum TransactionExpiration { /// The transaction has no expiration #[default] @@ -189,6 +191,7 @@ pub struct RandomnessStateUpdate { /// ``` #[derive(Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum TransactionKind { /// A user transaction comprised of a list of native commands and move calls ProgrammableTransaction(ProgrammableTransaction), @@ -254,6 +257,7 @@ impl TransactionKind { schemars(tag = "kind", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum EndOfEpochTransactionKind { /// End the epoch and start the next one ChangeEpoch(ChangeEpoch), @@ -293,6 +297,7 @@ impl EndOfEpochTransactionKind { #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[non_exhaustive] pub enum ExecutionTimeObservations { V1(Vec), } @@ -351,6 +356,7 @@ pub struct ValidatorExecutionTimeObservation { #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +#[non_exhaustive] pub enum ExecutionTimeObservationKey { // Contains all the fields from `ProgrammableMoveCall` besides `arguments`. MoveEntryPoint { @@ -472,6 +478,7 @@ pub struct ActiveJwk { schemars(tag = "kind", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum ConsensusDeterminedVersionAssignments { /// Cancelled transaction version assignment. CancelledTransactions { @@ -886,6 +893,7 @@ pub struct ProgrammableTransaction { schemars(tag = "type", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum Input { /// A move value serialized as BCS. /// @@ -950,6 +958,7 @@ impl Input { schemars(tag = "command", rename_all = "snake_case") )] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum Command { /// A call to either an entry or a public Move function MoveCall(MoveCall), @@ -1165,6 +1174,7 @@ pub struct Upgrade { /// ``` #[derive(Clone, Copy, Debug, PartialEq, Eq)] #[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))] +#[non_exhaustive] pub enum Argument { /// The gas coin. The gas coin can only be used by-ref, except for with /// `TransferObjects`, which can use it by-value. diff --git a/crates/iota-sdk/examples/get_object.rs b/crates/iota-sdk/examples/get_object.rs index 0b3a98ab1..993cd567c 100644 --- a/crates/iota-sdk/examples/get_object.rs +++ b/crates/iota-sdk/examples/get_object.rs @@ -3,7 +3,7 @@ use std::str::FromStr; -use eyre::{OptionExt, Result}; +use eyre::{OptionExt, Result, bail}; use iota_sdk::{graphql_client::Client, types::ObjectId}; #[tokio::main] @@ -31,6 +31,7 @@ async fn main() -> Result<()> { iota_types::Owner::Object(object_id) => format!("Object({object_id})"), iota_types::Owner::Shared(version) => format!("Shared({version})"), iota_types::Owner::Immutable => "Immutable".to_owned(), + _ => bail!("unknown owner type"), } ); println!("Storage rebate: {}", obj.storage_rebate());