Skip to content

Commit

Permalink
do the ios side
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 24, 2024
1 parent 1ccaec4 commit 8ac19bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions ios/Wrappers/AuthParamsWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,40 @@ struct AuthParamsWrapper {
let enableV3: Bool
let dbDirectory: String?
let historySyncUrl: String?
let isSmartContractWallet: Bool
let walletType: WalletType
let chainId: UInt64?
let blockNumber: UInt64?

init(environment: String, appVersion: String?, enableV3: Bool, dbDirectory: String?, historySyncUrl: String?, isSmartContractWallet: Bool, chainId: UInt64?, blockNumber: UInt64?) {
init(environment: String, appVersion: String?, enableV3: Bool, dbDirectory: String?, historySyncUrl: String?, walletType: WalletType, chainId: UInt64?, blockNumber: UInt64?) {
self.environment = environment
self.appVersion = appVersion
self.enableV3 = enableV3
self.dbDirectory = dbDirectory
self.historySyncUrl = historySyncUrl
self.isSmartContractWallet = isSmartContractWallet
self.walletType = walletType
self.chainId = chainId
self.blockNumber = blockNumber
}

static func authParamsFromJson(_ authParams: String) -> AuthParamsWrapper {
guard let data = authParams.data(using: .utf8),
let jsonOptions = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else {
return AuthParamsWrapper(environment: "dev", appVersion: nil, enableV3: false, dbDirectory: nil, historySyncUrl: nil, isSmartContractWallet: false, chainId: nil, blockNumber: nil)
return AuthParamsWrapper(environment: "dev", appVersion: nil, enableV3: false, dbDirectory: nil, historySyncUrl: nil, walletType: WalletType.EOA, chainId: nil, blockNumber: nil)
}

let environment = jsonOptions["environment"] as? String ?? "dev"
let appVersion = jsonOptions["appVersion"] as? String
let enableV3 = jsonOptions["enableV3"] as? Bool ?? false
let dbDirectory = jsonOptions["dbDirectory"] as? String
let historySyncUrl = jsonOptions["historySyncUrl"] as? String
let isSmartContractWallet = jsonOptions["isSmartContractWallet"] as? Bool ?? false
let walletTypeString = jsonOptions["walletType"] as? String ?? "EOA"
let chainId = jsonOptions["chainId"] as? Int
let blockNumber = jsonOptions["blockNumber"] as? Int

let walletType = switch walletTypeString {
case "SCW" -> return WalletType.SCW
default: return WalletType.EOA
}


return AuthParamsWrapper(
Expand All @@ -51,7 +56,7 @@ struct AuthParamsWrapper {
enableV3: enableV3,
dbDirectory: dbDirectory,
historySyncUrl: historySyncUrl,
isSmartContractWallet: isSmartContractWallet,
walletType: walletType,
chainId: chainId != nil ? UInt64(chainId!) : nil,
blockNumber: blockNumber != nil ? UInt64(blockNumber!) : nil
)
Expand Down
2 changes: 1 addition & 1 deletion ios/XMTPModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public class XMTPModule: Module {
dbDirectory: authOptions.dbDirectory,
historySyncUrl: authOptions.historySyncUrl
)
let client = try await XMTP.Client.buildV3(address: address, chainId: authOptions.chainId, options: options)
let client = try await XMTP.Client.buildV3(address: address, options: options)
await clientsManager.updateClient(key: client.inboxID, client: client)
return try ClientWrapper.encodeToObj(client)
}
Expand Down

0 comments on commit 8ac19bb

Please sign in to comment.