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

🔄 synced file(s) with circlefin/modularwallets-ios-sdk-internal #8

Merged
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 CircleModularWalletsCore/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleShortVersionString</key>
<string>1.0.5</string>
<string>1.0.6</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleName</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Foundation
#if SWIFT_PACKAGE
extension Bundle {
public enum SDK {
public static let version = "1.0.5"
public static let version = "1.0.6"
}
}
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,22 @@ extension WebAuthnHandler: ASAuthorizationControllerDelegate {
// The attestationObject contains the user's new public key to store and use for subsequent sign-ins.
let attestationObjectData = asCredentialRegistration.rawAttestationObject
let clientDataJSON = asCredentialRegistration.rawClientDataJSON
var attachment: AuthenticatorAttachment = .platform
if #available(iOS 16.6, *) {
switch asCredentialRegistration.attachment {
case .platform:
attachment = .platform
case .crossPlatform:
attachment = .crossPlatform
@unknown default:
attachment = .platform
}
}

let credential = RegistrationCredential(
id: asCredentialRegistration.credentialID.base64URLEncodedString().asString(),
type: CredentialType.publicKey,
authenticatorAttachment: .platform,
authenticatorAttachment: attachment,
rawID: asCredentialRegistration.credentialID.base64URLEncodedString(),
response: AuthenticatorAttestationResponse(
rawClientDataJSON: clientDataJSON.bytes,
Expand All @@ -144,11 +155,22 @@ extension WebAuthnHandler: ASAuthorizationControllerDelegate {
let signature = asCredentialAssertion.signature
let clientDataJSON = asCredentialAssertion.rawClientDataJSON
let authenticatorData = asCredentialAssertion.rawAuthenticatorData
var attachment: AuthenticatorAttachment = .platform
if #available(iOS 16.6, *) {
switch asCredentialAssertion.attachment {
case .platform:
attachment = .platform
case .crossPlatform:
attachment = .crossPlatform
@unknown default:
attachment = .platform
}
}

let credential = AuthenticationCredential(
id: asCredentialAssertion.credentialID.base64URLEncodedString().asString(),
type: CredentialType.publicKey,
authenticatorAttachment: .platform,
authenticatorAttachment: attachment,
rawID: asCredentialAssertion.credentialID.base64URLEncodedString(),
response: AuthenticatorAssertionResponse(
clientDataJSON: clientDataJSON.bytes.base64URLEncodedString(),
Expand Down
12 changes: 6 additions & 6 deletions CircleModularWalletsCore/Sources/Models/Token.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public enum MainnetToken: String {
}

public var name: String {
return "\(Mainnet.chainId)_\(self.rawValue)"
return "Mainnet_\(self.rawValue)"
}
}

Expand Down Expand Up @@ -75,7 +75,7 @@ public enum PolygonToken: String {
}

public var name: String {
return "\(Polygon.chainId)_\(self.rawValue)"
return "Polygon_\(self.rawValue)"
}
}

Expand Down Expand Up @@ -106,7 +106,7 @@ public enum ArbitrumToken: String {
}

public var name: String {
return "\(Arbitrum.chainId)_\(self.rawValue)"
return "Arbitrum_\(self.rawValue)"
}
}

Expand All @@ -118,7 +118,7 @@ public enum SepoliaToken: String {
}

public var name: String {
return "\(Sepolia.chainId)_\(self.rawValue)"
return "Sepolia_\(self.rawValue)"
}
}

Expand All @@ -130,7 +130,7 @@ public enum PolygonAmoyToken: String {
}

public var name: String {
return "\(PolygonAmoy.chainId)_\(self.rawValue)"
return "PolygonAmoy_\(self.rawValue)"
}
}

Expand All @@ -142,6 +142,6 @@ public enum ArbitrumSepoliaToken: String {
}

public var name: String {
return "\(ArbitrumSepolia.chainId)_\(self.rawValue)"
return "ArbitrumSepolia_\(self.rawValue)"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public class HttpTransport: Transport {
extension HttpTransport {

func send<T: Decodable>(_ urlRequest: URLRequest) async throws -> T {
var data: Data = .init(), response: URLResponse?
do {
let (data, response) = try await session.data(for: urlRequest)
(data, response) = try await session.data(for: urlRequest)
try processResponse(data: data, response: response)

if let errorResult = try? decodeData(data: data) as JsonRpcErrorResult {
Expand All @@ -72,6 +73,8 @@ extension HttpTransport {
return try decodeData(data: data) as T
}

} catch let error as BaseError {
throw error
} catch let error as HttpError {
var _details: String?
var _cause: Error?
Expand All @@ -85,7 +88,12 @@ extension HttpTransport {
_details = "Decoding Failed."
_cause = error
case .unknownError(let statusCode):
_details = "Request failed: \(statusCode)"
if let errorResult = try? decodeData(data: data) as JsonRpcErrorResult {
_details = errorResult.error.message
} else {
let message = String(data: data, encoding: .utf8) ?? ""
_details = "Request failed: \(message)"
}
_statusCode = statusCode
default:
_details = String(describing: error)
Expand Down
Loading