Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Nov 21, 2024
2 parents 79316dc + d4d21e9 commit 86c0510
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 239 deletions.
17 changes: 0 additions & 17 deletions __mocks__/react-native-tor.ts

This file was deleted.

15 changes: 7 additions & 8 deletions components/CompanionDelegates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,14 @@ const CompanionDelegates = () => {
} catch (error) {
console.error('Error detecting QR code:', error);
}
} else {
DeeplinkSchemaMatch.navigationRouteFor(event, (value: [string, any]) => navigationRef.navigate(...value), {
wallets,
addWallet,
saveToDisk,
setSharedCosigner,
});
}
} else {
triggerHapticFeedback(HapticFeedbackTypes.NotificationSuccess);
DeeplinkSchemaMatch.navigationRouteFor(event, (value: [string, any]) => navigationRef.navigate(...value), {
wallets,
addWallet,
saveToDisk,
setSharedCosigner,
});
}
},
[wallets, addWallet, saveToDisk, setSharedCosigner],
Expand Down
56 changes: 42 additions & 14 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ platform :android do
UI.message("APK build completed.")

# Define APK name based on branch
signed_apk_name = branch_name != 'master' ?
"BlueWallet-#{version_name}-#{build_number}-#{branch_name}".gsub(/[\/\\:?*"<>|]/, '_') + ".apk" :
signed_apk_name = branch_name != 'master' ?
"BlueWallet-#{version_name}-#{build_number}-#{branch_name}".gsub(/[\/\\:?*"<>|]/, '_') + ".apk" :
"BlueWallet-#{version_name}-#{build_number}.apk"

# Define paths
Expand All @@ -90,7 +90,6 @@ platform :android do
end
end


desc "Upload APK to BrowserStack and post result as PR comment"
lane :upload_to_browserstack_and_comment do
Dir.chdir(project_root) do
Expand Down Expand Up @@ -120,8 +119,10 @@ platform :android do
browserstack_hashed_id = app_url.gsub('bs://', '')
pr_number = ENV['GITHUB_PR_NUMBER']

comment_identifier = '### APK Successfully Uploaded to BrowserStack'

comment = <<~COMMENT
### APK Successfully Uploaded to BrowserStack
#{comment_identifier}
You can test it on the following devices:
Expand All @@ -139,22 +140,49 @@ platform :android do
**BrowserStack App URL**: #{app_url}
COMMENT

# Post PR comment if PR number is available
# Delete Previous BrowserStack Comments
if pr_number
begin
repo = ENV['GITHUB_REPOSITORY'] # Format: "owner/repo"
repo_owner, repo_name = repo.split('/')

UI.message("Fetching existing comments for PR ##{pr_number}...")

comments_json = `gh api -X GET /repos/#{repo_owner}/#{repo_name}/issues/#{pr_number}/comments`
comments = JSON.parse(comments_json)

comments.each do |comment|
if comment['body'].start_with?(comment_identifier)
comment_id = comment['id']
UI.message("Deleting previous comment ID: #{comment_id}...")
`gh api -X DELETE /repos/#{repo_owner}/#{repo_name}/issues/comments/#{comment_id}`
UI.success("Deleted comment ID: #{comment_id}")
end
end

rescue => e
UI.error("Failed to delete previous comments: #{e.message}")
end
else
UI.important("No PR number found. Skipping deletion of previous comments.")
end

# Post New Comment to PR
if pr_number
begin
sh("GH_TOKEN=#{ENV['GH_TOKEN']} gh pr comment #{pr_number} --body '#{comment}'")
UI.success("Posted comment to PR ##{pr_number}")
escaped_comment = comment.gsub("'", "'\\''")
sh("GH_TOKEN=#{ENV['GH_TOKEN']} gh pr comment #{pr_number} --body '#{escaped_comment}'")
UI.success("Posted new comment to PR ##{pr_number}")
rescue => e
UI.error("Failed to post comment to PR: #{e.message}")
end
else
UI.important("No PR number found. Skipping PR comment.")
end
end
end

end


# ===========================
# iOS Lanes
# ===========================
Expand Down Expand Up @@ -294,7 +322,7 @@ platform :ios do
desc "Install CocoaPods dependencies"
lane :install_pods do
UI.message("Installing CocoaPods dependencies...")
cocoapods(podfile: "ios/Podfile", deployment: true, clean_install: true)
cocoapods(podfile: "ios/Podfile")
end


Expand All @@ -321,7 +349,7 @@ platform :ios do
CHANGELOG

ipa_path = ENV['IPA_OUTPUT_PATH']

if ipa_path.nil? || ipa_path.empty? || !File.exist?(ipa_path)
UI.user_error!("IPA file not found at path: #{ipa_path}")
end
Expand Down Expand Up @@ -378,7 +406,7 @@ lane :build_app_lane do
export_options_path = File.join(project_root, "ios", "export_options.plist")

clear_derived_data_lane

begin
build_ios_app(
scheme: "BlueWallet",
Expand Down Expand Up @@ -412,7 +440,7 @@ lane :build_app_lane do
end
end
end

end
# ===========================
# Global Lanes
# ===========================
Expand Down Expand Up @@ -561,5 +589,5 @@ lane :update_release_notes do |options|
UI.error("No localization found for locale #{locale}")
end
end
end
end
end
16 changes: 8 additions & 8 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ PODS:
- React-Core
- RealmJS (20.0.0):
- React
- RNCAsyncStorage (2.0.0):
- RNCAsyncStorage (2.1.0):
- React-Core
- RNCClipboard (1.15.0):
- React-Core
Expand All @@ -1604,7 +1604,7 @@ PODS:
- React-Core
- RNFS (2.20.0):
- React-Core
- RNGestureHandler (2.20.2):
- RNGestureHandler (2.21.1):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1789,7 +1789,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNShare (11.0.4):
- RNShare (11.1.0):
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -1810,7 +1810,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- RNSVG (15.8.0):
- RNSVG (15.9.0):
- React-Core
- RNVectorIcons (10.2.0):
- DoubleConversion
Expand Down Expand Up @@ -2260,13 +2260,13 @@ SPEC CHECKSUMS:
ReactCommon: 36d48f542b4010786d6b2bcee615fe5f906b7105
ReactNativeCameraKit: f058d47e0b1e55fd819bb55ee16505a2e0ca53db
RealmJS: 7947e9d9edcfb4fde3dcf9911d320a2e08cdd540
RNCAsyncStorage: 40367e8d25522dca9c3513c7b9815a184669bd97
RNCAsyncStorage: c91d753ede6dc21862c4922cd13f98f7cfde578e
RNCClipboard: dbcf25b8f666b4685c02eeb65be981d30198e505
RNCPushNotificationIOS: 6c4ca3388c7434e4a662b92e4dfeeee858e6f440
RNDefaultPreference: ee13d69e6693d193cd223d10e15e5b3c012d31ba
RNDeviceInfo: ae26ae45db3f9937f038a284bcd0a1db8d70db96
RNFS: 89de7d7f4c0f6bafa05343c578f61118c8282ed8
RNGestureHandler: 27a63f2218affdf1a426d56682f9b174904838b3
RNGestureHandler: 7be359a48b77254597f10108757dd5cd85b782e7
RNHandoff: bc8af5a86853ff13b033e7ba1114c3c5b38e6385
RNKeychain: 4df48b5186ca2b6a99f5ead69ad587154e084a32
RNLocalize: d024afa9204c13885e61dc88b8190651bcaabac9
Expand All @@ -2277,8 +2277,8 @@ SPEC CHECKSUMS:
RNReactNativeHapticFeedback: 00ba111b82aa266bb3ee1aa576831c2ea9a9dfad
RNReanimated: 6398ee150e1ebeda517fdd1e1b5525833a0c0ddc
RNScreens: 35bb8e81aeccf111baa0ea01a54231390dbbcfd9
RNShare: 6af59763338a7d8440035701f39be9d53cbc4d09
RNSVG: 8542aa11770b27563714bbd8494a8436385fc85f
RNShare: 6204e6a1987ba3e7c47071ef703e5449a0e3548a
RNSVG: bb4bfcb8ec723a6f34b074a1b7cd40ee35246fe5
RNVectorIcons: 182892e7d1a2f27b52d3c627eca5d2665a22ee28
RNWatch: 28fe1f5e0c6410d45fd20925f4796fce05522e3f
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Expand Down
95 changes: 47 additions & 48 deletions ios/Shared/MarketAPI+Electrum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,60 +14,59 @@ struct APIError: LocalizedError {

extension MarketAPI {

static func fetchNextBlockFee(completion: @escaping ((MarketData?, Error?) -> Void), userElectrumSettings: UserDefaultsElectrumSettings = UserDefaultsGroup.getElectrumSettings()) {
let settings = userElectrumSettings
let portToUse = settings.sslPort ?? settings.port
let isSSLSupported = settings.sslPort != nil
static func fetchNextBlockFee(completion: @escaping ((MarketData?, Error?) -> Void), userElectrumSettings: UserDefaultsElectrumSettings = UserDefaultsGroup.getElectrumSettings()) {
Task {
let client = SwiftTCPClient()
defer {
print("Closing connection to \(userElectrumSettings.host ?? "unknown"):\(userElectrumSettings.sslPort ?? userElectrumSettings.port ?? 0).")
client.close()
}

DispatchQueue.global(qos: .background).async {
let client = SwiftTCPClient()
guard let host = userElectrumSettings.host, let portToUse = userElectrumSettings.sslPort ?? userElectrumSettings.port else {
completion(nil, APIError())
return
}

defer {
print("Closing connection to \(String(describing: settings.host)):\(String(describing: portToUse)).")
client.close()
}

guard let host = settings.host, let portToUse = portToUse else { return }
let isSSLSupported = userElectrumSettings.sslPort != nil
print("Attempting to connect to \(host):\(portToUse) with SSL supported: \(isSSLSupported).")

print("Attempting to connect to \(String(describing: settings.host)):\(portToUse) with SSL supported: \(isSSLSupported).")

if client.connect(to: host, port: UInt32(portToUse), useSSL: isSSLSupported) {
print("Successfully connected to \(String(describing: settings.host)):\(portToUse) with SSL:\(isSSLSupported).")
} else {
print("Failed to connect to \(String(describing: settings.host)):\(portToUse) with SSL:\(isSSLSupported).")
completion(nil, APIError())
return
}
let connected = await client.connect(to: host, port: portToUse, useSSL: isSSLSupported)
if connected {
print("Successfully connected to \(host):\(portToUse) with SSL: \(isSSLSupported).")
} else {
print("Failed to connect to \(host):\(portToUse) with SSL: \(isSSLSupported).")
completion(nil, APIError())
return
}

let message = "{\"id\": 1, \"method\": \"mempool.get_fee_histogram\", \"params\": []}\n"
guard let data = message.data(using: .utf8), client.send(data: data) else {
print("Message sending failed to \(String(describing: settings.host)):\(portToUse) with SSL supported: \(isSSLSupported).")
completion(nil, APIError())
return
}
print("Message sent successfully to \(String(describing: settings.host)):\(portToUse) with SSL:\(isSSLSupported).")
let message = "{\"id\": 1, \"method\": \"mempool.get_fee_histogram\", \"params\": []}\n"
guard let data = message.data(using: .utf8), await client.send(data: data) else {
print("Message sending failed to \(host):\(portToUse) with SSL supported: \(isSSLSupported).")
completion(nil, APIError())
return
}
print("Message sent successfully to \(host):\(portToUse) with SSL: \(isSSLSupported).")

do {
let receivedData = try client.receive()
print("Data received. Parsing...")
guard let responseString = String(data: receivedData, encoding: .utf8),
let responseData = responseString.data(using: .utf8),
let json = try JSONSerialization.jsonObject(with: responseData, options: .allowFragments) as? [String: AnyObject],
let feeHistogram = json["result"] as? [[Double]] else {
print("Failed to parse response from \(String(describing: settings.host)).")
completion(nil, APIError())
return
}
do {
let receivedData = try await client.receive()
print("Data received. Parsing...")
guard let json = try JSONSerialization.jsonObject(with: receivedData, options: .allowFragments) as? [String: AnyObject],
let feeHistogram = json["result"] as? [[Double]] else {
print("Failed to parse response from \(host).")
completion(nil, APIError())
return
}

let fastestFee = calcEstimateFeeFromFeeHistogram(numberOfBlocks: 1, feeHistogram: feeHistogram)
let marketData = MarketData(nextBlock: String(format: "%.0f", fastestFee), sats: "0", price: "0", rate: 0)
completion(marketData, nil) // Successfully fetched data, return it
} catch {
print("Error receiving data from \(String(describing: settings.host)): \(error.localizedDescription)")
completion(nil, APIError())
}
}
}
let fastestFee = calcEstimateFeeFromFeeHistogram(numberOfBlocks: 1, feeHistogram: feeHistogram)
let marketData = MarketData(nextBlock: String(format: "%.0f", fastestFee), sats: "0", price: "0", rate: 0, dateString: "")
print("Parsed MarketData: \(marketData)")
completion(marketData, nil)
} catch {
print("Error receiving data from \(host): \(error.localizedDescription)")
completion(nil, APIError())
}
}
}

static func fetchMarketData(currency: String, completion: @escaping ((MarketData?, Error?) -> Void)) {
var marketDataEntry = MarketData(nextBlock: "...", sats: "...", price: "...", rate: 0)
Expand Down
16 changes: 8 additions & 8 deletions ios/Shared/UserDefaultsGroup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import Foundation

struct UserDefaultsElectrumSettings {
let host: String?
let port: Int32?
let sslPort: Int32?
var host: String?
var port: UInt16?
var sslPort: UInt16?
}

let hardcodedPeers = [
Expand All @@ -34,14 +34,14 @@ class UserDefaultsGroup {
return DefaultElectrumPeers.randomElement()!
}

let electrumSettingsTCPPort = suite?.string(forKey: UserDefaultsGroupKey.ElectrumSettingsTCPPort.rawValue) ?? "50001"
let electrumSettingsSSLPort = suite?.string(forKey: UserDefaultsGroupKey.ElectrumSettingsSSLPort.rawValue) ?? "50002"
let electrumSettingsTCPPort = suite?.value(forKey: UserDefaultsGroupKey.ElectrumSettingsTCPPort.rawValue) ?? 50001
let electrumSettingsSSLPort = suite?.value(forKey: UserDefaultsGroupKey.ElectrumSettingsSSLPort.rawValue) ?? 50002

let host = electrumSettingsHost
let sslPort = Int32(electrumSettingsSSLPort)
let port = Int32(electrumSettingsTCPPort)
let sslPort = electrumSettingsSSLPort
let port = electrumSettingsTCPPort

return UserDefaultsElectrumSettings(host: host, port: port, sslPort: sslPort)
return UserDefaultsElectrumSettings(host: host, port: port as! UInt16, sslPort: sslPort as! UInt16)
}

static func getAllWalletsBalance() -> Double {
Expand Down
Loading

0 comments on commit 86c0510

Please sign in to comment.