Skip to content

Commit

Permalink
feat: support custom GRPC clients.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew54068 committed Jun 5, 2023
1 parent 33ed23a commit 47f3928
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 19 deletions.
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/portto/blocto-ios-sdk.git",
"state" : {
"revision" : "6c24b03c33076f9d5f17c013483dad040a687467",
"version" : "0.4.2"
"revision" : "977b0a4f2284c85ce3795ba959866e675cc39aac",
"version" : "0.4.4"
}
},
{
Expand All @@ -41,8 +41,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/portto/flow-swift-sdk.git",
"state" : {
"revision" : "b5e4c381def8b166a39496f2a32e184f4d8a17d1",
"version" : "0.4.2"
"revision" : "52448238d0e887af02fc0bdaf50ca76426317289",
"version" : "0.5.0"
}
},
{
Expand Down
5 changes: 3 additions & 2 deletions Sources/FCL-SDK/AppUtilities/AppUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ public enum AppUtilities {
case .testnet:
return Address(hexString: "0x74daa6f9c7ef24b1")
case .canarynet,
.sandboxnet,
.emulator:
.sandboxnet,
.emulator,
.custom:
throw FCLError.currentNetworkNotSupported
}
}
Expand Down
27 changes: 22 additions & 5 deletions Sources/FCL-SDK/FCL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ public class FCL: NSObject {

var flowAPIClient: Client {
get async throws {
let task = Task(priority: .utility) {
Client(network: config.network)
if let internalClient {
return internalClient
} else {
let task = Task(priority: .utility) {
let client = Client(network: config.network)
self.internalClient = client
return client
}
return await task.value
}
return await task.value
}
}

private var internalClient: Client?
private var webAuthSession: ASWebAuthenticationSession?
private let requestSession = URLSession(configuration: .default)

Expand Down Expand Up @@ -398,6 +405,7 @@ extension FCL {
/// - cadence: Cadence Transaction used to mutate Flow
/// - arguments: Arguments passed to cadence transaction
/// - limit: Compute Limit (gas limit) for transaction
/// - authorizers: Addresses of accounts data being modify by current transaction.
/// - Returns: Transaction id
public func mutate(
cadence: String,
Expand Down Expand Up @@ -448,7 +456,12 @@ public extension FCL {
options: CallOptions? = nil
) async throws -> [BlockEvents] {
try await flowAPIClient
.getEventsForHeightRange(eventType: eventType, startHeight: startHeight, endHeight: endHeight, options: options)
.getEventsForHeightRange(
eventType: eventType,
startHeight: startHeight,
endHeight: endHeight,
options: options
)
}

func getEventsForBlockIDs(
Expand All @@ -457,7 +470,11 @@ public extension FCL {
options: CallOptions? = nil
) async throws -> [BlockEvents] {
try await flowAPIClient
.getEventsForBlockIDs(eventType: eventType, blockIds: blockIds, options: options)
.getEventsForBlockIDs(
eventType: eventType,
blockIds: blockIds,
options: options
)
}

func getAccount(address: String) async throws -> FlowSDK.Account? {
Expand Down
9 changes: 4 additions & 5 deletions Sources/FCL-SDK/WalletProvider/BloctoWalletProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,10 @@ public final class BloctoWalletProvider: WalletProvider {
return .prod
case .testnet:
return .dev
case .canarynet:
return nil
case .sandboxnet:
return nil
case .emulator:
case .canarynet,
.sandboxnet,
.emulator,
.custom:
return nil
}
}
Expand Down
7 changes: 4 additions & 3 deletions Sources/FCL-SDK/WalletProvider/DapperWalletProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ public final class DapperWalletProvider: WalletProvider {
private var accessNodeApiString: String {
switch fcl.config.network {
case .testnet,
.canarynet,
.sandboxnet,
.emulator:
.canarynet,
.sandboxnet,
.emulator,
.custom:
return ""
case .mainnet:
return "https://dapper-http-post.vercel.app/api/authn"
Expand Down

0 comments on commit 47f3928

Please sign in to comment.