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

Allow to choose local or GH SPM release yttrium package #21

Merged
merged 6 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,6 @@
"version": "1.0.3"
}
},
{
"package": "swift-snapshot-testing",
"repositoryURL": "https://github.com/pointfreeco/swift-snapshot-testing",
"state": {
"branch": null,
"revision": "f29e2014f6230cf7d5138fc899da51c7f513d467",
"version": "1.10.0"
}
},
{
"package": "SwiftImageReadWrite",
"repositoryURL": "https://github.com/dagronf/SwiftImageReadWrite",
Expand Down
10 changes: 5 additions & 5 deletions Example/Shared/Signer/Signer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ final class Signer {

let userOpHash = try await client.sendTransaction(transaction)

Task {
let userOpReceipt = try await SmartAccount.instance.getClient().waitForUserOperationReceipt(userOperationHash: userOpHash)
guard let userOpReceiptSting = userOpReceipt.jsonString else { return }
AlertPresenter.present(message: userOpReceiptSting, type: .info)
}
// Task {
llbartekll marked this conversation as resolved.
Show resolved Hide resolved
// let userOpReceipt = try await SmartAccount.instance.getClient().waitForUserOperationReceipt(userOperationHash: userOpHash)
// guard let userOpReceiptSting = userOpReceipt.jsonString else { return }
// AlertPresenter.present(message: userOpReceiptSting, type: .info)
// }

return AnyCodable(userOpHash)

Expand Down
55 changes: 0 additions & 55 deletions Example/WalletApp/BusinessLayer/SmartAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,58 +174,3 @@ class SmartAccountSafe {
let chainId: Int
}
}


class AccountClientMock: YttriumWrapper.AccountClientProtocol {

var onSign: OnSign?

var chainId: Int

var ownerAddress: String

var entryPoint: String

private var config: Yttrium.Config

required init(ownerAddress: String, entryPoint: String, chainId: Int, config: Yttrium.Config, safe: Bool) {
self.ownerAddress = ownerAddress
self.entryPoint = entryPoint
self.chainId = chainId
self.config = config
}

func register(privateKey: String) {

}

// prepares UserOp
func sendTransaction(_ transaction: YttriumWrapper.Transaction) async throws -> String {
guard let onSign = onSign else {
fatalError("Error - onSign closure must be set before calling signMessage")
}
let _ = onSign("UserOp")
return "txHash"
}

func sendBatchTransaction(_ batch: [YttriumWrapper.Transaction]) async throws -> String {
return "userOpReceipt"
}

func getAddress() async throws -> String {
return "0xF4D7560648F1252FD7501863355AEaBfb9d3b7c3"
}

func getAccount() async throws -> Account {
let chain = try Blockchain(namespace: "eip155", reference: chainId)
let address = try await getAddress()
return try Account(blockchain: chain, accountAddress: address)
}

func signMessage(_ message: String) throws -> String {
guard let onSign = onSign else {
fatalError("Error - onSign closure must be set before calling signMessage")
}
return try! onSign(message).get()
}
}
49 changes: 34 additions & 15 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,38 @@

import PackageDescription

// Determine if Yttrium should be used in debug (local) mode
let yttriumDebug = false


// Define dependencies array
var dependencies: [Package.Dependency] = [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
.package(url: "https://github.com/WalletConnect/QRCode", from: "14.3.1"),
.package(name: "CoinbaseWalletSDK", url: "https://github.com/WalletConnect/wallet-mobile-sdk", from: "1.0.0"),
// .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", .upToNextMinor(from: "1.10.0")),
]
var yttriumTarget: Target!
// Conditionally add Yttrium dependency
if yttriumDebug {
var yttriumSwiftSettings: [SwiftSetting] = []
dependencies.append(.package(path: "../yttrium/crates/ffi/YttriumCore"))
yttriumSwiftSettings.append(.define("YTTRIUM_DEBUG"))
yttriumTarget = .target(
name: "YttriumWrapper",
dependencies: [.product(name: "YttriumCore", package: "YttriumCore")],
path: "Sources/YttriumWrapper",
swiftSettings: yttriumSwiftSettings
)
} else {
dependencies.append(.package(url: "https://github.com/reown-com/yttrium", .upToNextMinor(from: "0.0.11")))
yttriumTarget = .target(
name: "YttriumWrapper",
dependencies: [.product(name: "Yttrium", package: "yttrium")],
path: "Sources/YttriumWrapper"
)
}

let package = Package(
name: "WalletConnect",
platforms: [
Expand Down Expand Up @@ -47,14 +79,7 @@ let package = Package(
name: "YttriumWrapper",
targets: ["YttriumWrapper"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
.package(url: "https://github.com/WalletConnect/QRCode", from: "14.3.1"),
.package(name: "CoinbaseWalletSDK", url: "https://github.com/WalletConnect/wallet-mobile-sdk", from: "1.0.0"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", .upToNextMinor(from: "1.10.0")),
.package(path: "../yttrium")
// .package(url: "https://github.com/WalletConnect/yttrium", branch: "main")
],
dependencies: dependencies,
targets: [
.target(
name: "WalletConnectSign",
Expand Down Expand Up @@ -161,13 +186,7 @@ let package = Package(
name: "ReownAppKitBackport",
path: "Sources/ReownAppKitBackport"
),
.target(
name: "YttriumWrapper",
dependencies: [
.productItem(name: "Yttrium", package: "yttrium")
],
path: "Sources/YttriumWrapper"
),
yttriumTarget,
.testTarget(
name: "WalletConnectSignTests",
dependencies: ["WalletConnectSign", "WalletConnectUtils", "TestingUtils", "WalletConnectVerify"]),
Expand Down
4 changes: 4 additions & 0 deletions Sources/YttriumWrapper/YttriumWrapper.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import Foundation

#if YTTRIUM_DEBUG
@_exported import YttriumCore
#else
@_exported import Yttrium
#endif