Skip to content

Commit 5dff8c7

Browse files
committed
refactor: replace AnyCodable with SuiJSON for improved type safety and concurrency support
- Removed AnyCodable references from various structs and protocols, replacing them with SuiJSON to enhance type safety. - Updated Package.swift and Package.resolved to remove AnyCodable dependency. - Refactored RPC-related structures and methods to utilize SuiJSON for flexible JSON representation. - Deleted SuiRequestS6C as part of the transition to a more streamlined request handling approach. - Ensured all relevant tests are updated to reflect these changes, maintaining functionality and reliability.
1 parent 0b13a74 commit 5dff8c7

26 files changed

Lines changed: 256 additions & 235 deletions

Package.resolved

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ let package = Package(
1515
.package(url: "https://github.com/pebble8888/ed25519swift.git", from: "1.2.7"),
1616
.package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "4.0.0"),
1717
.package(url: "https://github.com/tesseract-one/Blake2.swift.git", from: "0.2.0"),
18-
.package(url: "https://github.com/MarcoDotIO/AnyCodable", from: "1.0.0"),
1918
.package(url: "https://github.com/auth0/JWTDecode.swift", from: "3.1.0"),
2019
.package(url: "https://github.com/attaswift/BigInt.git", from: "5.3.0"),
2120
.package(url: "https://github.com/apollographql/apollo-ios.git", exact: "1.17.0"),
@@ -33,7 +32,6 @@ let package = Package(
3332
.product(name: "ed25519swift", package: "ed25519swift"),
3433
.product(name: "SwiftyJSON", package: "swiftyjson"),
3534
.product(name: "Blake2", package: "Blake2.swift"),
36-
.product(name: "AnyCodable", package: "AnyCodable"),
3735
.product(name: "JWTDecode", package: "JWTDecode.swift"),
3836
.product(name: "Apollo", package: "apollo-ios"),
3937
.product(name: "UncommonCrypto", package: "UncommonCrypto.swift"),

Sources/SuiKit/Protocols/BCS/EncodingProtocol.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import Foundation
2727
import UInt256
28-
@preconcurrency import AnyCodable
2928

3029
public protocol EncodingProtocol: EncodingContainer, Sendable { }
3130

Sources/SuiKit/Protocols/Sui/RPCErrorRequest.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
//
2525

2626
import Foundation
27-
@preconcurrency import AnyCodable
2827

2928
/// Protocol defining the requirements for an RPC (Remote Procedure Call) error request.
3029
/// Conforming types are expected to provide a method name and arguments for the RPC call
@@ -35,6 +34,6 @@ public protocol RPCErrorRequest: Sendable {
3534
var method: String { get set }
3635

3736
/// The list of arguments that were passed to the method during the call that resulted in an error.
38-
/// Using `AnyCodable` allows for a flexible array that can contain multiple types, as long as they conform to `Codable`.
39-
var args: [AnyCodable] { get set }
37+
/// Using `SuiJSON` allows for a flexible array that can contain multiple types, as long as they conform to `Codable`.
38+
var args: [SuiJSON] { get set }
4039
}

Sources/SuiKit/Types/Structs/GraphQL/GraphQLClient.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ internal struct GraphQLClient {
3535
/// - query: The query itself containing information such as user inputs parameters, the endpoint itself, and various other metadata for making the GraphQL client functional.
3636
/// - Returns: A GraphQLResult object of either T.Data type, or throws an error.
3737
internal static func fetchQuery<T: GraphQLQuery>(client: ApolloClient, query: T) async throws -> GraphQLResult<T.Data> {
38+
print("DEBUG::: MARCUS - QUERY - \(query.__variables)\n\n")
3839
return try await withCheckedThrowingContinuation { (con: CheckedContinuation<GraphQLResult<T.Data>, Error>) in
3940
_ = client.fetch(query: query) { @Sendable result in
4041
switch result {

Sources/SuiKit/Types/Structs/GraphQL/GraphQLSuiProvider.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
import Foundation
2727
import SwiftyJSON
28-
@preconcurrency import AnyCodable
2928
import Blake2
3029
import Apollo
3130
import ApolloAPI

Sources/SuiKit/Types/Structs/Kiosk/Client/KioskTransactionClient.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
//
2525

2626
import Foundation
27-
@preconcurrency import AnyCodable
2827

2928
/**
3029
* A helper for building transactions that involve kiosk.

Sources/SuiKit/Types/Structs/Kiosk/Types/KioskTypes/PurchaseOptions.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
//
2525

2626
import Foundation
27-
@preconcurrency import AnyCodable
2827

2928
public struct PurchaseOptions {
30-
public let extraArgs: [String: AnyCodable]?
29+
public let extraArgs: [String: SuiJSON]?
3130

32-
public init(extraArgs: [String: AnyCodable]? = nil) {
31+
public init(extraArgs: [String: SuiJSON]? = nil) {
3332
self.extraArgs = extraArgs
3433
}
3534
}

Sources/SuiKit/Types/Structs/Kiosk/Types/TransferPolicyTypes/RuleResolvingParams.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
//
2525

2626
import Foundation
27-
@preconcurrency import AnyCodable
2827

2928
/// The object a Rule resolving function accepts
3029
/// It can accept a set of fixed fields, that are part of every purchase flow as well any extra arguments to resolve custom policies!
@@ -41,5 +40,5 @@ public struct RuleResolvingParams {
4140
public let transferRequest: TransactionObjectArgument
4241
public let purchasedItem: TransactionObjectArgument
4342
public let packageId: String
44-
public let extraArgs: [String: AnyCodable]
43+
public let extraArgs: [String: SuiJSON]
4544
}

Sources/SuiKit/Types/Structs/Provider/Parameters/MoveEventField.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,21 @@
2424
//
2525

2626
import Foundation
27-
@preconcurrency import AnyCodable
2827

2928
/// Represents a field within a Move event, conforming to `Codable` to support encoding and decoding.
3029
public struct MoveEventField: Codable {
3130
/// A `String` representing the path of the event field.
3231
public var path: String
3332

34-
/// An `AnyCodable` object representing the value of the event field.
33+
/// An `SuiJSON` object representing the value of the event field.
3534
/// It's designed to allow encoding and decoding of any Codable value.
36-
public var value: AnyCodable
35+
public var value: SuiJSON
3736

3837
/// Initializes a new instance of `MoveEventField`.
3938
/// - Parameters:
4039
/// - path: A `String` representing the path of the event field.
41-
/// - value: An `AnyCodable` object representing the value of the event field.
42-
public init(path: String, value: AnyCodable) {
40+
/// - value: An `SuiJSON` object representing the value of the event field.
41+
public init(path: String, value: SuiJSON) {
4342
self.path = path
4443
self.value = value
4544
}

0 commit comments

Comments
 (0)