Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename #1

Merged
merged 6 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .github/workflows/rustdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: rustdoc

on:
push:
branches: [ master ]
branches: [master]
workflow_dispatch:

env:
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ all:: ci

.PHONY: check-features
check-features:
$(MAKE) -C crates/sui-sdk check-features
$(MAKE) -C crates/iota-rust-sdk check-features

.PHONY: check-fmt
check-fmt:
Expand All @@ -21,7 +21,7 @@ test:

.PHONY: wasm
wasm:
$(MAKE) -C crates/sui-sdk wasm
$(MAKE) -C crates/iota-rust-sdk wasm

.PHONY: doc
doc:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Sui Sdk
# Iota Sdk

[![Documentation (master)](https://img.shields.io/badge/docs-master-59f)](https://mystenlabs.github.io/sui-rust-sdk/sui_sdk/)
[![Documentation (master)](https://img.shields.io/badge/docs-master-59f)](https://github.com/iotaledger/iota-rust-sdk/iota_sdk/)

A WIP from-scratch rust sdk for the sui blockchain
A WIP from-scratch rust sdk for the iota blockchain
38 changes: 23 additions & 15 deletions crates/sui-sdk/Cargo.toml → crates/iota-rust-sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
[package]
name = "sui-sdk"
name = "iota-rust-sdk"
version = "0.0.0"
authors = ["Brandon Williams <[email protected]>"]
license = "Apache-2.0"
authors = ["IOTA Foundation <[email protected]>"]
edition = "2021"
license = "Apache-2.0"
publish = false
readme = "README.md"
description = "Sdk for the Sui Blockchain"
description = "Sdk for the Iota Blockchain"

[package.metadata.docs.rs]
# To build locally:
# RUSTDOCFLAGS="--cfg=doc_cfg -Zunstable-options --generate-link-to-definition" RUSTC_BOOTSTRAP=1 cargo doc --all-features --no-deps --open
all-features = true
rustdoc-args = [
# Enable doc_cfg showing the required features.
"--cfg=doc_cfg",
# Enable doc_cfg showing the required features.
"--cfg=doc_cfg",

# Generate links to definition in rustdoc source code pages
# https://github.com/rust-lang/rust/pull/84176
"-Zunstable-options", "--generate-link-to-definition"
# Generate links to definition in rustdoc source code pages
# https://github.com/rust-lang/rust/pull/84176
"-Zunstable-options",
"--generate-link-to-definition",
]

[features]
default = []
serde = ["dep:serde", "dep:serde_derive", "dep:serde_with", "dep:bcs", "dep:serde_json", "roaring/std"]
serde = [
"dep:serde",
"dep:serde_derive",
"dep:serde_with",
"dep:bcs",
"dep:serde_json",
"roaring/std",
]
schemars = ["serde", "dep:schemars", "dep:serde_json"]
rand = ["dep:rand_core"]
hash = ["dep:blake2"]

[dependencies]
base64ct = { version = "1.6.0", features = ["alloc"] }
bnum = "0.11.0"
bs58 = "0.5.1"
hex = "0.4.3"
roaring = { version = "0.10.6", default-features = false }
bnum = "0.11.0"
winnow = "0.6.18"

# Serialization and Deserialization support
bcs = { version = "0.1.6", optional = true }
serde = { version = "1.0.190", optional = true }
serde_derive = { version = "1.0.190", optional = true }
serde_with = { version = "3.9", default-features = false, features = ["alloc"], optional = true }
bcs = { version = "0.1.6", optional = true }
serde_json = { version = "1.0.114", optional = true }
serde_with = { version = "3.9", default-features = false, features = ["alloc"], optional = true }

# JsonSchema definitions for types, useful for generating an OpenAPI Specificaiton.
schemars = { version = "0.8.21", optional = true }
Expand All @@ -54,10 +62,10 @@ blake2 = { version = "0.10.6", optional = true }

[dev-dependencies]
bcs = "0.1.6"
serde_json = "1.0.114"
num-bigint = "0.4.4"
jsonschema = { version = "0.18", default-features = false }
num-bigint = "0.4.4"
paste = "1.0.15"
serde_json = "1.0.114"

# proptest support in tests
#
Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions crates/sui-sdk/src/hash.rs → crates/iota-rust-sdk/src/hash.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::types::Address;
use crate::types::Digest;

use blake2::Digest as DigestTrait;

use crate::types::{Address, Digest};

type Blake2b256 = blake2::Blake2b<blake2::digest::consts::U32>;

#[derive(Debug, Default)]
Expand Down Expand Up @@ -226,9 +225,9 @@ mod type_digest {
}
}

/// A 1-byte domain separator for hashing Object ID in Sui. It is starting from 0xf0
/// to ensure no hashing collision for any ObjectId vs Address which is derived
/// as the hash of `flag || pubkey`.
/// A 1-byte domain separator for hashing Object ID in Iota. It is starting from
/// 0xf0 to ensure no hashing collision for any ObjectId vs Address which is
/// derived as the hash of `flag || pubkey`.
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
#[cfg_attr(test, derive(test_strategy::Arbitrary))]
#[repr(u8)]
Expand All @@ -241,7 +240,8 @@ enum HashingIntent {
impl crate::types::ObjectId {
/// Create an ObjectId from `TransactionDigest` and `count`.
///
/// `count` is the number of objects that have been created during a transactions.
/// `count` is the number of objects that have been created during a
/// transactions.
pub fn derive_id(digest: crate::types::TransactionDigest, count: u64) -> Self {
let mut hasher = Hasher::new();
hasher.update([HashingIntent::RegularObjectId as u8]);
Expand Down Expand Up @@ -280,13 +280,13 @@ impl crate::types::ObjectId {

#[cfg(test)]
mod test {
use super::HashingIntent;
use crate::types::SignatureScheme;
use test_strategy::proptest;

#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

use super::HashingIntent;
use crate::types::SignatureScheme;

impl HashingIntent {
fn from_byte(byte: u8) -> Result<Self, u8> {
match byte {
Expand Down
21 changes: 8 additions & 13 deletions crates/sui-sdk/src/lib.rs → crates/iota-rust-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,12 @@ pub mod hash;

#[cfg(feature = "serde")]
mod _serde {
use base64ct::Base64;
use base64ct::Encoding;
use serde::Deserialize;
use serde::Deserializer;
use serde::Serialize;
use serde::Serializer;
use serde_with::Bytes;
use serde_with::DeserializeAs;
use serde_with::SerializeAs;
use std::borrow::Cow;

use base64ct::{Base64, Encoding};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_with::{Bytes, DeserializeAs, SerializeAs};

pub(crate) type ReadableDisplay =
::serde_with::As<::serde_with::IfIsHumanReadable<::serde_with::DisplayFromStr>>;

Expand Down Expand Up @@ -124,10 +119,10 @@ mod _serde {

#[cfg(feature = "schemars")]
mod _schemars {
use schemars::schema::InstanceType;
use schemars::schema::Metadata;
use schemars::schema::SchemaObject;
use schemars::JsonSchema;
use schemars::{
schema::{InstanceType, Metadata, SchemaObject},
JsonSchema,
};

pub(crate) struct U64;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Address {
<[u8; Self::LENGTH] as hex::FromHex>::from_hex(hex)
}
.map(Self)
//TODO fix error to contain hex parse error
// TODO fix error to contain hex parse error
.map_err(|_| AddressParseError)
}

Expand Down Expand Up @@ -201,16 +201,13 @@ impl schemars::JsonSchema for Address {
}

fn json_schema(_: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
use schemars::schema::InstanceType;
use schemars::schema::Metadata;
use schemars::schema::SchemaObject;
use schemars::schema::StringValidation;
use schemars::schema::{InstanceType, Metadata, SchemaObject, StringValidation};

let hex_length = Address::LENGTH * 2;
SchemaObject {
metadata: Some(Box::new(Metadata {
title: Some(Self::schema_name()),
description: Some("A 32-byte Sui address, encoded as a hex string.".to_owned()),
description: Some("A 32-byte Iota address, encoded as a hex string.".to_owned()),
examples: vec![serde_json::to_value(Address::TWO).unwrap()],
..Default::default()
})),
Expand All @@ -229,12 +226,12 @@ impl schemars::JsonSchema for Address {

#[cfg(test)]
mod test {
use super::*;
use test_strategy::proptest;

#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

use super::*;

#[test]
fn hex_parsing() {
let actual = Address::from_hex("0x2").unwrap();
Expand Down
Loading
Loading