Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/iota-sdk-crypto/src/multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ impl Verifier<UserSignature> for UserSignatureVerifier {
UserSignature::Passkey(passkey_authenticator) => {
crate::passkey::PasskeyVerifier::default().verify(message, passkey_authenticator)
}
_ => Err(SignatureError::from_source("unknown signature scheme")),
}
}
}
Expand Down Expand Up @@ -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")),
}
}
1 change: 1 addition & 0 deletions crates/iota-sdk-crypto/src/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl Verifier<SimpleSignature> for SimpleVerifier {
SimpleSignature::Secp256r1 { .. } => Err(SignatureError::from_source(
"support for secp256r1 is not enabled",
)),
_ => Err(SignatureError::from_source("unknown signature scheme")),
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions crates/iota-sdk-crypto/src/zklogin/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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...
Expand All @@ -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>;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/iota-sdk-ffi/src/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ impl From<iota_sdk::graphql_client::faucet::BatchSendStatusType> 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!(),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion crates/iota-sdk-ffi/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions crates/iota-sdk-ffi/src/types/execution_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl From<iota_sdk::types::ExecutionStatus> for ExecutionStatus {
error: error.into(),
command,
},
_ => unimplemented!(),
}
}
}
Expand Down Expand Up @@ -408,6 +409,7 @@ impl From<iota_sdk::types::ExecutionError> for ExecutionError {
Self::ExecutionCancelledDueToRandomnessUnavailable
}
iota_sdk::types::ExecutionError::InvalidLinkage => Self::InvalidLinkage,
_ => unimplemented!(),
}
}
}
Expand Down Expand Up @@ -613,6 +615,7 @@ impl From<MoveLocation> 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,
Expand Down Expand Up @@ -717,6 +720,7 @@ impl From<iota_sdk::types::PackageUpgradeError> for PackageUpgradeError {
package_id: Arc::new(package_id.into()),
ticket_id: Arc::new(ticket_id.into()),
},
_ => unimplemented!(),
}
}
}
Expand Down Expand Up @@ -763,6 +767,7 @@ impl From<PackageUpgradeError> 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,
Expand Down
4 changes: 4 additions & 0 deletions crates/iota-sdk-ffi/src/types/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,7 @@ pub struct ValidatorCredentials {
}

#[uniffi::remote(Enum)]
#[non_exhaustive]
pub enum TransactionBlockKindInput {
SystemTx,
ProgrammableTx,
Expand Down Expand Up @@ -960,13 +961,15 @@ impl MoveFunction {
}

#[uniffi::remote(Enum)]
#[non_exhaustive]
pub enum MoveVisibility {
Public,
Private,
Friend,
}

#[uniffi::remote(Enum)]
#[non_exhaustive]
pub enum MoveAbility {
Copy,
Drop,
Expand Down Expand Up @@ -1238,6 +1241,7 @@ pub struct ServiceConfig {
}

#[uniffi::remote(Enum)]
#[non_exhaustive]
pub enum Feature {
Analytics,
Coins,
Expand Down
1 change: 1 addition & 0 deletions crates/iota-sdk-ffi/src/types/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::{
/// passkey-flag = %x06
/// ```
#[uniffi::remote(Enum)]
#[non_exhaustive]
#[repr(u8)]
pub enum SignatureScheme {
Ed25519 = 0x00,
Expand Down
3 changes: 3 additions & 0 deletions crates/iota-sdk-ffi/src/types/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ impl Transaction {
pub fn as_v1(&self) -> Arc<TransactionV1> {
match &self.0 {
iota_sdk::types::Transaction::V1(tx) => Arc::new(TransactionV1(tx.clone())),
_ => unimplemented!(),
}
}

Expand Down Expand Up @@ -1801,6 +1802,7 @@ impl From<iota_sdk::types::TransactionArgument> for TransactionArgument {
iota_sdk::types::TransactionArgument::Result { cmd, ix } => {
TransactionArgument::Result { cmd, ix }
}
_ => unimplemented!(),
}
}
}
Expand Down Expand Up @@ -1960,6 +1962,7 @@ impl From<DryRunResult> for iota_sdk::types::DryRunResult {
/// =/ %x01 u64 ; epoch
/// ```
#[uniffi::remote(Enum)]
#[non_exhaustive]
pub enum TransactionExpiration {
/// The transaction has no expiration
None,
Expand Down
4 changes: 4 additions & 0 deletions crates/iota-sdk-ffi/src/types/transaction/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ impl From<iota_sdk::types::UnchangedSharedKind> for UnchangedSharedKind {
Self::Cancelled { version }
}
iota_sdk::types::UnchangedSharedKind::PerEpochConfig => Self::PerEpochConfig,
_ => unimplemented!(),
}
}
}
Expand Down Expand Up @@ -311,6 +312,7 @@ impl From<iota_sdk::types::ObjectIn> for ObjectIn {
digest: Arc::new(digest.into()),
owner: Arc::new(owner.into()),
},
_ => unimplemented!(),
}
}
}
Expand Down Expand Up @@ -374,6 +376,7 @@ impl From<iota_sdk::types::ObjectOut> for ObjectOut {
version,
digest: Arc::new(digest.into()),
},
_ => unimplemented!(),
}
}
}
Expand Down Expand Up @@ -410,6 +413,7 @@ impl From<ObjectOut> for iota_sdk::types::ObjectOut {
/// id-operation-deleted = %x02
/// ```
#[uniffi::remote(Enum)]
#[non_exhaustive]
#[repr(u8)]
pub enum IdOperation {
None,
Expand Down
1 change: 1 addition & 0 deletions crates/iota-sdk-graphql-client/src/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ struct BatchStatusFaucetResponse {

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "UPPERCASE")]
#[non_exhaustive]
pub enum BatchSendStatusType {
InProgress,
Succeeded,
Expand Down
1 change: 1 addition & 0 deletions crates/iota-sdk-graphql-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ fn response_to_err<T>(response: GraphQlResponse<T>) -> Result<T, crate::Error> {
}

/// 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ pub struct ServiceConfig {
graphql_type = "Feature",
rename_all = "SCREAMING_SNAKE_CASE"
)]
#[non_exhaustive]
pub enum Feature {
Analytics,
Coins,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ pub struct TransactionBlockCheckpoint {
graphql_type = "TransactionBlockKindInput",
rename_all = "SCREAMING_SNAKE_CASE"
)]
#[non_exhaustive]
pub enum TransactionBlockKindInput {
SystemTx,
ProgrammableTx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ impl ClientMethods for iota_graphql_client::Client {
tx: &Transaction,
skip_checks: bool,
) -> Result<DryRunResult, Self::Error> {
let Transaction::V1(tx) = &tx;
let Transaction::V1(tx) = &tx else {
unimplemented!()
};
let gas_objects = tx
.gas_payment
.objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)?);
Expand Down
9 changes: 7 additions & 2 deletions crates/iota-sdk-transaction-builder/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ impl<C: ClientMethods, L> TransactionBuilder<C, L> {
initial_shared_version: *v,
mutable: false,
},
_ => unimplemented!(),
};
let idx = inputs.len();
inputs.push(input);
Expand Down Expand Up @@ -1113,7 +1114,9 @@ impl<C: ClientMethods, L> TransactionBuilder<C, L> {
.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
}

Expand All @@ -1129,7 +1132,9 @@ impl<C: ClientMethods, L> TransactionBuilder<C, L> {
pub async fn dry_run(mut self, skip_checks: bool) -> Result<DryRunResult, Error> {
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(),
Expand Down
1 change: 1 addition & 0 deletions crates/iota-sdk-transaction-builder/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ mod tests {
}
}
}
_ => unimplemented!(),
}
}
check_effects_status_success(effects).await;
Expand Down
4 changes: 4 additions & 0 deletions crates/iota-sdk-transaction-builder/src/unresolved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -61,6 +63,7 @@ impl InputKind {
}

#[derive(Debug, Clone, derive_more::From)]
#[non_exhaustive]
pub enum Command {
MoveCall(MoveCall),
TransferObjects(TransferObjects),
Expand Down Expand Up @@ -231,6 +234,7 @@ impl Publish {
}

#[derive(Debug, Clone, Copy)]
#[non_exhaustive]
pub enum Argument {
Gas,
Input(InputId),
Expand Down
1 change: 1 addition & 0 deletions crates/iota-sdk-types/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading