Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ categories = ["cryptography::cryptocurrencies"]
edition = "2024"
license = "Apache-2.0"
repository = "https://github.com/AftermathFinance/aftermath-sdk-rust"
rust-version = "1.88"
rust-version = "1.92"

[workspace.lints.clippy]
double_parens = "allow"
Expand Down
7 changes: 2 additions & 5 deletions crates/af-iperps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ graphql = [
"dep:sui-gql-schema",
"sui-gql-schema/build",
]
stop-orders = ["dep:fastcrypto"]
stop-orders = []

[dependencies]
# Public dependencies; a SemVer-breaking bump in one of these must come with a SemVer-breaking bump
Expand All @@ -46,7 +46,7 @@ num_enum = { version = "0.7", public = true }
strum = { version = "0.28", public = true, features = ["derive"] }
sui-framework-sdk = { version = "0.17.3", public = true, path = "../sui-framework-sdk" }
sui-gql-client = { version = "0.26", public = true, default-features = false, optional = true, path = "../sui-gql-client" }
sui-sdk-types = { version = "0.3", public = true }
sui-sdk-types = { version = "0.3", public = true, features = ["hash"] }

# TODO: remove this after using Rust's `Option` (see TODO in `lib.rs`)
move-stdlib-sdk = { version = "0.16.3", public = true, path = "../move-stdlib-sdk" }
Expand All @@ -69,9 +69,6 @@ enum-as-inner = { version = "0.7", optional = true }
futures = { version = "0.3", optional = true }
graphql-extract = { version = "0.0.12", path = "../graphql-extract", optional = true }

# Stop Orders
fastcrypto = { version = "0.1", optional = true }

[build-dependencies.sui-gql-schema]
default-features = false
features = ["build"]
Expand Down
4 changes: 2 additions & 2 deletions crates/af-iperps/src/math.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,13 @@ mod tests {
ifixed = 0.1.try_into().unwrap();
insta::assert_snapshot!(ifixed, @"0.1");
let ok = units.ifixed_to_price(ifixed).unwrap();
assert_eq!(ok, 0_100000000);
assert_eq!(ok, 100_000_000);

// `ifixed_to_price` truncates
ifixed = 0.15.try_into().unwrap();
insta::assert_snapshot!(ifixed, @"0.15");
let ok = units.ifixed_to_price(ifixed).unwrap();
assert_eq!(ok, 0_150000000);
assert_eq!(ok, 150_000_000);

ifixed = units.price_to_ifixed(0);
insta::assert_snapshot!(ifixed, @"0.0");
Expand Down
4 changes: 2 additions & 2 deletions crates/af-iperps/src/stop_order_helpers.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! Helpers for stop orders.

use af_utilities::IFixed;
use fastcrypto::hash::{Blake2b256, HashFunction};
use serde::{Deserialize, Serialize};
use sui_framework_sdk::object::ID;
use sui_sdk_types::hash::Hasher;

use crate::order_helpers::{OrderType, Side};

Expand All @@ -15,7 +15,7 @@ pub trait StopOrderTicketDetails {
{
let mut bytes = sui_sdk_types::bcs::ToBcs::to_bcs(&self)?;
bytes.extend(salt);
Ok(Blake2b256::digest(bytes).to_vec())
Ok(Hasher::digest(bytes).into_inner().to_vec())
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/af-move-type/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ derive_more = { version = "2", features = ["deref", "deref_mut", "from", "into
serde = "1"
serde_with = "3"
sui-sdk-types = { version = "0.3", public = true }
tabled = "0.20"
tabled = "0.21"
thiserror = "2"
2 changes: 1 addition & 1 deletion crates/af-move-type/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ and defining a pretty `Display`.

For Move structs (objects), `MoveStruct` should be used as it has an
associated `MoveStructTag`. The
[`MoveStruct`](af_move_type_derive::MoveStruct) derive macro is exported for automatically
`MoveStruct` derive macro is exported for automatically
creating a `MoveStructTag` implementation from normal Rust struct declarations.

A specific instance of a Move type is represented by `MoveInstance`.
Expand Down
9 changes: 7 additions & 2 deletions crates/af-ptbuilder/examples/builder_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ pub struct Payload {
#[derive(serde::Deserialize, serde::Serialize)]
struct Base64BcsPtb(#[serde_as(as = "Base64")] Vec<u8>);

/// For [`TryFromInto`]
/// For [`TryFromInto`], which requires an infallible `From` in this direction; BCS
/// serialization of a valid [`ProgrammableTransaction`] cannot fail.
#[allow(clippy::fallible_impl_from)]
impl From<ProgrammableTransactionBuilder> for Base64BcsPtb {
fn from(value: ProgrammableTransactionBuilder) -> Self {
let pt = ProgrammableTransaction::from(value);
Self(pt.to_bcs().unwrap())
Self(
pt.to_bcs()
.expect("BCS serialization of a programmable transaction cannot fail"),
)
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/af-sui-pkg-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ workspace = true
# https://rust-lang.github.io/rfcs/3516-public-private-dependencies.html
af-move-type = { version = "0.19.1", public = true, path = "../af-move-type" }
af-sui-types = { version = "0.18.0", public = true, features = ["u256"], path = "../af-sui-types" }
tabled = { version = "0.20", public = true }
tabled = { version = "0.21", public = true }
# Because of `tabled`
papergrid = { version = "0.17", public = true }
papergrid = { version = "0.18", public = true }
sui-sdk-types = { version = "0.3", public = true }

derive-new = "0.7.0"
Expand Down
8 changes: 4 additions & 4 deletions crates/af-sui-pkg-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ source code and implementing relevant `af_move_type` traits.
Automates the conversion of Sui Move types to Rust. The goal is to extract as much information
as possible at compile time about the Move types of a Sui package, generating equivalent Rust
types that:
- are [BCS]-compatible with their on-chain counterparts, so that their contents can be
- are `BCS`-compatible with their on-chain counterparts, so that their contents can be
deserialized from BCS bytes returned by RPCs
- embed type information based on their location (path) in a Move package + type parameters, so
that a corresponding type tag can be easily constructed with just the missing information
Expand All @@ -15,7 +15,7 @@ types that:

See also:
- `af_move_type`
- [`af_move_type_derive`] for how the type tag information for a struct is derived from its
- `af_move_type_derive` for how the type tag information for a struct is derived from its
declaration

<div class="warning">
Expand All @@ -30,13 +30,13 @@ Rust types. Some additional steps may be necessary however:
- Struct fields should be Rust types. That means they must be in scope. Special Move types like
`address`, `vector<T>` and `u256` are automatically converted to equivalent Rust types.

The only requirement for a struct field type is that it has the same [BCS] representation as
The only requirement for a struct field type is that it has the same `BCS` representation as
the Move type for that field. You may use that to your advantage. For instance, if a
`u256` is supposed to be interpreted as a fixed point number, you may define a custom
`FixedP(U256)` type that (de)serializes to/from `u256` bytes but behaves like a fixed point
number.

Additionally, you may add any outter [attributes], e.g. docs, to structs and their fields.
Additionally, you may add any outter `attributes`, e.g. docs, to structs and their fields.

All `MoveStruct`s created by this macro will have a pretty `Display`
using `tabled` as a backend.
Expand Down
8 changes: 4 additions & 4 deletions crates/af-sui-types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

<!-- cargo-rdme start -->

Aftermath's extensions to [`sui_sdk_types`].
Aftermath's extensions to `sui_sdk_types`.

Includes some types and constants from the original [`sui_types`] and [`move_core_types`] that
Includes some types and constants from the original `sui_types` and `move_core_types` that
are not present in `sui_sdk_types`. This crate also re-exports a lot of the types in
`sui_sdk_types`.

This crate was originally conceived with the following objectives:
- [`serde`] compatibility with the full Sui checkpoint data
- `serde` compatibility with the full Sui checkpoint data
- avoiding dynamic error types so that callers could match against errors and react accordingly
- using a minimal set of dependencies
- [SemVer](https://doc.rust-lang.org/cargo/reference/semver.html) compatibility

<div class="warning">

The long-term plan is to deprecate most of this in favor of [`sui_sdk_types`]. However, there
The long-term plan is to deprecate most of this in favor of `sui_sdk_types`. However, there
are some types in that crate that don't expose all of the attributes/methods we need yet.

</div>
Expand Down
3 changes: 1 addition & 2 deletions crates/af-sui-types/src/sui/move_object_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ enum MoveObjectType_ {

#[cfg(test)]
mod tests {
use super::*;
use crate::CLOCK_ID;

#[test]
Expand All @@ -268,7 +267,7 @@ mod tests {
fn sui_address_display_pads() {
assert_eq!(
"0x0000000000000000000000000000000000000000000000000000000000000006",
format!("{}", Address::from(CLOCK_ID))
format!("{}", CLOCK_ID)
);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/graphql-extract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ workspace = true
derive-syn-parse = "0.2"
proc-macro2 = "1"
quote = "1"
syn = { version = "2", features = ["full"] }
syn = { version = "3", features = ["full"] }

[dev-dependencies]
insta = "1"
Expand Down
6 changes: 3 additions & 3 deletions crates/graphql-extract/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Macro to extract data from deeply nested types representing GraphQL results

# Suggested workflow

1. Generate query types using [cynic] and its [generator]
1. Use [insta] to define an inline snapshot test so that the query string is visible in the
1. Generate query types using `cynic` and its `generator`
1. Use `insta` to define an inline snapshot test so that the query string is visible in the
module that defines the query types
1. Define an `extract` function that takes the root query type and returns the data of interest
1. Inside `extract`, use `extract!` as `extract!(data => { ... })`
Expand All @@ -16,7 +16,7 @@ Macro to extract data from deeply nested types representing GraphQL results

# Examples

The following omits the `derive`s for [cynic] traits that are usually implemented for GraphQL
The following omits the `derive`s for `cynic` traits that are usually implemented for GraphQL
queries. This is so that we can focus on the nesting of the structures and how the macro helps
to 'extract' the leaves.

Expand Down
2 changes: 1 addition & 1 deletion crates/pyth-hermes-client/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- cargo-rdme start -->

Client for [Pyth Hermes] using [`reqwest`]. See `PythClient`.
Client for [Pyth Hermes] using `reqwest`. See `PythClient`.

[Pyth Hermes]: https://docs.pyth.network/price-feeds/how-pyth-works/hermes
[`reqwest`]: https://docs.rs/reqwest/latest/reqwest/
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-gql-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ clap = { version = "4", features = ["derive"] }
derive_more = { version = "2", features = ["display"] }
extension-traits = "2"
futures = { version = "0.3" }
itertools = { version = "0.14" }
itertools = { version = "0.15" }
tap = "1"
thiserror = "2"
trait-variant = "0.1"
Expand Down
10 changes: 5 additions & 5 deletions crates/sui-gql-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ interface for clients interacting with an RPC. See the `reqwest` feature for a p
implementation.

The queries inclued here (under feature `queries`) were constructed with the help of `cynic`s
[generator] and use the scalars defined in [`sui_gql_schema`].
`generator` and use the scalars defined in `sui_gql_schema`.

## Custom queries

Users building their own queries should first:
1. add [`sui_gql_schema`] as a build dependency
1. add `sui_gql_schema` as a build dependency
1. register its schema in a `build.rs` file;
1. import the `schema` module in any module defining new fragments

For steps 1 and 2, you can check this crate's `[build-dependencies]` and `build.rs` for an
example of how to do so. Read more about schema crates in <https://cynic-rs.dev/large-apis>.

Then, to create query structs, we recommend using the [generator] with Sui's GraphQL
Then, to create query structs, we recommend using the `generator` with Sui's GraphQL
[schema][sui_schema] and to try reusing the scalars defined in `scalars`
as those automatically convert opaque types to more useful ones like [`af_sui_types`].
as those automatically convert opaque types to more useful ones like `af_sui_types`.

## Features

Expand All @@ -32,7 +32,7 @@ as those automatically convert opaque types to more useful ones like [`af_sui_ty
- `queries`: enables the `queries` submodule with pre-made queries
- `reqwest`: enables the `reqwest` submodule with an implementation of
`GraphQlClient`
- `scalars`: re-exports the `scalars` module of [`sui_gql_schema`]
- `scalars`: re-exports the `scalars` module of `sui_gql_schema`

## Handy links:

Expand Down
2 changes: 1 addition & 1 deletion crates/sui-gql-client/src/queries/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ fn gql_output() {
use cynic::QueryBuilder as _;

let vars = Variables {
address: Address::new(rand::random()).into(),
address: Address::new(rand::random()),
first: None,
after: None,
};
Expand Down
6 changes: 3 additions & 3 deletions crates/sui-jsonrpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ bs58 = "0.5"
colored = "3"
derive_more = { version = "2", features = ["from"] }
enum_dispatch = "0.3"
itertools = "0.14"
json_to_table = "0.12"
itertools = "0.15"
json_to_table = "0.13"
regex = "1"
serde_with = { version = "3", features = ["base64"] }
tabled = "0.20"
tabled = "0.21"
thiserror = "2"

async-stream = { version = "0.3", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-jsonrpc/src/msgs/sui_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ impl Display for SuiParsedData {
match self {
SuiParsedData::MoveObject(o) => {
writeln!(writer, "{}: {}", "type".bold().bright_black(), o.type_)?;
write!(writer, "{}", &o.fields)?;
write!(writer, "{}", o.fields)?;
}
SuiParsedData::Package(p) => {
write!(
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-jsonrpc/src/msgs/sui_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ impl PartialEq for SuiTransactionBlockResponse {

impl Display for SuiTransactionBlockResponse {
fn fmt(&self, writer: &mut Formatter<'_>) -> fmt::Result {
writeln!(writer, "Transaction Digest: {}", &self.digest)?;
writeln!(writer, "Transaction Digest: {}", self.digest)?;

if let Some(t) = &self.transaction {
writeln!(writer, "{}", t)?;
Expand Down
Loading