Skip to content

Commit 99454e8

Browse files
committed
version up
1 parent 67d7ec8 commit 99454e8

File tree

9 files changed

+89
-65
lines changed

9 files changed

+89
-65
lines changed

BeamWallet.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4418,7 +4418,7 @@
44184418
CLANG_WARN_ENUM_CONVERSION = NO;
44194419
CODE_SIGN_ENTITLEMENTS = Resources/BeamWallet.entitlements;
44204420
CODE_SIGN_STYLE = Automatic;
4421-
CURRENT_PROJECT_VERSION = 5;
4421+
CURRENT_PROJECT_VERSION = 17;
44224422
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
44234423
DEVELOPMENT_TEAM = KNU2R94BJK;
44244424
ENABLE_BITCODE = NO;
@@ -4493,7 +4493,7 @@
44934493
CLANG_WARN_ENUM_CONVERSION = NO;
44944494
CODE_SIGN_ENTITLEMENTS = Resources/BeamWallet.entitlements;
44954495
CODE_SIGN_STYLE = Automatic;
4496-
CURRENT_PROJECT_VERSION = 5;
4496+
CURRENT_PROJECT_VERSION = 17;
44974497
DEVELOPMENT_TEAM = KNU2R94BJK;
44984498
ENABLE_BITCODE = NO;
44994499
FRAMEWORK_SEARCH_PATHS = (
@@ -4731,7 +4731,7 @@
47314731
CODE_SIGN_ENTITLEMENTS = Resources/BeamWalletMasterNet.entitlements;
47324732
CODE_SIGN_IDENTITY = "iPhone Developer";
47334733
CODE_SIGN_STYLE = Automatic;
4734-
CURRENT_PROJECT_VERSION = 55;
4734+
CURRENT_PROJECT_VERSION = 56;
47354735
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
47364736
DEVELOPMENT_TEAM = KNU2R94BJK;
47374737
ENABLE_BITCODE = NO;
@@ -4808,7 +4808,7 @@
48084808
CODE_SIGN_ENTITLEMENTS = Resources/BeamWalletMasterNet.entitlements;
48094809
CODE_SIGN_IDENTITY = "iPhone Developer";
48104810
CODE_SIGN_STYLE = Automatic;
4811-
CURRENT_PROJECT_VERSION = 55;
4811+
CURRENT_PROJECT_VERSION = 56;
48124812
DEVELOPMENT_TEAM = KNU2R94BJK;
48134813
ENABLE_BITCODE = NO;
48144814
FRAMEWORK_SEARCH_PATHS = (

BeamWallet/BeamSDK/AppModel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ typedef void(^FeecalculatedBlock)(uint64_t fee, double change, uint64_t shielded
9393
@property (nonatomic,assign) BOOL isNodeChanging;
9494
@property (nonatomic,assign) BOOL isOwnNode;
9595
@property (nonatomic,assign) BMRestoreType restoreType;
96+
@property (nonatomic,assign) BOOL isMaxPrivacyRequest;
9697

9798
@property (nonatomic,strong) BMWalletStatus* _Nullable walletStatus;
9899
@property (nonatomic,strong) NSMutableArray<BMTransaction*>*_Nullable transactions;

BeamWallet/BeamSDK/AppModel.mm

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,16 @@ +(NSString*_Nonnull)chooseRandomNodeWithoutNodes:(NSArray*)nodes {
214214
for (const auto& item : peers) {
215215
BOOL found = NO;
216216
NSString *address = [NSString stringWithUTF8String:item.c_str()];
217-
218-
for (NSString *node in nodes) {
219-
if([address isEqualToString:node]) {
220-
found = YES;
217+
if ([address rangeOfString:@"shanghai"].location == NSNotFound) {
218+
for (NSString *node in nodes) {
219+
if([address isEqualToString:node]) {
220+
found = YES;
221+
}
222+
}
223+
224+
if (!found) {
225+
[array addObject:address];
221226
}
222-
}
223-
224-
if (!found) {
225-
[array addObject:address];
226227
}
227228
}
228229

@@ -241,7 +242,9 @@ +(NSArray*_Nonnull)randomNodes {
241242

242243
for (const auto& item : peers) {
243244
NSString *address = [NSString stringWithUTF8String:item.c_str()];
244-
[array addObject:address];
245+
if([address rangeOfString:@"shanghai"].location == NSNotFound) {
246+
[array addObject:address];
247+
}
245248
}
246249

247250
return array;
@@ -254,7 +257,9 @@ +(NSString*_Nonnull)chooseRandomNode {
254257

255258
for (const auto& item : peers) {
256259
NSString *address = [NSString stringWithUTF8String:item.c_str()];
257-
[array addObject:address];
260+
if([address rangeOfString:@"shanghai"].location == NSNotFound) {
261+
[array addObject:address];
262+
}
258263
}
259264

260265
srand([[NSDate date] timeIntervalSince1970]);
@@ -1883,16 +1888,20 @@ -(NSString*_Nullable)feeError:(double)fee {
18831888

18841889
-(void)calculateFee:(double)amount fee:(double)fee isShielded:(BOOL) isShielded result:(FeecalculatedBlock _Nonnull )block {
18851890

1891+
self.isMaxPrivacyRequest = isShielded;
1892+
18861893
self.feecalculatedBlock = block;
18871894

18881895
Amount bAmount = round(amount * Rules::Coin);
18891896
Amount bFee = fee;
18901897

1891-
wallet->getAsync()->calcShieldedCoinSelectionInfo(bAmount, bFee, isShielded);
1898+
wallet->getAsync()->calcShieldedCoinSelectionInfo(bAmount + bFee, 0, isShielded);
18921899
}
18931900

18941901
-(void)calculateFee2:(double)amount fee:(double)fee isShielded:(BOOL) isShielded result:(FeecalculatedBlock _Nonnull )block {
18951902

1903+
self.isMaxPrivacyRequest = isShielded;
1904+
18961905
self.feecalculatedBlock = block;
18971906

18981907
Amount bAmount = round(amount * Rules::Coin);

BeamWallet/BeamSDK/Objects/BMTransaction.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#import "BMAddress.h"
2525
#import "AppModel.h"
2626

27+
2728
@implementation BMTransaction
2829

2930
- (void)encodeWithCoder:(NSCoder *)encoder
@@ -648,5 +649,6 @@ -(NSString*)textDetails {
648649
return [details componentsJoinedByString:@"\n\n"];
649650
}
650651

652+
651653
@end
652654

BeamWallet/BeamSDK/WalletModel.mm

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@
101101
auto kernelId = to_hex(item.m_kernelID.m_pData, item.m_kernelID.nBytes);
102102
std::string comment(item.m_message.begin(), item.m_message.end());
103103

104+
Amount fee = item.m_fee;
105+
106+
std::vector<TxKernel::Ptr> shieldedInputs;
107+
item.GetParameter(TxParameterID::InputsShielded, shieldedInputs);
108+
if (shieldedInputs.size())
109+
{
110+
Transaction::FeeSettings fs;
111+
Amount shieldedFee = shieldedInputs.size() * (fs.m_Kernel + fs.m_ShieldedInput);
112+
fee = shieldedFee + item.m_fee;
113+
}
114+
104115
BMTransaction *transaction = [BMTransaction new];
105116
transaction.realAmount = double(int64_t(item.m_amount)) / Rules::Coin;
106117
transaction.createdTime = item.m_createTime;
@@ -117,8 +128,8 @@
117128
transaction.identity = [NSString stringWithUTF8String:item.getIdentity(item.m_sender).c_str()];
118129
transaction.ID = [NSString stringWithUTF8String:txIDToString(item.m_txId).c_str()];
119130
transaction.isSelf = item.m_selfTx;
120-
transaction.fee = double(int64_t(item.m_fee)) / Rules::Coin;
121-
transaction.realFee = int64_t(item.m_fee);
131+
transaction.fee = double(int64_t(fee)) / Rules::Coin;
132+
transaction.realFee = int64_t(fee);
122133
transaction.kernelId = [NSString stringWithUTF8String:kernelId.c_str()];
123134
transaction.canCancel = item.canCancel();
124135
transaction.canResume = item.canResume();
@@ -1104,11 +1115,13 @@
11041115
{
11051116
auto result = selectionRes.minimalFee;
11061117
auto change = selectionRes.change;
1118+
if ([AppModel sharedManager].isMaxPrivacyRequest) {
1119+
change = selectionRes.change + selectionRes.shieldedInputsFee;
1120+
}
1121+
1122+
11071123
auto shieldedInputsFee = selectionRes.shieldedInputsFee;
11081124

1109-
// if (change > 0) {
1110-
// change = change + selectionRes.selectedFee; //+ selectionRes.requestedFee;
1111-
// }
11121125
double amount = double(int64_t(change)) / Rules::Coin;
11131126

11141127
[AppModel sharedManager].feecalculatedBlock(result, amount, shieldedInputsFee);

BeamWallet/Model/Transaction/SendTransactionViewModel.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ class SendTransactionViewModel: NSObject, WalletModelDelegate {
7575
}
7676

7777
public func calculateFee() {
78-
if AppModel.sharedManager().walletStatus?.shielded ?? 0 > 0 {
79-
AppModel.sharedManager().calculateFee(Double(amount) ?? 0, fee: 0, isShielded: maxPrivacy) { (result, changed, shieldedInputsFee) in
78+
// if AppModel.sharedManager().walletStatus?.shielded ?? 0 > 0 {
79+
AppModel.sharedManager().calculateFee(Double(amount) ?? 0, fee: (Double(fee) ?? 0), isShielded: maxPrivacy) { (result, changed, shieldedInputsFee) in
8080
DispatchQueue.main.async {
8181
self.shieldedInputsFee = shieldedInputsFee
8282
let current = UInt64(self.fee) ?? 0
@@ -92,7 +92,7 @@ class SendTransactionViewModel: NSObject, WalletModelDelegate {
9292
}
9393
}
9494
}
95-
}
95+
// }
9696
}
9797

9898
public var requestedMaxPrivacy = false
@@ -507,15 +507,19 @@ class SendTransactionViewModel: NSObject, WalletModelDelegate {
507507
}
508508

509509
public func calculateChange() {
510-
if (AppModel.sharedManager().walletStatus?.shielded ?? 0) > 0 {
510+
// AppModel.sharedManager().calculateFee2((Double(amount) ?? 0), fee: (Double(fee) ?? 0), isShielded: maxPrivacy || requestedMaxPrivacy) { (fee, change, shieldedInputsFee) in
511+
// self.onCalculateChanged?(change)
512+
// }
513+
514+
// if (AppModel.sharedManager().walletStatus?.shielded ?? 0) > 0 {
511515
AppModel.sharedManager().calculateFee2((Double(amount) ?? 0), fee: (Double(fee) ?? 0), isShielded: maxPrivacy || requestedMaxPrivacy) { (fee, change, shieldedInputsFee) in
512516
self.onCalculateChanged?(change)
513517
}
514-
}
515-
else {
516-
AppModel.sharedManager().calculateChange(Double(amount) ?? 0, fee: Double(fee) ?? 0)
517-
}
518-
518+
// }
519+
// else {
520+
// AppModel.sharedManager().calculateChange(Double(amount) ?? 0, fee: Double(fee) ?? 0)
521+
// }
522+
//
519523
if AppModel.sharedManager().isToken(toAddress) {
520524
_ = AppModel.sharedManager().getTransactionParameters(toAddress)
521525
}

BeamWallet/ViewControllers/Login/OpenWalletProgressViewController.swift

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,16 @@ class OpenWalletProgressViewController: BaseViewController {
8080
cancelButton.isHidden = false
8181
}
8282
else if phrase == nil {
83+
timeoutTimer?.invalidate()
8384
timeoutTimer = Timer.scheduledTimer(timeInterval: 10.0, target: self, selector: #selector(onTimeOut), userInfo: nil, repeats: false)
8485

8586
progressTitleLabel.text = Localizable.shared.strings.loading_wallet
8687
cancelButton.isHidden = true
8788
}
89+
else if phrase != nil {
90+
timeoutTimer?.invalidate()
91+
timeoutTimer = Timer.scheduledTimer(timeInterval: 10.0, target: self, selector: #selector(openMainPage), userInfo: nil, repeats: false)
92+
}
8893

8994
if let base = self.navigationController as? BaseNavigationController {
9095
base.enableSwipeToDismiss = false
@@ -110,7 +115,12 @@ class OpenWalletProgressViewController: BaseViewController {
110115
}
111116
}
112117

113-
private func openMainPage() {
118+
@objc private func openMainPage() {
119+
if isPresented {
120+
return
121+
}
122+
123+
114124
isPresented = true
115125

116126
if phrase != nil {
@@ -306,11 +316,7 @@ class OpenWalletProgressViewController: BaseViewController {
306316

307317
@objc private func onTimeOut() {
308318
if Settings.sharedManager().isChangedNode() {
309-
if !self.isPresented {
310-
self.isPresented = true
311-
312-
self.openMainPage()
313-
}
319+
self.openMainPage()
314320
}
315321
}
316322
}
@@ -321,8 +327,7 @@ extension OpenWalletProgressViewController : WalletModelDelegate {
321327
DispatchQueue.main.async { [weak self] in
322328
guard let strongSelf = self else { return }
323329

324-
if connected && !strongSelf.isPresented && !AppModel.sharedManager().isRestoreFlow {
325-
strongSelf.isPresented = true
330+
if connected && !AppModel.sharedManager().isRestoreFlow {
326331
strongSelf.progressView.progress = 1
327332

328333
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
@@ -416,16 +421,11 @@ extension OpenWalletProgressViewController : WalletModelDelegate {
416421
let error = _error as NSError
417422

418423
if error.code == 2 && Settings.sharedManager().isChangedNode() {
419-
if !strongSelf.isPresented {
420-
strongSelf.isPresented = true
421-
strongSelf.openMainPage()
422-
}
424+
strongSelf.openMainPage()
423425
}
424426
else if error.code == 1 {
425-
if !strongSelf.isPresented {
426-
strongSelf.isPresented = true
427-
strongSelf.openMainPage()
428-
}
427+
strongSelf.openMainPage()
428+
429429
// if strongSelf.navigationController?.viewControllers.last is OpenWalletProgressViewController {
430430
// strongSelf.confirmAlert(title: Localizable.shared.strings.incompatible_node_title, message: Localizable.shared.strings.incompatible_node_info, cancelTitle: Localizable.shared.strings.cancel, confirmTitle: Localizable.shared.strings.change_settings, cancelHandler: { (_ ) in
431431
//
@@ -438,10 +438,7 @@ extension OpenWalletProgressViewController : WalletModelDelegate {
438438
// }
439439
}
440440
else if error.code == 4 {
441-
if !strongSelf.isPresented {
442-
strongSelf.isPresented = true
443-
strongSelf.openMainPage()
444-
}
441+
strongSelf.openMainPage()
445442
}
446443
else if !strongSelf.isPresented {
447444
if let controllers = strongSelf.navigationController?.viewControllers {

BeamWallet/ViewControllers/Main/Settings/TrustedNodeViewController.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class TrustedNodeViewController: BMInputViewController {
3131
private var timer = Timer()
3232
private var timeoutTimer = Timer()
3333
private var event: EventType!
34-
34+
private var isConnected = false
35+
3536
private var oldAddress: String!
3637

3738
init(event: EventType) {
@@ -238,22 +239,17 @@ extension TrustedNodeViewController: UITextFieldDelegate {
238239
extension TrustedNodeViewController: WalletModelDelegate {
239240

240241
func onWalletStatusChange(_ status: BMWalletStatus) {
241-
if status.available > 0 {
242+
if status.available > 0 && event == .restore && !Settings.sharedManager().connectToRandomNode {
242243
DispatchQueue.main.async { [weak self] in
243244
guard let strongSelf = self else { return }
244-
if !strongSelf.isPresented {
245-
strongSelf.isPresented = true
246-
strongSelf.timer.invalidate()
247-
SVProgressHUD.dismiss()
248-
strongSelf.openMainPage()
249-
}
245+
strongSelf.timeout()
250246
}
251247
}
252248
}
253249

254250
@objc private func timeout() {
255251
SVProgressHUD.dismiss()
256-
if !isPresented {
252+
if !isPresented && !Settings.sharedManager().connectToRandomNode {
257253
isPresented = true
258254
timer.invalidate()
259255
timeoutTimer.invalidate()
@@ -264,6 +260,7 @@ extension TrustedNodeViewController: WalletModelDelegate {
264260
@objc private func timerAction() {
265261

266262
let connected = AppModel.sharedManager().isConnected
263+
isConnected = connected
267264

268265
if connected {
269266
errorLabel.isHidden = true
@@ -275,6 +272,7 @@ extension TrustedNodeViewController: WalletModelDelegate {
275272
}
276273
timer.invalidate()
277274

275+
timeoutTimer.invalidate()
278276
timeoutTimer = Timer.scheduledTimer(timeInterval: 15, target: self, selector: #selector(timeout), userInfo: nil, repeats: false)
279277
}
280278
else {

BeamWallet/ViewControllers/Main/Wallet/Send/SendConfirmViewController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -215,13 +215,13 @@ extension SendConfirmViewController: WalletModelDelegate {
215215

216216
func onChangeCalculated(_ amount: Double) {
217217
DispatchQueue.main.async {
218-
let am = amount
219-
// let total = AppModel.sharedManager().realTotal(Double(self.viewModel.amount) ?? 0, fee: Double(self.viewModel.fee) ?? 0)
220-
// let left = (AppModel.sharedManager().walletStatus?.realAmount ?? 0) - total
221-
//
222-
// if left < am {
223-
// am = 0
224-
// }
218+
var am = amount
219+
let total = AppModel.sharedManager().realTotal(Double(self.viewModel.amount) ?? 0, fee: Double(self.viewModel.fee) ?? 0)
220+
let left = (AppModel.sharedManager().walletStatus?.realAmount ?? 0) - total
221+
222+
if left < am {
223+
am = 0
224+
}
225225

226226
let totalString = String.currency(value: am) //+ Localizable.shared.strings.beam
227227
let item = BMMultiLineItem(title: Localizable.shared.strings.change_locked, detail: totalString, detailFont: SemiboldFont(size: 16), detailColor: UIColor.white)

0 commit comments

Comments
 (0)