Skip to content

Commit

Permalink
sui-sdk-types: flatten the types module
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed Dec 20, 2024
1 parent aa546ca commit dc54c46
Show file tree
Hide file tree
Showing 61 changed files with 412 additions and 417 deletions.
12 changes: 6 additions & 6 deletions crates/sui-crypto/src/ed25519.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::SignatureError;
use crate::Signer;
use crate::Verifier;
use sui_sdk_types::types::Ed25519PublicKey;
use sui_sdk_types::types::Ed25519Signature;
use sui_sdk_types::types::SignatureScheme;
use sui_sdk_types::types::SimpleSignature;
use sui_sdk_types::types::UserSignature;
use sui_sdk_types::Ed25519PublicKey;
use sui_sdk_types::Ed25519Signature;
use sui_sdk_types::SignatureScheme;
use sui_sdk_types::SimpleSignature;
use sui_sdk_types::UserSignature;

pub struct Ed25519PrivateKey(ed25519_dalek::SigningKey);

Expand Down Expand Up @@ -269,7 +269,7 @@ mod test {
use super::*;
use crate::SuiSigner;
use crate::SuiVerifier;
use sui_sdk_types::types::PersonalMessage;
use sui_sdk_types::PersonalMessage;
use test_strategy::proptest;

#[cfg(target_arch = "wasm32")]
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-crypto/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#![cfg_attr(doc_cfg, feature(doc_cfg))]

use sui_sdk_types::types::PersonalMessage;
use sui_sdk_types::types::Transaction;
use sui_sdk_types::types::UserSignature;
use sui_sdk_types::PersonalMessage;
use sui_sdk_types::Transaction;
use sui_sdk_types::UserSignature;

pub use signature::Error as SignatureError;
pub use signature::Signer;
Expand Down
16 changes: 8 additions & 8 deletions crates/sui-crypto/src/multisig.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::SignatureError;
use crate::Verifier;
use sui_sdk_types::types::MultisigAggregatedSignature;
use sui_sdk_types::types::MultisigCommittee;
use sui_sdk_types::types::MultisigMemberPublicKey;
use sui_sdk_types::types::MultisigMemberSignature;
use sui_sdk_types::types::UserSignature;
use sui_sdk_types::MultisigAggregatedSignature;
use sui_sdk_types::MultisigCommittee;
use sui_sdk_types::MultisigMemberPublicKey;
use sui_sdk_types::MultisigMemberSignature;
use sui_sdk_types::UserSignature;

#[derive(Default)]
pub struct MultisigVerifier {
Expand Down Expand Up @@ -267,7 +267,7 @@ pub struct MultisigAggregator {
impl MultisigAggregator {
pub fn new_with_transaction(
committee: MultisigCommittee,
transaction: &sui_sdk_types::types::Transaction,
transaction: &sui_sdk_types::Transaction,
) -> Self {
Self {
committee,
Expand All @@ -280,7 +280,7 @@ impl MultisigAggregator {

pub fn new_with_message(
committee: MultisigCommittee,
message: &sui_sdk_types::types::PersonalMessage<'_>,
message: &sui_sdk_types::PersonalMessage<'_>,
) -> Self {
Self {
committee,
Expand Down Expand Up @@ -360,7 +360,7 @@ impl MultisigAggregator {
fn multisig_pubkey_and_signature_from_user_signature(
signature: UserSignature,
) -> Result<(MultisigMemberPublicKey, MultisigMemberSignature), SignatureError> {
use sui_sdk_types::types::SimpleSignature;
use sui_sdk_types::SimpleSignature;
match signature {
UserSignature::Simple(SimpleSignature::Ed25519 {
signature,
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-crypto/src/passkey.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::secp256r1::Secp256r1VerifyingKey;
use crate::SignatureError;
use signature::Verifier;
use sui_sdk_types::types::PasskeyAuthenticator;
use sui_sdk_types::types::SimpleSignature;
use sui_sdk_types::types::UserSignature;
use sui_sdk_types::PasskeyAuthenticator;
use sui_sdk_types::SimpleSignature;
use sui_sdk_types::UserSignature;

#[derive(Default, Clone, Debug)]
pub struct PasskeyVerifier {}
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Verifier<UserSignature> for PasskeyVerifier {
mod test {
use super::*;
use crate::SuiVerifier;
use sui_sdk_types::types::Transaction;
use sui_sdk_types::Transaction;

#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
Expand Down
12 changes: 6 additions & 6 deletions crates/sui-crypto/src/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use k256::ecdsa::VerifyingKey;
use k256::elliptic_curve::group::GroupEncoding;
use signature::Signer;
use signature::Verifier;
use sui_sdk_types::types::Secp256k1PublicKey;
use sui_sdk_types::types::Secp256k1Signature;
use sui_sdk_types::types::SignatureScheme;
use sui_sdk_types::types::SimpleSignature;
use sui_sdk_types::types::UserSignature;
use sui_sdk_types::Secp256k1PublicKey;
use sui_sdk_types::Secp256k1Signature;
use sui_sdk_types::SignatureScheme;
use sui_sdk_types::SimpleSignature;
use sui_sdk_types::UserSignature;

pub struct Secp256k1PrivateKey(SigningKey);

Expand Down Expand Up @@ -271,7 +271,7 @@ mod test {
use super::*;
use crate::SuiSigner;
use crate::SuiVerifier;
use sui_sdk_types::types::PersonalMessage;
use sui_sdk_types::PersonalMessage;
use test_strategy::proptest;

#[cfg(target_arch = "wasm32")]
Expand Down
12 changes: 6 additions & 6 deletions crates/sui-crypto/src/secp256r1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use p256::ecdsa::VerifyingKey;
use p256::elliptic_curve::group::GroupEncoding;
use signature::Signer;
use signature::Verifier;
use sui_sdk_types::types::Secp256r1PublicKey;
use sui_sdk_types::types::Secp256r1Signature;
use sui_sdk_types::types::SignatureScheme;
use sui_sdk_types::types::SimpleSignature;
use sui_sdk_types::types::UserSignature;
use sui_sdk_types::Secp256r1PublicKey;
use sui_sdk_types::Secp256r1Signature;
use sui_sdk_types::SignatureScheme;
use sui_sdk_types::SimpleSignature;
use sui_sdk_types::UserSignature;

pub struct Secp256r1PrivateKey(SigningKey);

Expand Down Expand Up @@ -271,7 +271,7 @@ mod test {
use super::*;
use crate::SuiSigner;
use crate::SuiVerifier;
use sui_sdk_types::types::PersonalMessage;
use sui_sdk_types::PersonalMessage;
use test_strategy::proptest;

#[cfg(target_arch = "wasm32")]
Expand Down
12 changes: 6 additions & 6 deletions crates/sui-crypto/src/simple.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::SignatureError;
use signature::Verifier;
use sui_sdk_types::types::SimpleSignature;
use sui_sdk_types::types::UserSignature;
use sui_sdk_types::SimpleSignature;
use sui_sdk_types::UserSignature;

pub struct SimpleVerifier;

Expand Down Expand Up @@ -78,10 +78,10 @@ mod keypair {
use crate::SignatureError;
use signature::Signer;
use signature::Verifier;
use sui_sdk_types::types::MultisigMemberPublicKey;
use sui_sdk_types::types::SignatureScheme;
use sui_sdk_types::types::SimpleSignature;
use sui_sdk_types::types::UserSignature;
use sui_sdk_types::MultisigMemberPublicKey;
use sui_sdk_types::SignatureScheme;
use sui_sdk_types::SimpleSignature;
use sui_sdk_types::UserSignature;

pub struct SimpleKeypair {
inner: InnerKeypair,
Expand Down
16 changes: 8 additions & 8 deletions crates/sui-crypto/src/zklogin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::collections::HashMap;
use crate::SignatureError;
use poseidon::POSEIDON;
use signature::Verifier;
use sui_sdk_types::types::Claim;
use sui_sdk_types::types::Jwk;
use sui_sdk_types::types::JwkId;
use sui_sdk_types::types::UserSignature;
use sui_sdk_types::types::ZkLoginAuthenticator;
use sui_sdk_types::types::ZkLoginInputs;
use sui_sdk_types::Claim;
use sui_sdk_types::Jwk;
use sui_sdk_types::JwkId;
use sui_sdk_types::UserSignature;
use sui_sdk_types::ZkLoginAuthenticator;
use sui_sdk_types::ZkLoginInputs;

mod poseidon;
mod verify;
Expand Down Expand Up @@ -245,10 +245,10 @@ fn verify_extended_claim(claim: &Claim, expected_key: &str) -> Result<String, Si

pub(crate) fn zklogin_identifier_from_inputs(
inputs: &ZkLoginInputs,
) -> Result<sui_sdk_types::types::ZkLoginPublicIdentifier, SignatureError> {
) -> Result<sui_sdk_types::ZkLoginPublicIdentifier, SignatureError> {
const ISS: &str = "iss";

let iss = verify_extended_claim(&inputs.iss_base64_details, ISS)?;
sui_sdk_types::types::ZkLoginPublicIdentifier::new(iss, inputs.address_seed.clone())
sui_sdk_types::ZkLoginPublicIdentifier::new(iss, inputs.address_seed.clone())
.ok_or_else(|| SignatureError::from_source("invalid iss"))
}
2 changes: 1 addition & 1 deletion crates/sui-crypto/src/zklogin/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use signature::Signer;
use sui_sdk_types::types::PersonalMessage;
use sui_sdk_types::PersonalMessage;

use crate::ed25519::Ed25519PrivateKey;
use crate::SuiVerifier;
Expand Down
22 changes: 11 additions & 11 deletions crates/sui-crypto/src/zklogin/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ use ark_bn254::G2Projective;
use ark_ff::PrimeField;
use ark_groth16::PreparedVerifyingKey;
use ark_groth16::Proof;
use sui_sdk_types::types::Bn254FieldElement;
use sui_sdk_types::types::CircomG1;
use sui_sdk_types::types::CircomG2;
use sui_sdk_types::types::Ed25519PublicKey;
use sui_sdk_types::types::Jwk;
use sui_sdk_types::types::Secp256k1PublicKey;
use sui_sdk_types::types::Secp256r1PublicKey;
use sui_sdk_types::types::SimpleSignature;
use sui_sdk_types::types::ZkLoginInputs;
use sui_sdk_types::types::ZkLoginProof;
use sui_sdk_types::Bn254FieldElement;
use sui_sdk_types::CircomG1;
use sui_sdk_types::CircomG2;
use sui_sdk_types::Ed25519PublicKey;
use sui_sdk_types::Jwk;
use sui_sdk_types::Secp256k1PublicKey;
use sui_sdk_types::Secp256r1PublicKey;
use sui_sdk_types::SimpleSignature;
use sui_sdk_types::ZkLoginInputs;
use sui_sdk_types::ZkLoginProof;

use super::POSEIDON;

Expand Down Expand Up @@ -522,7 +522,7 @@ pub(crate) fn gen_address_seed_with_salt_hash(
#[cfg(test)]
mod test {
use super::*;
use sui_sdk_types::types::Ed25519Signature;
use sui_sdk_types::Ed25519Signature;

#[cfg(test)]
#[cfg(target_arch = "wasm32")]
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-graphql-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The client provides an API to request gas from the faucet. The `request_and_wait
### Example for standard devnet/testnet/local networks.
```rust, no_run
use sui_graphql_client::faucet::FaucetClient;
use sui_types::types::Address;
use sui_types::Address;
use anyhow::Result;
use std::str::FromStr;
Expand Down Expand Up @@ -70,7 +70,7 @@ async fn main() -> Result<()> {
Note that this [`FaucetClient`] is explicitly designed to work with two endpoints: `v1/gas`, and `v1/status`. When passing in the custom faucet URL, skip the final endpoint and only pass in the top-level url (e.g., `https://faucet.devnet.sui.io`).
```rust, no_run
use sui_graphql_client::faucet::FaucetClient;
use sui_types::types::Address;
use sui_types::Address;
use anyhow::Result;
use std::str::FromStr;
Expand Down Expand Up @@ -155,7 +155,7 @@ use sui_graphql_client::{
query_types::{schema, BigInt},
Client,
};
use sui_types::types::Address;
use sui_types::Address;
// The data returned by the custom query.
#[derive(cynic::QueryFragment, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-graphql-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use std::num::TryFromIntError;

use cynic::GraphQlError;

use sui_types::types::AddressParseError;
use sui_types::types::DigestParseError;
use sui_types::types::TypeParseError;
use sui_types::AddressParseError;
use sui_types::DigestParseError;
use sui_types::TypeParseError;

type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;

Expand Down
6 changes: 3 additions & 3 deletions crates/sui-graphql-client/src/faucet.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use sui_types::types::Address;
use sui_types::types::ObjectId;
use sui_types::types::TransactionDigest;
use sui_types::Address;
use sui_types::ObjectId;
use sui_types::TransactionDigest;

use anyhow::anyhow;
use anyhow::bail;
Expand Down
38 changes: 19 additions & 19 deletions crates/sui-graphql-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ use query_types::TransactionsFilter;
use query_types::Validator;
use streams::stream_paginated_query;

use sui_types::types::framework::Coin;
use sui_types::types::Address;
use sui_types::types::CheckpointDigest;
use sui_types::types::CheckpointSequenceNumber;
use sui_types::types::CheckpointSummary;
use sui_types::types::Event;
use sui_types::types::MovePackage;
use sui_types::types::Object;
use sui_types::types::SignedTransaction;
use sui_types::types::Transaction;
use sui_types::types::TransactionDigest;
use sui_types::types::TransactionEffects;
use sui_types::types::TransactionKind;
use sui_types::types::TypeTag;
use sui_types::types::UserSignature;
use sui_types::framework::Coin;
use sui_types::Address;
use sui_types::CheckpointDigest;
use sui_types::CheckpointSequenceNumber;
use sui_types::CheckpointSummary;
use sui_types::Event;
use sui_types::MovePackage;
use sui_types::Object;
use sui_types::SignedTransaction;
use sui_types::Transaction;
use sui_types::TransactionDigest;
use sui_types::TransactionEffects;
use sui_types::TransactionKind;
use sui_types::TypeTag;
use sui_types::UserSignature;

use base64ct::Encoding;
use cynic::serde;
Expand Down Expand Up @@ -1011,7 +1011,7 @@ impl Client {
.transpose()?;

let object = bcs
.map(|b| bcs::from_bytes::<sui_types::types::Object>(&b))
.map(|b| bcs::from_bytes::<sui_types::Object>(&b))
.transpose()?;

Ok(object)
Expand Down Expand Up @@ -1070,7 +1070,7 @@ impl Client {
.collect::<Result<Vec<_>, base64ct::Error>>()?;
let objects = bcs
.iter()
.map(|b| bcs::from_bytes::<sui_types::types::Object>(b))
.map(|b| bcs::from_bytes::<sui_types::Object>(b))
.collect::<Result<Vec<_>, bcs::Error>>()?;

Ok(Page::new(page_info, objects))
Expand Down Expand Up @@ -1720,8 +1720,8 @@ impl Client {
mod tests {
use base64ct::Encoding;
use futures::StreamExt;
use sui_types::types::Ed25519PublicKey;
use sui_types::types::TypeTag;
use sui_types::Ed25519PublicKey;
use sui_types::TypeTag;

use crate::faucet::FaucetClient;
use crate::BcsName;
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-graphql-client/src/query_types/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use base64ct::Encoding;
use sui_types::types::CheckpointSummary;
use sui_types::CheckpointSummary;

use crate::error;
use crate::error::Error;
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-graphql-client/src/query_types/dry_run.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use sui_types::types::ObjectReference;
use sui_types::ObjectReference;

use crate::query_types::schema;
use crate::query_types::Address;
Expand Down
Loading

0 comments on commit dc54c46

Please sign in to comment.